pablo-abc / svelte-markdown

Markdown parser to svelte components
MIT License
360 stars 50 forks source link

Best way to get a Table of Contents with this component? #29

Closed wozzashek closed 3 years ago

wozzashek commented 3 years ago

I like the simplicity of this component, and was wondering what would be the best way to generate a Table of Contents from the headings of the markdown?

As you are only using the Lexer, it means we can't do a marked.use and generate HTML purely from the headings. Could we add export let tokens to the component, so we can optionally access the tokens generated from a parent component?

Similar to this example: https://svelte.dev/examples#component-bindings

Once I have the array of tokens, I can quite easily build my own Table of Contents component, and provide the heading tokens to it.

wozzashek commented 3 years ago

Being addressed with pull request #30

pablo-abc commented 3 years ago

Hey, @wozzashek! If you add to the description of #30 something like "closes #29", it'll automatically link it to this issue and close it when #30 is merged. Here's some information about it if you're interested.

In this case I'm reopening this, since it's technically still an issue until your PR gets merged. For tracking purposes!