Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Table Of Contents to docs page #226

Open
Cahllagerfeld opened this issue Sep 21, 2022 · 16 comments
Open

Add Table Of Contents to docs page #226

Cahllagerfeld opened this issue Sep 21, 2022 · 16 comments

Comments

@Cahllagerfeld
Copy link
Member

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

@ChinmayMhatre
Copy link
Member

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

@ChinmayMhatre
Copy link
Member

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

@Cahllagerfeld
Copy link
Member Author

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

@ChinmayMhatre
Copy link
Member

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

@ChinmayMhatre
Copy link
Member

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

@Cahllagerfeld
Copy link
Member Author

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

@ChinmayMhatre
Copy link
Member

Alright I'll look into it.

@ChinmayMhatre
Copy link
Member

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
Copy link
Member

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.

@Cahllagerfeld
Copy link
Member Author

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

@ChinmayMhatre
Copy link
Member

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

@Cahllagerfeld
Copy link
Member Author

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

@ChinmayMhatre
Copy link
Member

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

@ChinmayMhatre ChinmayMhatre removed their assignment Jan 9, 2023
@saaagarsingh
Copy link

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
Copy link

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

@Cahllagerfeld
Copy link
Member Author

I think it's the layout file in the docs route

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants