fantinel.dev icon indicating copy to clipboard operation
fantinel.dev copied to clipboard

Table of Contents

Open matfantinel opened this issue 2 years ago • 2 comments

I'd like there to be a table of contents on some blog posts, mainly the bigger guides.

Could be done with IntersectionObserver maybe, but I'm not sure that would be flawless as that API has its quirks. Might be worth having a look at https://github.com/metonym/svelte-intersection-observer

matfantinel avatar Oct 13 '21 21:10 matfantinel

You may try rehype-toc. By the way, I'm a frontend newbie, and I built my first blog by learning from your blog. Actually, I copy some code from you like the themes. Hope you don't mind. I will add a link to your repo in my readme. Thanks!

KaminariOS avatar Mar 02 '22 07:03 KaminariOS

@KaminariOS I've had a look at rehype-toc and it should be good enough to create the headers I need, yes. However I want the ToC to be a bit more dynamic (like scroll along with the content and highlight the current chapter) and didn't have much luck with that yet.

Thank you for the kind words! Feel free to use any part of the code. That's why I made it open! I just ask that you make yours open as well so it may also help someone in the future 😄

matfantinel avatar Mar 02 '22 10:03 matfantinel

Just saw this, might be perfect for this project!

https://github.com/janosh/svelte-toc

matfantinel avatar Nov 21 '22 17:11 matfantinel