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

Rewrite navbar generation code from first principles #2547

Merged
merged 11 commits into from
May 16, 2024
Merged

Conversation

hadley
Copy link
Member

@hadley hadley commented May 15, 2024

@maelle I got tired of having a bunch of code copied from rmarkdown and then modified over the years. It was hard to understand the logic and challenging to make changes. So I've rewritten it from scratch. Along the way:

  • I documented the target field for links
  • I discovered that we were using depth to mean two different things (menu and path), causing search to fail pages deeper in the site
  • I updated the generated HTML to match latest BS5 recommendations (i.e. using <ul> and <li> instead of bare <div>s
  • I learned that BS5 definitely doesn't support submenus and now give a slighter better error message (instead of just generating HTML that looks weird)
  • I added some better errors if your navbar code is malformed

@hadley hadley requested a review from maelle May 15, 2024 13:43
github:
icon: fab fa-github fa-lg
href: https://github.com/r-lib/pkgdown
aria-label: github
aria-label: GitHub
Copy link
Member Author

Choose a reason for hiding this comment

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

Our label was a bit lazy before

Copy link

github-actions bot commented May 15, 2024

@jayhesselberth
Copy link
Collaborator

This looks good but the position of the search box is slightly different on the new site — is there a CSS rule that also needs updating?

Copy link
Collaborator

@maelle maelle left a comment

Choose a reason for hiding this comment

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

Nice!

  • should there be tests for the two other new errors?
  • is it worth re-running an HTML validator?
  • should there a "gallery" of some YAML configurations for the navbar in the tests?

R/navbar-menu.R Outdated Show resolved Hide resolved
@hadley
Copy link
Member Author

hadley commented May 16, 2024

  • Yes, done!
  • Already did it 😄
  • I think the existing tests are ok since the structure is now pretty simple given that we are clear are not about supporting submenus. But I'll add a comment to explain a bit more.

@hadley hadley merged commit 24f7993 into main May 16, 2024
14 checks passed
@hadley hadley deleted the navbar-rewrite branch May 16, 2024 15:23
@hadley hadley mentioned this pull request May 17, 2024
SebKrantz pushed a commit to SebKrantz/pkgdown that referenced this pull request Jun 1, 2024
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.

3 participants