good-first-issue-finder icon indicating copy to clipboard operation
good-first-issue-finder copied to clipboard

Add Table Of Contents to docs page

Open Cahllagerfeld opened this issue 3 years ago • 16 comments

Description

We should display the headings on the page in the right column of the layout, to make it easier for users to navigate

Screenshots

No response

Additional information

No response

Cahllagerfeld avatar Sep 21 '22 13:09 Cahllagerfeld

Could you explain it again where exactly would the headings be?

ChinmayMhatre avatar Sep 30 '22 07:09 ChinmayMhatre

Hey @Cahllagerfeld could you elaborate on this . I could work on this issue.

ChinmayMhatre avatar Oct 04 '22 10:10 ChinmayMhatre

Oh sorry for the late reply:

In the Docs-Layout we're currently having a third column that isn't used. Its planned to display a table of contents of the current page inside it, similar to tailwind grafik

Features:

  • pick the headings from the current page and display them in a hierarchical order
  • when clicking one of the headings in the table of contents, the page should jump to that heading
  • When scrolling through headings, the active one should be highlighted

Cahllagerfeld avatar Oct 04 '22 12:10 Cahllagerfeld

Got it ! I'd like to work on this.

ChinmayMhatre avatar Oct 04 '22 13:10 ChinmayMhatre

Could you give me a overview on how I could get this started?

ChinmayMhatre avatar Oct 04 '22 13:10 ChinmayMhatre

I don't know myself in detail, I didn't have a look in depth into it, but my suggestion would be:

  1. Get Headings from Page and write a function that sorts them hierarchically
  2. turn the headings in the toc to links => the headers are already anchors that can be targeted
  3. For the scrolling thing, you may need a scroll-listener calculating and comparing the Y-Offset of the page and the headings 🤔

I'm not sure if this is working though, its just my assumption

Cahllagerfeld avatar Oct 04 '22 13:10 Cahllagerfeld

Alright I'll look into it.

ChinmayMhatre avatar Oct 04 '22 14:10 ChinmayMhatre

Hey @Cahllagerfeld , I am working on this. but I can't seem to figure out how to get the headings from the markdown file. I tried using the vite plugin for markdown but I can't seem to be able to import the markdown file in the layout.svelte file.

ChinmayMhatre avatar Oct 07 '22 07:10 ChinmayMhatre

https://github.com/hmsk/vite-plugin-markdown this is the plugin. But when I go to add the configs it throws and error. And with out the plugin I could'nt even import the md file.

ChinmayMhatre avatar Oct 07 '22 07:10 ChinmayMhatre

I think you can just use a QuerySelector to grab the headlines from the content-block 🤔

Cahllagerfeld avatar Oct 07 '22 10:10 Cahllagerfeld

wouldn't I need a div to query the id? What do I query to get the headlines?

ChinmayMhatre avatar Oct 07 '22 10:10 ChinmayMhatre

I thing you would run the query selector on the div mdsvex renders the content in, with h2, h3, h4, h5, h6 selector 🤔

Cahllagerfeld avatar Oct 07 '22 12:10 Cahllagerfeld

Wow! I skipped the most logically and simple solution, lol. Works now, Thanks!

ChinmayMhatre avatar Oct 10 '22 05:10 ChinmayMhatre

Hey, is this issue being already resolved??? if not do let me know I would love to work on the issue. I've got the enough insights about the issue and solution approach. Please assign it to me.

saaagarsingh avatar Feb 22 '23 05:02 saaagarsingh

Thank you @Cahllagerfeld I'll start working on it. I had one question where can I find the page which need to be modified??

saaagarsingh avatar Feb 23 '23 07:02 saaagarsingh