Skip to content

Add links to top-level sidebar categories #143

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

Merged
merged 2 commits into from
Mar 18, 2025

Conversation

ptgott
Copy link
Contributor

@ptgott ptgott commented Mar 10, 2025

Contributes to #87

Top-level sidebar categories do not have links, meaning that when a user clicks a sidebar category, it expands, but does not take the user to a category index page as they might expect. Category index pages are listed as regular pages among other regular pages (another change will handle the redundant menu page sidebar listings).

This change edits the code that converts the config.json configuration file into a Docusaurus navigation config. It adds a Docusaurus link to each top-level navigation category based on the root path segment shared by all slugs within the category.

Copy link

github-actions bot commented Mar 10, 2025

Amplify deployment status

Branch Commit Job ID Status Preview Updated (UTC)
paul.gottschling/287-config-fix 2ad40d7 9 ✅SUCCEED paul-gottschling-287-config-fix 2025-03-18 16:28:47

@ptgott
Copy link
Contributor Author

ptgott commented Mar 10, 2025

Reviewer note: eventually we can convert config.json files in gravitational/teleport to use the Docusaurus format permanently and not need to do all this. I have to work on a way to support both formats first, though.

@ptgott ptgott requested a review from avatus March 10, 2025 12:51
Copy link

@avatus avatus left a comment

Choose a reason for hiding this comment

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

Without having too much context here, it looks fine. however, there is that big warning about something wrong with the regex. could you check it out before merginig.

Comment on lines 386 to 398
if (category.entries.some((e) => e.slug.match(categoryDirPattern)[2] == "")) {
return "index";
}
Copy link

Choose a reason for hiding this comment

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

this this index [2] guaranteed to exist?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

My impression was that the caller would always supply a valid slug, but I should prevent bad inputs anyway—I've added better exception handling and some tests in 2ad40d7

ptgott added 2 commits March 18, 2025 11:37
Contributes to #87

Top-level sidebar categories do not have links, meaning that when a user
clicks a sidebar category, it expands, but does not take the user to a
category index page as they might expect. Category index pages are
listed as regular pages among other regular pages (another change will
handle the redundant menu page sidebar listings).

This change edits the code that converts the `config.json` configuration
file into a Docusaurus navigation config. It adds a Docusaurus `link` to
each top-level navigation category based on the root path segment shared
by all slugs within the category.
- Remove unnecessary double negation.
- Add an escape character to `categoryDirPattern`
- Handle invalid entry slugs and add tests for invalid `getIndexPageID`
  cases
@ptgott ptgott force-pushed the paul.gottschling/287-config-fix branch from d1fd7e8 to 2ad40d7 Compare March 18, 2025 16:13
@ptgott ptgott merged commit c87dfac into main Mar 18, 2025
5 checks passed
@ptgott ptgott deleted the paul.gottschling/287-config-fix branch March 18, 2025 17:06
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.

2 participants