fix(publish): expose entry public paths to publish filters - #297
Open
EuanTop wants to merge 3 commits into
Open
Conversation
There was a problem hiding this comment.
Pull request overview
This PR extends the publish filter context so publish.html handlers can reliably access the public URL pathname (path) of the emitted page/artefact (especially important for entry/template routes where slug identifies the template document, not the per-entry public route).
Changes:
- Add
pathto the renderer output and thread it through thepublish.htmlfilter context (bake/live/preview/republish flows). - Update plugin SDK types and documentation to define the
slugvspathsemantics for entry routes. - Add regression coverage asserting
pathis present for both/and entry routes.
Reviewed changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/core/plugins/hookBus.ts | Updates inline docs for filter context extras. |
| src/core/plugin-sdk/types/hooks.ts | Introduces a shared PublishFilterContext including path for publish filters. |
| src/tests/server/publicRendering.test.ts | Ensures hookBus state is reset per test; asserts publish filter context includes path for /. |
| src/tests/server/cmsTemplateRoutes.test.ts | Adds regression test that entry route renders provide path (and keep template slug). |
| src/tests/architecture/publish-html-filter-context.test.ts | Updates test description to reflect path being part of the expected context contract. |
| server/publish/republish.ts | Changes background republish to use a page permalink-derived synthetic URL. |
| server/publish/publishedHtmlPipeline.ts | Passes path into the publish.html filter context extras. |
| server/publish/publicRenderer.ts | Makes url mandatory in render contexts and reports path via url.pathname on renderer output. |
| server/plugins/protocol/messages.ts | Updates protocol docs for filter context fields. |
| server/handlers/cms/data/preview.ts | Adds path to preview renderer output fed into the shared publish pipeline. |
| docs/features/publisher.md | Documents publish.html filters receiving { siteId, pageId, slug, path }. |
| docs/features/plugin-system.md | Adds canonical URL example using path and documents slug vs path semantics. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 15 out of 15 changed files in this pull request and generated no new comments.
Comments suppressed due to low confidence (1)
src/tests/architecture/publish-html-filter-context.test.ts:7
- The header comment overstates what this architecture gate enforces. The test only checks that
applyFilter('publish.html', ...)is called with a third argument, not that the context contains specific keys likepath. Reword the comment to match the actual guarantee (presence of a context argument), while still noting that handlers commonly destructure{ siteId, pageId, slug, path }.
* This ensures that plugin filter handlers for `publish.html` always receive
* `{ siteId, pageId, slug, path }` in their context — without this, plugins that
* destructure those fields would silently receive `undefined`.
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.
Summary
publish.htmlruntime context and shared publish filter SDK contextslugas the rendered page or template document identitypathfrom the same route URL used by live rendering, static baking, preview, and background republishFor entry routes,
slugidentifies the shared entry template whilepathidentifies the concrete public artifact, for example/posts/hello-world.This allows SEO plugins to generate per-entry canonical and Open Graph URLs
without changing the existing template identity semantics.
Closes #225.
Verification
bun run buildbun testbun run lintChecklist