Repository navigation
fix(og-image): prioritize generated home cards over fallback - #508
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
Standard-mode review of the move of home-page OpenGraph handling from injectHead to transformHtml in @docubook/plugin-og-image, so the generated home card wins over meta.ogImage.
- Home tag replacement:
replaceHomeImageTags()scans only the<head>and skips comments and<script>/<style>bodies. It removesog:image,og:image:*,twitter:imageandtwitter:image:altmeta tags, then adds the card's tags once before</head>. I ran it against real FlamehtmlShelloutput, which writes a self-closing<meta property="og:image" … />frombuildSeoMeta. The fallback was removed and the CSP meta, canonical link and other SEO tags stayed the same. wantsHome()no longer checksmeta.ogImage:onEndnow renders the home card even when a global fallback is set, so the image the page points to always exists.pages.home: falseandexperimental.pagesstill leave Flame's fallback alone.- Dev parity: the dev server builds HTML without
seoand then runsrunTransformHtmlChain, so the home page still gets the card inflame dev.pluginsStamp()hashes the plugin version anddist/, so the patch bump invalidates cached pages. - Docs and changeset: the README, the Flame
og-image.mdxpage and thePagesOption.homeJSDoc describe the new priority. The patch changeset targets the unlinked plugin package.
Verification: vitest run in plugins/og-image passes 151 of 151 tests (after building core, themes-colors, markdown and ui-react).
claude-opus-5-5 | 𝕏
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
This standard-mode re-review covers 1ed25bb. That commit changes how replaceHomeImageTags() removes fallback image tags, which addresses the CodeQL "incomplete multi-character sanitization" alert.
- Splice instead of replace: the head is now tokenized with
matchAll. The code copies the text between dropped<meta>tags and leaves comments,<script>and<style>tokens unchanged. The attribute check moved intoisImageMeta()with no change in behavior. - Boundary space: a dropped tag now leaves one space, except when the output so far is empty or ends in
>or whitespace. Text on either side can no longer join into<!--or<script. When several tags in a row are dropped, only one space is added, because the trailing-whitespace check skips the rest. Real Flame heads put>or a newline before every<meta>, so normal output is the same as before. - Regression test: a new test shows that
<!-<meta…>-- x --><scr<meta…>ipt>becomes<!- -- x --><scr ipt>.
Verification: vitest run in plugins/og-image passed 152 of 152 tests after core, themes-colors, markdown and ui-react were built.
claude-opus-5-5 | 𝕏

Summary
When the plugin generates a home card, use it for the landing page's OpenGraph and Twitter previews instead of
meta.ogImage. Before this change, settingmeta.ogImageturned off the home card. Settingpages.home: falsestill keepsmeta.ogImageon home, and docs pages without their own image still fall back to it.Changes
injectHeadtotransformHtml. On the home page, remove Flame's fallbackog:image*,twitter:imageandtwitter:image:altmeta tags, then write the generated card's tags once, so no image metadata is duplicated.<script>/<style>bodies when matching meta tags, and leave every other tag in the page unchanged.!meta.ogImagecondition fromwantsHome.pages.homeJSDoc to describe the new priority.@docubook/plugin-og-image.Verification
vitest runinplugins/og-image: 151 tests passed, including new coverage for the home tag replacement.tsc --noEmitand the package build passed.