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

Reference dynamic route variables in Legacy Collection examples in v5.mdx #9555

Merged
merged 3 commits into from
Oct 7, 2024

Conversation

cdvillard
Copy link

Description (required)

As dynamic routes are also allowed to use variables, it's easy to overlook when following directions specific to file content. This PR explicitly calls out changing any references to slug used in dynamic routes to id.

Related issues & labels (optional)

  • Closes #
  • Suggested label: improve documentation, hacktoberfest-accepted

If you have additional questions, I'm also cdvillard in the Discord server.

….mdx

As dynamic routes are also allowed to use variables, it's easy to overlook when following directions specific to file content. This PR explicitly calls out changing any references to `slug` used in dynamic routes to `id`.
Copy link

netlify bot commented Oct 4, 2024

Deploy Preview for astro-docs-2 ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit a9646b7
🔍 Latest deploy log https://app.netlify.com/sites/astro-docs-2/deploys/6703c297cdfe710008983c61
😎 Deploy Preview https://deploy-preview-9555--astro-docs-2.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 configuration.

Copy link
Member

@sarah11918 sarah11918 left a comment

Choose a reason for hiding this comment

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

Thanks for this @cdvillard , it's a great catch!

I'm not sure this is the solution, though, because people wouldn't normally be writing file names in Astro code. You made me think hard about whether there's a diff it makes sense to show, and the only thing I can come up with is using our <FileTree> component to show files!

I'll ask @hippotastic if he's ever tried to render a file diff somehow! 😅

Otherwise, then I think probably not showing a diff for the file name, but rather just mentioning it in the text above, maybe like...

Change references from slug to id. Content layer collections do not have a slug field. Instead, all updated collections will have an id. You may also need to update your file name to match an updated getStaticPaths() parameter:

@hippotastic
Copy link
Contributor

Hehe, interesting idea! :)

We're currently not able to show a before/after diff of the file name inside an open file tab.

I really like the FileTree idea, but unfortunately the component doesn't seem to support diffs either.

I therefore think we'll need to resort to regular text to explain the necessary changes for now as you suggested.

@cdvillard
Copy link
Author

@sarah11918 Took your recommendation into account, though I also renamed the file as well to reflect the change as well. Would that work, instead of worry about illustrating it via a diff?

Copy link
Member

@sarah11918 sarah11918 left a comment

Choose a reason for hiding this comment

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

I think this works great now. Thank you @cdvillard and welcome to Team Docs! 🥳

@sarah11918 sarah11918 added improve documentation Enhance existing documentation (e.g. add an example, improve description) hacktoberfest-accepted Mark a PR as accepted to contribute towards Hacktoberfest code snippet update Updates a code sample: typo, outdated code etc. labels Oct 7, 2024
@sarah11918 sarah11918 merged commit 3942cdf into withastro:5.0.0-beta Oct 7, 2024
4 of 5 checks passed
@ArmandPhilippot ArmandPhilippot mentioned this pull request Oct 7, 2024
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
code snippet update Updates a code sample: typo, outdated code etc. hacktoberfest-accepted Mark a PR as accepted to contribute towards Hacktoberfest improve documentation Enhance existing documentation (e.g. add an example, improve description)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants