docs: document rendering SEO panel data via getSeoMeta (#1518)#1900
docs: document rendering SEO panel data via getSeoMeta (#1518)#1900swissky wants to merge 2 commits into
Conversation
getSeoMeta/getContentSeo were undocumented outside the in-repo skill references, so templates that hand-roll meta tags silently bypass the whole SEO panel, including the noindex toggle. Adds a section to the querying guide with a full example and a caution about the footgun.
|
@emdash-cms/admin
@emdash-cms/auth
@emdash-cms/auth-atproto
@emdash-cms/blocks
@emdash-cms/cloudflare
@emdash-cms/contentful-to-portable-text
emdash
create-emdash
@emdash-cms/gutenberg-to-portable-text
@emdash-cms/plugin-cli
@emdash-cms/plugin-types
@emdash-cms/registry-client
@emdash-cms/registry-lexicons
@emdash-cms/sandbox-workerd
@emdash-cms/x402
@emdash-cms/plugin-ai-moderation
@emdash-cms/plugin-atproto
@emdash-cms/plugin-audit-log
@emdash-cms/plugin-color
@emdash-cms/plugin-embeds
@emdash-cms/plugin-field-kit
@emdash-cms/plugin-forms
@emdash-cms/plugin-webhook-notifier
commit: |
There was a problem hiding this comment.
The PR does the right thing: the SEO panel data has been reachable since #1285 but the public docs never showed how to render it, so this fills a real gap. The documented API shapes match packages/core/src/seo/index.ts (getSeoMeta is re-exported from the main "emdash" entry, SeoMeta fields line up, and entry.data.seo is where the loader attaches the folded SEO data).
I checked the diff, the SEO implementation, the loader's extractSeo/entryData.seo wiring, the package exports, and the generated types. The docs are mostly clean.
One inconsistency: the new example drops the error check that the same guide demonstrates in the preceding "Get a Single Entry" section and its "Error Handling" subsection. Treating a query failure the same as a missing entry is an anti-pattern to avoid teaching readers.
Recommended fix: make the SEO example mirror the error-handling pattern used earlier in the page.
| --- | ||
| import { getEmDashEntry, getSeoMeta } from "emdash"; | ||
|
|
||
| const { entry } = await getEmDashEntry("posts", Astro.params.slug); |
There was a problem hiding this comment.
[suggestion] The example ignores the error result from getEmDashEntry and redirects any failure to /404. The "Get a Single Entry" section immediately above this addition demonstrates checking error first, and the guide's "Error Handling" subsection recommends it. For consistency and to avoid teaching readers to swallow query failures, mirror that pattern here:
| const { entry } = await getEmDashEntry("posts", Astro.params.slug); | |
| const { entry, error } = await getEmDashEntry("posts", Astro.params.slug); | |
| if (error) { | |
| return new Response("Server error", { status: 500 }); | |
| } | |
| if (!entry) return Astro.redirect("/404"); |
There was a problem hiding this comment.
Fixed in 9db9183 — the example now destructures error, returns a 500 on query failure, and only redirects to /404 for a genuinely missing entry, matching the "Get a Single Entry" pattern above.
What does this PR do?
Addresses the documentation half of #1518. The SEO panel's data has been reachable on the render path since #1285 (
entry.data.seo), butgetSeoMeta/getContentSeowere documented nowhere in the public docs — only in the in-repo agent skill references. So the footgun in #1518 stands: a template that hand-rolls<title>/<meta>fromdata.titlesilently bypasses the entire panel, including the noindex toggle.This adds a "Rendering SEO Panel Data" section to the Querying Content guide with a complete
getSeoMetaexample (title/description/OG image/canonical/robots) and a caution box calling out that every detail-page template for an SEO-enabled collection must render through it.It deliberately does not attempt the "warn the editor in the admin when the template doesn't consume SEO" idea from the issue — detecting template wiring from the server is a design discussion, not a docs fix.
Type of change
Checklist
pnpm typecheckpassespnpm lintpassespnpm testpasses (or targeted tests for my change) — docs onlypnpm formathas been runAI-generated code disclosure
Screenshots / test output
n/a — docs. Example verified against the actual
SeoMetaOptions/SeoMetashapes inpackages/core/src/seo/index.ts.