berkeley-cdss / course-site-myst

A MyST-based course website template
0 stars 1 forks source link

TOC that mixes drop-downs with individual files? #9

Open rgiordan opened 10 months ago

rgiordan commented 10 months ago

Is there a way in Myst to mix "parts" and files in the table of contents? For example, I would like the TOC to contain a link "Syllabus" directly to "syllabus.md," and then an expandable box called "Lectures" with links to a bunch of individual lecture markdown files.

For example, you might hope that this would work, but the Lectures section just doesn't show up:

chapters:
- file: syllabus
parts:
  - caption: Lectures
    chapters:
    - file: Lectures/Lecture1.md
    - file: Lectures/Lecture2.md
ryanlovett commented 10 months ago

Yes, if I understand you correctly. This worked in testing:

chapters:
- file: syllabus
- file: Lectures
  sections:
  - file: Lectures/Lecture1.md
  - file: Lectures/Lecture2.md

Here is what is looked like with additional files: Screenshot 2023-11-28 at 10 08 01 AM

MyST uses the jupyter-book table of contents structure, and this particular feature is documented at https://jupyterbook.org/en/stable/structure/toc.html#use-chapter-sub-sections.

If you want Lectures to only be a TOC heading and not be a landing page, I'll do a bit more digging.

rgiordan commented 10 months ago

I think this is workable. But you're right --- Lectures needs to be a file. If it's not (e.g., if it is the name of a directory, as in my case), the TOC just skips it, as you can see in this screenshot (which was generated with your TOC code):

Screenshot from 2023-11-28 11-41-17