janniks / vue-notion

A fast Vue renderer for Notion pages
https://vue-notion.now.sh
Other
883 stars 65 forks source link

Maybe consider adding Table of Contents support #130

Open brachkow opened 1 year ago

brachkow commented 1 year ago

Hi! We are migrating our big project from vue3-notion to vue-notion, and we stumbled upon the fact that the table of contents is not displayed.

I know that in README table of contents marked as not planned, but it is clearly implementable (see https://github.com/NotionX/react-notion-x that is recommended by OG react-notion) so maybe you consider adding it?

janniks commented 1 year ago

Sure, đź‘Ť I'll look into it in the next days

janniks commented 1 year ago

Sorry that I still haven’t gotten to this yet

brachkow commented 11 months ago

@janniks you can see how I implemented table of contents in our fork — https://github.com/tough-dev-school/vue-notion/blob/main/components/NotionTableOfContents.vue

Code is messy, but I'm sure that you will get an idea.

Keep in mind important thing that I discovered: blockMap order ≠ page block order. Page block order is one which affects order of blocks on page. Using blockMap for that may lead to broken order in Table of Contents.

FYI @zernonia your fork has this bug too: https://github.com/zernonia/vue3-notion/blob/44e0d470530b7de8b3909b3b5081c7aae1d93b99/src/blocks/table-of-contents.vue#L18. And btw, thanks a lot for clever ideas on porting this library.