website: [Docs Bug 🐞 report]: Automate the Prev and UpNext buttons for Docs

Describe the bug you found in AsyncAPI Docs.

Every time we update the docs or add a new doc inside documentation, we have to add Up Next and Back buttons for each page or update them to the latest. Make the buttons in such a way that it automates itself to point to next and back pages sequentially according to the Doc tree.

Remove the DocsButton component from each Doc page and add the component to the DocsLayout, and implement it according to the index of the map function used.

Attach any resources that can help us understand the issue.

image

Use the weight parameter to serialize the docs and then provide the routes to the buttons for each page.

Code of Conduct

  • I agree to follow this project’s Code of Conduct

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 1
  • Comments: 31 (31 by maintainers)

Most upvoted comments

This appears to be a common question in the internet πŸ˜„ … lots of blog posts and StackOverflow threads mention it

Perhaps this can help?

The iteration order for objects follows a certain set of rules since ES2015, but it does not (always) follow the insertion order. Source: https://stackoverflow.com/questions/5525795/does-javascript-guarantee-object-property-order

image

@derberg @alequetzalli what if we make an object of posts copied/calculated using the DocsNav tree object, add prev and next fields using previous and next elements respectively, and then pass it as post to the component?

hey folks, IMHO we need 2 mechanisms:

  • one proposed by @akshatnema based on weight. So automatically detect what is next, and what previous
  • but ☝🏼 should be β€œfallback” and main mechanism should be a front matter, that docs author can add to markdown file, and specify next and previous that is actually different than weights

wdyt?

@manavdesai27 @alequetzalli I have updated the issue description according to the need. Kindly look into it.

But tbh, it’s not a good way right now. Because if you try to access the page in development mode, it broke down giving a 404 page as redirection is not set there.

well, I didn’t say it must stay like this πŸ˜„ redirects were done for people linking to AsyncAPI website from outside. I just explained why it works πŸ˜„ this link should definitely be fixed in the markdown file.

I create another issue for these small changes and give it a hacktoberfest tag.

@manavdesai27 is super motivated to do both issue, so let us leave hacktoberfest tag. There are still 2 weeks to go.

@manavdesai27 okay you take this one.

Hey @akshatnema this is actually 3 different bugs listed under one issue… Can you at least create 3 tasks in this same issue to help make it more digestible? πŸ˜œπŸ™ŒπŸ½ I also recommend thinking of a new title that better encapsulates the 3 items you discuss. πŸ‘πŸ½πŸ‘πŸ½

As for adding Prev/Next buttons on each content bucket /Overview pages, I think that’s a great idea πŸ’‘ . I am ok with a contributor adding them and I assume that Lukasz prob is too. (altho yes, I should never assume πŸ˜‚)