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

fix: automated DocsButton #1188

Merged
merged 21 commits into from
Jan 20, 2023
Merged

fix: automated DocsButton #1188

merged 21 commits into from
Jan 20, 2023

Conversation

akshatnema
Copy link
Member

Description
This PR consists of automating the DocsButton component for all the Doc pages. The Up Next and Go Back Buttons are automated according to the order of the pages given in the Doc Tree.

Related issue(s)
Fixes #1000

Signed-off-by: akshatnema <20bcs022@iiitdmj.ac.in>
@netlify
Copy link

netlify bot commented Dec 23, 2022

Deploy Preview for asyncapi-website ready!

Name Link
🔨 Latest commit fd00679
🔍 Latest deploy log https://app.netlify.com/sites/asyncapi-website/deploys/63ca646e7a531a0008499d41
😎 Deploy Preview https://deploy-preview-1188--asyncapi-website.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@github-actions
Copy link

github-actions bot commented Dec 23, 2022

⚡️ Lighthouse report for the changes in this PR:

Category Score
🔴 Performance 34
🟠 Accessibility 88
🟢 Best practices 100
🟢 SEO 100
🔴 PWA 30

Lighthouse ran on https://deploy-preview-1188--asyncapi-website.netlify.app/

akshatnema and others added 2 commits December 23, 2022 17:32
Signed-off-by: akshatnema <20bcs022@iiitdmj.ac.in>
@akshatnema
Copy link
Member Author

@alequetzalli Functionality implemented!! It is not as effective as manual insertion right now, but it will be improved as we need this improvement quite urgently. I have removed the manual insertion of components in the pages so far. I'll like to have your review first as Lukasz is on vacation right now.

@akshatnema
Copy link
Member Author

@magicmatatjahu @derberg @alequetzalli Kindly look into the implementation and preview of this PR and review it. Till now, I found this to be a quick and effective solution to automate these buttons according to DocTree. Kindly suggest or give your feedback on the implementation made.

Copy link
Member

@derberg derberg left a comment

Choose a reason for hiding this comment

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

as we need this only for docs layout, why you added this new code to Layout.js?

components/layout/Layout.js Outdated Show resolved Hide resolved
const allDocPosts = posts.filter(p => p.slug.startsWith('/docs/'))
const treePosts = buildNavTree(allDocPosts)
let structuredPosts = []
const convertDocPosts = (docObject) => {
Copy link
Member

Choose a reason for hiding this comment

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

for future us 😄 , please add a comment what the purpose of this function is, why the conversion is needed and what is converted. I don't think you are converting anything, you are rather generating a flat list of all docs 🤔

Copy link
Member Author

Choose a reason for hiding this comment

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

Sure 👍

@akshatnema
Copy link
Member Author

as we need this only for docs layout, why you added this new code to Layout.js?

This is because DocsLayout is called after the doc post route has been requested. It contains a prop for each doc post that has been requested by the user. This means that for every render of a doc, the DocsLayout.js will work accordingly, whereas, in Layout.js Component, the logic has been used for all the doc posts at once. So, it is easier to work on the list of Doc Posts for once and add some fields accordingly.

Co-authored-by: Lukasz Gornicki <lpgornicki@gmail.com>
Copy link
Member

@derberg derberg left a comment

Choose a reason for hiding this comment

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

lgtm, please just add as many comments as possible 🙏🏼

things like index-2>=0 or index+1<countDocPages scare the hell out of me when I think that sometime I will have to go there and make some adjustments 😆 and will end up needing to debug every single line 😄

akshatnema and others added 2 commits January 12, 2023 13:58
Signed-off-by: akshatnema <20bcs022@iiitdmj.ac.in>
@akshatnema
Copy link
Member Author

@derberg Comments are added to the changes. You can now review the implementation and logic behind the buttons.

Copy link
Member

@derberg derberg left a comment

Choose a reason for hiding this comment

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

@akshatnema thanks ❤️

one final question, sorry. Wouldn't it be better if this is all calculated in https://github.com/asyncapi/website/blob/master/scripts/build-post-list.js

@akshatnema
Copy link
Member Author

one final question, sorry. Wouldn't it be better if this is all calculated in master/scripts/build-post-list.js

Yeah, I have a plan of doing that in building the posts list, but right now I couldn't find the logic. Since, we need something right now, I build this solution in frontend 😅.

Copy link
Member

derberg commented Jan 16, 2023

So you mean that once we merge, you will work on followup PR?

I'm ok to accept it. @magicmatatjahu ?

@akshatnema
Copy link
Member Author

So you mean that once we merge, you will work on followup PR?

Yeah, because I need to do some hit and trials while creating and implementing the logic. I'll probably have to change the processing of posts list little bit to add these fields during the build time.

@quetzalliwrites
Copy link
Member

@alequetzalli Functionality implemented!! It is not as effective as manual insertion right now, but it will be improved as we need this improvement quite urgently. I have removed the manual insertion of components in the pages so far. I'll like to have your review first as Lukasz is on vacation right now.

Heyo, @akshatnema ! this is so exciting! ✨✨✨✨✨

I was on vacation and just got back. ✌🏽

@akshatnema
Copy link
Member Author

@alequetzalli Done with removing buttons in the Welcome page.

Copy link
Member

@quetzalliwrites quetzalliwrites left a comment

Choose a reason for hiding this comment

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

NOW FOR REAL 😄✨✨✨✨✨✨

@akshatnema
Copy link
Member Author

@derberg your review is needed for this PR.

@derberg
Copy link
Member

derberg commented Jan 18, 2023

just please create followup issue for the implementation improvement

Copy link
Member

@magicmatatjahu magicmatatjahu left a comment

Choose a reason for hiding this comment

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

You try to write such a logic inside Layout component and it should be written on building phase (in one of scripts) - atm every page on building phase and runtime is affected and we process unnecessary operations. In other words, please move logic to the scripts and add new metadata to the pages nodes.

@akshatnema
Copy link
Member Author

akshatnema commented Jan 18, 2023

In other words, please move logic to the scripts and add new metadata to the pages nodes.

Ok. That is my plan for the next follow up PR and I completely understand that current implementation will increase the run time of the website while rendering different pages. If you want the logic to be written in scripts folder only, you probably have to wait for some time as it requires some changes in the building of posts and the addition of some metadata nodes in docs. Also, as specified by @alequetzalli in this PR, we do need to figure out a way to add rootSection and Section names inside buttons so that a reader can identify properly which page the button is pointing to. But if you need this automation to be added quite urgently, I think you can go with this right now because it isn't increasing the runtime of the website too much. What's your opinion? @magicmatatjahu

@magicmatatjahu
Copy link
Member

@akshatnema If we were to have a release by Friday then I would accept it and have no problem, but due to the fact that the website code (overall) looks terrible and is becoming less and less readable (plus we don't have releases and we have a lot of time) then I would prefer it to be done in this PR.

If other codeowners are in favour of such a code push, I can accept it, but let them rethink my thoughts above.

@derberg
Copy link
Member

derberg commented Jan 18, 2023

@magicmatatjahu I shared my feedback here already #1188 (comment). @akshatnema is aware of the issue that code is in a wrong place, but this is a quick fix to address missing buttons in generator documentation that was added recently.

this is a maintainer contribution, not a random contributor that just came for one contribution and throw code on our backs, but maintainer that will create a followup issue to improve the code.

So yeah, I trust we will soon get a follow up cleanup

@akshatnema
Copy link
Member Author

@derberg your review needed!!

@quetzalliwrites
Copy link
Member

@derberg your review needed!!

YEAH LUKASZ, GET OVER HERE STAT!!

Copy link
Member

@derberg derberg left a comment

Choose a reason for hiding this comment

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

go go go
no need to wait for me if @alequetzalli and @magicmatatjahu already gave a green light

@akshatnema
Copy link
Member Author

/rtm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/docs Specify what technical area given issue relates to. Its goal is to ease filtering good first issues. 🐞 docs bug ready-to-merge
Projects
Status: Community PR under Review 🧐
Development

Successfully merging this pull request may close these issues.

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