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

Improve get all trees #174

Merged
merged 10 commits into from
Jul 11, 2024
Merged

Improve get all trees #174

merged 10 commits into from
Jul 11, 2024

Conversation

cdedreuille
Copy link
Collaborator

@cdedreuille cdedreuille commented Jul 11, 2024

We used to get the tree from getDocsTreeFromPath to get the tree but the slug returned included the actual version. In this PR I'm improving the way we get the tree with the right slugs, reducing the need to modify it after in multiple places. The new structure is as followed:

getDocsTreeFromPath(): RawTreeProps[]

This function will get the raw data of a tree at a specific path. This function doesn't include slug anymore.

getAllTrees(): TreeProps[]

This new function will return the list of all trees with the right slug. The latest version will not get the version in the url for example. I also improved the way we transform the slug to make sure it works even if there's a version in the name of the page.

To get the tree for a specific version, just call this function and look for the tree for a specific version like this:

const listofTrees = getAllTrees();
const findTree = listofTrees.find((tree) => tree.name === version.id);
const tree = findTree?.children;

This PR also fixes some slugs that were generated by mistake in docs like versions or empty slugs.

Copy link

vercel bot commented Jul 11, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
web ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 11, 2024 2:12pm
web-addon-catalog ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 11, 2024 2:12pm
1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
web-tutorials ⬜️ Ignored (Inspect) Jul 11, 2024 2:12pm

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.

1 participant