-
Notifications
You must be signed in to change notification settings - Fork 9
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
Feat/display collection in nav bar #362
Conversation
b861d0a
to
8672b5c
Compare
This commit refactors the `EditNavBar` component to use react-query to retrieve nav bar data from the backend. This includes moving the API call into a callback function defined in the api.js file.
Previously, we used the GET /v1/sites/:siteName/collections endpoint to retrieve data on collections. However, this endpoint is outdated - it retrieves data on collections based on the _config.yml file. This won't work with our Jekyll 4.2 repos going forward, since information on collection data will be stored in each individual collection directory. This commit updates the GET request to retrieve from the GET v1/sites/:siteName/folders/all endpoint instead. This endpoint returns not just information on what collections exist in the repo, but also returns information on the order of pages within each collection, which we need for rendering the collection page dropdown in the NavBar template.
This commit adds a util function which parses the folder order for each folder/collection and returns them in an array of deslugified elements in accordance with the nav bar dropdown requirements.
This commit updates the EditNavBar layout with a new folderDropdowns state variable, which is passed to the TemplateNavBar as the collectionsInfo prop. This gives the TemplateNavBar component the necessary information to render the dropdown items for collections/folders
9b95f7d
to
b25e6a1
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
} | ||
|
||
if (pathArr.length === 2 && pathArr[0] !== acc[acc.length - 1]) { | ||
acc.push(deslugifyDirectory(pathArr[0])) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should check if deslugifyDirectory(pathArr[0])
already exists or use Set()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch, fixed with 5a34a49
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
Note: this PR is to be reviewed with PR #117 on the backend
Overview
This PR builds on #358, and makes modifications to the
EditNavBar
layout so that it stores afoldersDropdown
state variable, which it passes to theTemplateNavBar
component so that the dropdown elements for a collections/folder entry in the nav bar are rendered.Before
After