Fix API blueprint route for modular page templates#1
Open
robertbak wants to merge 1 commit into
Open
Conversation
The blueprint endpoint previously used `/blueprints/pages/{template}`, which in FastRoute means `template` matches only a single path segment and stops at `/`. That worked for standard templates like `default` or `blog`, but failed for modular templates such as `modular/_hero_slider`, because the router interpreted the slash as a separator and never dispatched the request to `pageBlueprint()`.
Changing the route to `/blueprints/pages/{template:.+}` gives the `template` parameter an explicit regex. In FastRoute, `:.+` means “match one or more of any character,” including additional path segments separated by `/`. That allows the full template name `modular/_hero_slider` to be captured as a single parameter value, so the existing blueprint loader can resolve `theme://blueprints/modular/_hero_slider.yaml` correctly.
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.
The blueprint endpoint previously used
/blueprints/pages/{template}, which in FastRoute meanstemplatematches only a single path segment and stops at/. That worked for standard templates likedefaultorblog, but failed for modular templates such asmodular/_hero_slider, because the router interpreted the slash as a separator and never dispatched the request topageBlueprint().Changing the route to
/blueprints/pages/{template:.+}gives thetemplateparameter an explicit regex. In FastRoute,:.+means “match one or more of any character,” including additional path segments separated by/. That allows the full template namemodular/_hero_sliderto be captured as a single parameter value, so the existing blueprint loader can resolvetheme://blueprints/modular/_hero_slider.yamlcorrectly.