Skip to content

fix(og-image): prioritize generated home cards over fallback - #508

Merged
gitfromwildan merged 2 commits into
mainfrom
fix/og-image-home-priority
Nov 7, 2026
Merged

gitfromwildan merged 2 commits into
mainfrom
fix/og-image-home-priority

Conversation

@gitfromwildan

Copy link
Copy Markdown
Member

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, setting meta.ogImage turned off the home card. Setting pages.home: false still keeps meta.ogImage on home, and docs pages without their own image still fall back to it.

Changes

  • Move home image handling from injectHead to transformHtml. On the home page, remove Flame's fallback og:image*, twitter:image and twitter:image:alt meta tags, then write the generated card's tags once, so no image metadata is duplicated.
  • Skip comments and <script>/<style> bodies when matching meta tags, and leave every other tag in the page unchanged.
  • Drop the !meta.ogImage condition from wantsHome.
  • Update the README, the Flame og-image docs page and the pages.home JSDoc to describe the new priority.
  • Add a patch changeset for @docubook/plugin-og-image.

Verification

  • vitest run in plugins/og-image: 151 tests passed, including new coverage for the home tag replacement.
  • tsc --noEmit and the package build passed.
  • Pre-push workspace lint, all 7 build tasks and commitlint passed.

@vercel

vercel Bot commented Nov 7, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated
docu Ignored Ignored Preview Nov 7, 2026 5:15pm UTC

Comment thread plugins/og-image/src/index.ts Fixed
@gitfromwildan gitfromwildan self-assigned this Nov 7, 2026
pullfrog[bot]
pullfrog Bot previously approved these changes Nov 7, 2026

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ 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 removes og:image, og:image:*, twitter:image and twitter:image:alt meta tags, then adds the card's tags once before </head>. I ran it against real Flame htmlShell output, which writes a self-closing <meta property="og:image" … /> from buildSeoMeta. The fallback was removed and the CSP meta, canonical link and other SEO tags stayed the same.
  • wantsHome() no longer checks meta.ogImage: onEnd now renders the home card even when a global fallback is set, so the image the page points to always exists. pages.home: false and experimental.pages still leave Flame's fallback alone.
  • Dev parity: the dev server builds HTML without seo and then runs runTransformHtmlChain, so the home page still gets the card in flame dev. pluginsStamp() hashes the plugin version and dist/, so the patch bump invalidates cached pages.
  • Docs and changeset: the README, the Flame og-image.mdx page and the PagesOption.home JSDoc 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).

Pullfrog  | View workflow run | Using claude-opus-5-5 | 𝕏

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ 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 into isImageMeta() 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.

Pullfrog  | View workflow run | Using claude-opus-5-5 | 𝕏

@gitfromwildan
gitfromwildan merged commit 5c36178 into main Nov 7, 2026
15 checks passed
@gitfromwildan
gitfromwildan deleted the fix/og-image-home-priority branch November 7, 2026 17:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants