fix: prerender optional parameters as empty when entries contains '*'#11178
Merged
benmccann merged 13 commits intosveltejs:version-2from Dec 12, 2023
Merged
Conversation
🦋 Changeset detectedLatest commit: 37cfe14 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
benmccann
reviewed
Dec 3, 2023
benmccann
reviewed
Dec 3, 2023
Member
|
Thanks for this! The description of I feel that creating a whole new test project is a bit overkill. It'd probably be better to refactor out a method that can be unit tested or add an optional route to an existing test project |
Contributor
Author
|
Will do! |
Co-authored-by: Ben McCann <322311+benmccann@users.noreply.github.com>
Co-authored-by: Ben McCann <322311+benmccann@users.noreply.github.com>
…ot' into 11133-crawl-optional-param-at-root
benmccann
reviewed
Dec 12, 2023
entries contains '*'
benmccann
approved these changes
Dec 12, 2023
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #11133
Currently, any routes with parameters are only prerendered if they are discovered through crawling, or export
entries.This makes sense for required parameters, since it's not possible to know which values they accept otherwise.
For optional parameters, we do know that not passing a value is valid. With this PR routes with optional parameters that are marked as prerenderable will be crawled with no value by default.
Examples:
/some-route/[[optionalParam]]/awill be crawled with/some-route/a/some-route/[[optionalParam]]/a/[[optionalParam2]]/bwill be crawled with/some-route/a/bA common situation where this causes frustration is on multi-langauge pages with a
[[lang]]parameter at the root. In that case/won't be crawled. It needs to be manually specified in the entries, which feels silly.Please don't delete this checklist! Before submitting the PR, please make sure you do the following:
Tests
pnpm testand lint the project withpnpm lintandpnpm checkChangesets
pnpm changesetand following the prompts. Changesets that add features should beminorand those that fix bugs should bepatch. Please prefix changeset messages withfeat:,fix:, orchore:.