the-programmers-hangout / website

🌳 TPH website
https://theprogrammershangout.com
MIT License
102 stars 67 forks source link

Add navigation buttons at the bottom of the page for related pages. #338

Closed sidtr0 closed 4 years ago

sidtr0 commented 4 years ago

At the bottom of certain pages, it could be easier to implement a navigation button which takes you to the next related document or the previous page. Example: the http-project guide. It seems unintuitive to open the nav bar to go to the next page so it would be super nice here.

veksen commented 4 years ago

Yes 100%.

What I'm thinking: Have the button navigate to either the next sibling (page), or the next directory.

veksen commented 4 years ago

Gatsby docs do it like this:

https://www.gatsbyjs.com/docs/quick-start/

image

veksen commented 4 years ago

I've prepared a simple design for it

image

https://www.figma.com/file/Yz2t51GRnlcPPRujlTj3ggLl/tph-sketch?node-id=2028%3A68

sidtr0 commented 4 years ago

I don’t know anything about React or Gatsby but here goes my idea: in the Markdown Frontmatter for each of the pages, we would add two new labels: project_label which would be the name of the project like “DIY HTTP Server” and page_number which would be a number. How I thought it would work is it would look for pages with the same label and add the links in an array which would be used to switch pages.

Let me know how this sounds and if it is possible.

dfireBird commented 4 years ago

@woojiahao has already implemented a similar paging system in his personal site! We can use that as reference.

The repo of the site.

Edit: Upon researching the source! If we have a way to sort the resources we get from the grahpql we can use the allFile.edges.next and allFile.edges.previous and also allMdx.edges.next and allMdx.edges.previous are available.

Edit-2: We can also try useTree function to identify the next item and previous item.

veksen commented 4 years ago

closed by #359