fantinel.dev
fantinel.dev copied to clipboard
Table of Contents
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
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 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 😄
Just saw this, might be perfect for this project!
https://github.com/janosh/svelte-toc