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

feat: add table of contents for docs pages #308

Merged
merged 6 commits into from
Nov 29, 2024

Conversation

Nos43ratu
Copy link
Contributor

Problem: The current documentation pages, like Router Navigation, can be challenging to navigate due to their length and density of content.

Solution: Added a Table of Contents (ToC) to the right sidebar to enhance navigation.

Changes Made:

  1. Moved the DocsLayout right sidebar to be part of the document itself.
  2. Added logic to extract headings dynamically from the markup content.
  3. Created a Toc component to render the extracted headings.
  4. Applied the existing library color scheme to the Toc component for visual consistency
  5. Added heading-level padding to the Toc to clearly represent content structure

Screenshot 2024-11-26 at 13 11 27
Screenshot 2024-11-26 at 13 11 18

Copy link

vercel bot commented Nov 26, 2024

Someone is attempting to deploy a commit to the Tanstack Team on Vercel.

A member of the Team first needs to authorize it.

Copy link

netlify bot commented Nov 26, 2024

Deploy Preview for tanstack failed.

Name Link
🔨 Latest commit d99481a
🔍 Latest deploy log https://app.netlify.com/sites/tanstack/deploys/6748fbdbc89c760008721755

Copy link
Member

@SeanCassiere SeanCassiere left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Nos43ratu please resolve the conflicts

@Nos43ratu Nos43ratu force-pushed the add-table-of-contents branch from fbe92c6 to ad7a330 Compare November 27, 2024 09:45
@Nos43ratu
Copy link
Contributor Author

@SeanCassiere updated pr

Copy link
Member

@SeanCassiere SeanCassiere left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! @tannerlinsley any thoughts here?

@KevinVandy
Copy link
Member

I'm a bit concerned that there appears to be 3 scrollbars on that 2nd image, when 2 should be the max. But otherwise, I think this would be a welcome addition.

@Nos43ratu
Copy link
Contributor Author

@KevinVandy it can be fixed by making content margins smaller and moving toc out from right side
image
image
or smth like this(draft)
image

@Nos43ratu
Copy link
Contributor Author

@KevinVandy it can be fixed by making content margins smaller and moving toc out from right side image image or smth like this(draft) image

or making scroll inside of the toc invisible
for example shad ui toc

@KevinVandy
Copy link
Member

When a wide enough media query is triggered, that might be good. Otherwise probably needs to stay in one side bar on medium sized screens, and hidden on mobile

@SeanCassiere
Copy link
Member

@KevinVandy it can be fixed by making content margins smaller and moving toc out from right side image image or smth like this(draft) image

The draft looks better. Maybe just add a light border on the left and hide it on small screens.

@Nos43ratu Nos43ratu force-pushed the add-table-of-contents branch from ad7a330 to 477fff1 Compare November 28, 2024 00:16
@Nos43ratu
Copy link
Contributor Author

Moved toc from right side bar to the page. Saved initial page width. Made pr thiner by removing unnecessary changes.

This version can be reverted to use initial version

@SeanCassiere @KevinVandy @tannerlinsley

Screen.Recording.2024-11-28.at.05.09.59.mp4

Screenshot 2024-11-28 at 05 18 40
Screenshot 2024-11-28 at 05 18 59
Screenshot 2024-11-28 at 05 19 05

@SeanCassiere
Copy link
Member

On http://localhost:3000/router/latest/docs/framework/react/api/router there seems to be some content width issues.

image

@Nos43ratu Nos43ratu force-pushed the add-table-of-contents branch from 477fff1 to 41ec4d8 Compare November 28, 2024 09:16
@Nos43ratu
Copy link
Contributor Author

On http://localhost:3000/router/latest/docs/framework/react/api/router there seems to be some content width issues.

image

@SeanCassiere fixed
Screenshot 2024-11-28 at 14 17 46

@KevinVandy
Copy link
Member

KevinVandy commented Nov 28, 2024

@tannerlinsley This passes my qa from just looking at the table docs. I think it makes the docs a lot easier to navigate

image

Approving, but not merging until @tannerlinsley approves/merges

Copy link
Member

@SeanCassiere SeanCassiere left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These changes are great! I checked them out with the docs for Router, Query, and Form.

@tannerlinsley
Copy link
Collaborator

Fantastic! Approved!

@SeanCassiere SeanCassiere merged commit 6bfd2c8 into TanStack:main Nov 29, 2024
2 of 7 checks passed
@SeanCassiere SeanCassiere changed the title feat: Add table of contents feat: add table of contents for docs pages Nov 29, 2024
@SeanCassiere
Copy link
Member

@Nos43ratu thank you for your contribution 🎉

@Nos43ratu
Copy link
Contributor Author

Thanks guys 🙏

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

Successfully merging this pull request may close these issues.

4 participants