-
-
Notifications
You must be signed in to change notification settings - Fork 741
feat: support dynamic table of contents #600
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
nozomuikuta
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added some inline comments.
|
|
||
| - Type: `Number` | ||
| - Default: `3` | ||
| - Version: **>= v1.11.0** |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is just an placeholder, and supposed to be set correctly later.
docs/content/en/configuration.md
Outdated
| - Default: `3` | ||
| - Version: **>= v1.11.0** | ||
|
|
||
| Define until which heading levels is included in table of contents. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure this sentence is valid in English...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would say: Maximum heading depth to include in the table of contents (source: https://github.com/remarkjs/remark-toc#optionsmaxdepth)
| fullTextSearchFields: ['title', 'description', 'slug', 'text'], | ||
| nestedProperties: [], | ||
| markdown: { | ||
| tocDepth: 3, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For backward compatibility, I set default value of tocDepth as 3, so that h2 and h3 are included in table of contents.
benjamincanac
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 🙂
| > | ||
| <a | ||
| :href="`#${link.id}`" | ||
| class="block text-sm scrollactive-item transition-padding ease-in-out duration-300 hover:pl-1" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hover:pl-1 might result in "too dynamic" animation for deeper headings.
|
Thank you for reviewing the draft PR! I modified parts of code and updated the PR message. |
|
Hmm, it seems tests that I added take too long...they passed in my local, though. |
|
OK, now all the tests are passed by splitting tests for the new feature. 🙌 |
|
Great work @nozomuikuta, thank you very much 🙂 I think it's ready to be merged! |
Types of changes
Description
Resolves: #575.
I added an option
content.markdown.tocDepth, by which users can define which heading are included in table of contents. For example, if it is set as3(default),h2andh3are included in table of contents.There are 3 special cases to handle:
First case is where
content.markdown.tocDepthis set as1. Currently,h1seems to be treated as the title of the article rather than content. So, I let the module log an info message.Second case is where
content.markdown.tocDepthis set as0. I handle this case in same way as above.Third case is where
content.markdown.tocDepthis set as more than6. Since deepest heading tag ish6, I let the module logs an message.By the way, the reason why I don't design the option as originally described in the issue is that writing every tag names looks redundant to me.
Checklist: