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

Sidebar table of contents #93

Closed
3 tasks
rufuspollock opened this issue Mar 22, 2022 · 12 comments
Closed
3 tasks

Sidebar table of contents #93

rufuspollock opened this issue Mar 22, 2022 · 12 comments
Assignees
Labels
good first issue Good for newcomers Tech

Comments

@rufuspollock
Copy link
Member

rufuspollock commented Mar 22, 2022

Maybe only on certain pages (markdown pages or guide or ...)

Inspiration from eg. tailwindcss.com which has LHS table of contents for whole site and RHS for table of contents of current doc - https://tailwindcss.com/docs/installation

image

Acceptance

  • RHS table of contents for the current page
  • LHS table of contents for the entire site (pages and sub pages ...)
    • Bonus for making this fancy e.g. highlight which page, allow for custom stuff at top a la tailwind etc

Tasks

Notes

Note tailwindcss docs is on github so we can learn from them on code side https://github.com/tailwindlabs/tailwindcss.com/tree/master/src

@rufuspollock rufuspollock added the good first issue Good for newcomers label Mar 22, 2022
@AceTheCreator
Copy link

@rufuspollock I'll work on this

@rufuspollock
Copy link
Member Author

@AceTheCreator no, you can self-assign. This is probably easier than citation renderer - at least doing the RHS table of contents of the page.

@rufuspollock
Copy link
Member Author

@AceTheCreator how is it going?

@AceTheCreator
Copy link

@rufuspollock I'm almost done with it and I should raise a PR tomorrow.

I performed a logic to retrieve toc for every md and save it in a final JSON and then read JSON in the js and render React component

@rufuspollock
Copy link
Member Author

@AceTheCreator great - i'd start with the RHS table of contents which should be relatively easy I imagine - and do a PR with that and then a second one for the global ToC. Also could you share what research / inspiration you did - e.g. how do tailwind do it (their repo is public so you check ...)

@AceTheCreator
Copy link

@rufuspollock I need a clearer explanation of what the right LHS table of content should contain 🤔

@AceTheCreator
Copy link

@rufuspollock i noticed some of the links in some of the MD files has for example [web3](../../concepts/web3.md) which links to /concepts/web3.md instead of /concepts/web3

@rufuspollock
Copy link
Member Author

@AceTheCreator

@rufuspollock I need a clearer explanation of what the right LHS table of content should contain 🤔

Look at the screenshot in the description. There is a RHS table of contents which is the current page table of contents. I would have suggested that is the much easier thing to start with before moving onto the site table of contents. I'd also suggest doing some upfront analysis before coding to think this through a bit and research how, for example, tailwind are doing this. That way you have a rough plan of work - which i can review - before starting on the detailed coding. wdyt?

@rufuspollock i noticed some of the links in some of the MD files has for example web3 which links to /concepts/web3.md instead of /concepts/web3

That's correct and relates to how obsdian resolves links.

@AceTheCreator
Copy link

Look at the screenshot in the description. There is a RHS table of contents which is the current page table of contents. I would have suggested that is the much easier thing to start with before moving onto the site table of contents. I'd also suggest doing some upfront analysis before coding to think this through a bit and research how, for example, tailwind are doing this. That way you have a rough plan of work - which i can review - before starting on the detailed coding. wdyt?

@rufuspollock You're absolutely right!

@AceTheCreator
Copy link

AceTheCreator commented Apr 6, 2022

Issue Solution Summary

LHS toc summary

The inspiration for this solution was the Tailwindcss approach for their LHS toc. Based on my research they have an object that holds all the toc, each key in the object is the main title of the section in the toc which holds an array as a value(the value consist of an array of page link for that section) and a utility function exists called createPageList which IMO helps them generate the page for each link in the value of each section.

I was able to follow a similar approach with less code. Thanks to the content layer already in place I don't have to create a function that helps me create a page list. All I have to do was take advantage of the cotentlayer data and create an object that holds all the Toc. the breakdown can be found in #133 PR

RHS toc summary

All I did on this was to read all the markdown files in a specific path and on that, I created the toc for that and used it on the page. Then, I performed a logic to retrieve toc for every md and save it in a final Json, and then read the Json in the js and render a React component... more details can be found in this PR #134

@AceTheCreator
Copy link

@rufuspollock @khalilcodes I updated the PR by making it cleaner. Thanks, @rufuspollock for the feedback on my messy PR

@olayway olayway assigned olayway and unassigned AceTheCreator May 10, 2022
@olayway
Copy link
Contributor

olayway commented May 10, 2022

Moved to:

@olayway olayway closed this as completed May 10, 2022
Repository owner moved this from In Progress to Done in web3 May 10, 2022
This was referenced May 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers Tech
Projects
Status: Done
Development

No branches or pull requests

4 participants