stasis-generator icon indicating copy to clipboard operation
stasis-generator copied to clipboard

Exposing tree of page headers

Open f0x52 opened this issue 5 years ago • 2 comments

Hey, for my site I'd like to be able to dynamically generate a list of the current page's sections. Something like Wikipedia's Content block at the start of a page. For this I need to access an array of all header markdown objects from handlebars, and they all need to get an id to use in the anchor tag.

Im not sure what the best place would be to hack this in, any ideas?

f0x52 avatar Mar 03 '19 20:03 f0x52

Hm.. interesting. The compiler uses unified as a text parsing engine. You could checkout if there is a plugin that extracts this data. You could then attach it to the Edge as a “sections” array.

Gioni06 avatar Mar 04 '19 06:03 Gioni06

Maybe a combination of those plugins would do the trick.

https://www.npmjs.com/package/rehype-autolink-headings https://www.npmjs.com/package/rehype-slug https://www.npmjs.com/package/remark-outer-tochttps://www.npmjs.com/package/remark-outer-toc

Gioni06 avatar Mar 04 '19 07:03 Gioni06