-
Notifications
You must be signed in to change notification settings - Fork 317
Add table of contents sidebar and linkable headers #3591
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
dbae925 to
b7f3566
Compare
astro/astro.config.mjs
Outdated
| import rehypeAutolinkHeadings from 'rehype-autolink-headings'; | ||
|
|
||
| const autolinkConfig = { | ||
| behavior: 'prepend', |
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.
Imho, this does not look good. All headers have an indentation that looks off. Unfortunately also the append looks not good as it is on the far right of the site.
Playing around with it, I think append could work. I would prefer that over prepand
|
I rebased, some test where failing for me locally, so I fixed that as well. For me the prepand option does not look good, see my comment above. |
rehype-autolink-headings requires heading IDs to already exist. Added rehype-slug to run first in the plugin chain to generate them.
Matches the old Gridsome behavior and avoids competing with the main left navigation.
Addresses PR feedback - prepend caused odd indentation on headers. Append places the # link after the heading text instead.
Moves the TOC logic (mobile collapsible + desktop sidebar) into a shared component used by both ArticleLayout and the events page template.
b7f3566 to
f942d81
Compare
|
Cool! |
|
Thanks for the suggestions and merge! |
Summary
Features
Table of Contents:
autotocfrontmatter field (opt-in, matching old behavior)Linkable Headers:
#symbol, styled to be unobtrusiveTechnical Changes
rehype-slugandrehype-autolink-headingspluginsTableOfContents.astrocomponentArticleLayout.astroand event pages to support TOCFixes #3569