Add og:image:type meta tag to social cards#1337
Open
IEvangelist wants to merge 1 commit into
Open
Conversation
Emit og:image:type so crawlers can validate/decode the OG image without content sniffing. The MIME type is inferred from the resolved og:image URL extension (defaulting to image/png), covering the dynamic /og/<slug>.png cards, the /og-image.png fallback, and any non-PNG ogImage frontmatter override. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Adds support for the optional Open Graph meta tag og:image:type across aspire.dev’s generated social metadata so crawlers can interpret the image MIME type without sniffing.
Changes:
- Extend the OG metadata pipeline with an
imageTypefield and aresolveOgImageType()helper that infers MIME type from theog:imageURL (defaulting toimage/png). - Emit
<meta property="og:image:type" ...>in the Starlight head wrapper alongside existingog:imagetags. - Add unit and e2e coverage to validate the inferred MIME type and emitted meta tag.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| src/frontend/src/utils/page-metadata.ts | Adds OgMetadata.imageType and resolveOgImageType(); wires imageType into getOgMetadata(). |
| src/frontend/src/components/starlight/Head.astro | Emits the og:image:type meta tag next to og:image. |
| src/frontend/config/head.attrs.ts | Updates the documentation comment listing dynamically emitted per-page OG tags. |
| src/frontend/tests/unit/page-metadata.vitest.test.ts | Adds unit tests for MIME-type inference and getOgMetadata().imageType. |
| src/frontend/tests/e2e/og-metadata.spec.ts | Adds e2e assertions that og:image:type is present and image/png for key pages. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Contributor
Frontend HTML artifact readyThe latest frontend build uploaded the This comment updates automatically when a new frontend build artifact is uploaded. |
davidfowl
approved these changes
Jul 9, 2026
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
Adds the optional
og:image:typeOpen Graph meta tag to every page's social card so crawlers can validate and decode the image by its advertised MIME type without content sniffing.Details
OG image tags on aspire.dev are generated (Astro + Starlight), not hardcoded per page, so the fix lives in the metadata pipeline:
src/utils/page-metadata.ts— added animageTypefield toOgMetadataand aresolveOgImageType()helper that infers the MIME type from the resolvedog:imageURL extension. Defaults toimage/png(covering the dynamic/og/<slug>.pngcards and the/og-image.pngfallback) and also mapsjpeg/webp/gif/svg/aviffor anyogImagefrontmatter override. Case-insensitive; ignores query strings and fragments.src/components/starlight/Head.astro— emits<meta property="og:image:type" content={ogMetadata.imageType} />immediately afterog:image.config/head.attrs.ts— updated the doc comment listing the per-page OG tags.Tests
tests/unit/page-metadata.vitest.test.ts) — newresolveOgImageTypesuite (extension mapping, case-insensitivity, query/fragment handling, unknown/missing-extension fallback) plusgetOgMetadataassertions for PNG and a non-PNG override.tests/e2e/og-metadata.spec.ts) — assertsog:image:type=image/pngon the dynamic-card and sample pages.