Skip to content

Fix API blueprint route for modular page templates#1

Open
robertbak wants to merge 1 commit into
getgrav:developfrom
robertbak:patch-1
Open

Fix API blueprint route for modular page templates#1
robertbak wants to merge 1 commit into
getgrav:developfrom
robertbak:patch-1

Conversation

@robertbak
Copy link
Copy Markdown

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.

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.
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