-
Notifications
You must be signed in to change notification settings - Fork 0
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
feature: Table of Contents #202
base: main
Are you sure you want to change the base?
Conversation
- Adds unique html id slugs to heading elements. - Extracts these headings and turns them into a table of contents with links to the headings.
@@ -0,0 +1,18 @@ | |||
import GithubSlugger from 'github-slugger'; |
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.
Placing this script and export the resetHtmlIdSlugger
in the astro
file caused the compiler not to be able to find slugger
. Extracting it to this file solves that issue. But the new problem is that now this script isn't really scoped to the provider anymore.
May need to use a different mechanism, like https://docs.astro.build/en/recipes/sharing-state/ ?
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.
Or maybe we could use an actual context
with this library: https://withastro-utils.github.io/docs/guides/context/
slugger.reset(); | ||
}; | ||
|
||
export const htmlIdSlug = ({ id, html }: { id?: string; html: string }) => { |
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.
should add test coverage for these methods
Implementation is blocked as the
Help wanted: can we render the blocks using a different method? Or should we abandon this feature? Update: resolving this with |
However, this problem remains: ``` [ERROR] [vite] x Build failed in 1.25s [commonjs--resolver] [plugin vite:resolve] Cannot bundle Node.js built-in "node:path" imported from "node_modules/astro/dist/core/config/schema.js". Consider disabling ssr.noExternal or remove the built-in dependency. ```
Changes
Result:
Associated issue
N/A
How to test
Checklist