diff --git a/docs/src/content/docs/guides/querying-content.mdx b/docs/src/content/docs/guides/querying-content.mdx index 03718063d4..8338f61935 100644 --- a/docs/src/content/docs/guides/querying-content.mdx +++ b/docs/src/content/docs/guides/querying-content.mdx @@ -196,6 +196,43 @@ interface ContentEntry { The `data` object within `entry` contains all fields defined for the content type. The `edit` proxy provides visual editing annotations (see below). +## Rendering SEO Panel Data + +For collections with `supports: ["seo"]`, editors can set an SEO title, meta description, OG image, canonical URL, and a "hide from search engines" (noindex) toggle in the admin's SEO panel. That data is delivered on the entry as `entry.data.seo` — but it only reaches the rendered page if your template emits it. Use `getSeoMeta` to resolve the panel fields (with sensible fallbacks to `data.title` / `data.excerpt`) into ready-to-render meta tags: + +```astro title="src/pages/posts/[...slug].astro" +--- +import { getEmDashEntry, getSeoMeta } from "emdash"; + +const { entry, error } = await getEmDashEntry("posts", Astro.params.slug); +if (error) { + return new Response("Server error", { status: 500 }); +} +if (!entry) return Astro.redirect("/404"); + +const seo = getSeoMeta(entry, { + siteTitle: "My Site", + siteUrl: "https://example.com", + path: Astro.url.pathname, +}); +--- + + + {seo.title} + {seo.description && } + {seo.ogImage && } + {seo.canonical && } + {seo.robots && } + +``` + + + ## Preview Mode EmDash handles preview automatically via middleware. When a URL contains a valid `_preview` token, the middleware verifies it and sets up the request context. Your query functions then serve draft content without any special parameters: