Skip to content

Re-render an OG card when its title or summary changes - #1226

Merged
yakew7 merged 1 commit into
yakew7:mainfrom
minutechreview:feat/og-input-hashes-1197
Oct 30, 2026
Merged

yakew7 merged 1 commit into
yakew7:mainfrom
minutechreview:feat/og-input-hashes-1197

Conversation

@minutechreview

Copy link
Copy Markdown
Contributor

Summary

generate_og_images.py now stores a hash of each card's inputs in assets/og/card-inputs.json and assets/og-light/card-inputs.json, re-renders a card whose hash changed, and check_generated_files_current.py fails when a stored hash is stale.

Type

  • Audit
  • Explainer
  • Bug fix
  • Other

How it works:

  • card_inputs_hash(kicker, title, subtitle, theme) is the first 16 hex characters of a SHA-256 over those four values.
  • Each theme folder gets its own card-inputs.json ({slug: hash}, sorted). Keeping it next to the PNGs means the tests that point THEMES[...]["out_dir"] at a temp folder never touch the real files.
  • In main(), an existing PNG is skipped only while its stored hash matches. A changed title or summary, or a card with no stored hash, is re-rendered. --force still re-renders everything. The file is rewritten on every run with only the current cards, so removed explainers drop out.
  • render_card_both_themes() called without stored keeps the old behaviour (skip any existing PNG), so the generate_og_images.py rewrites every existing OG image on a different machine #1144 test still holds.
  • The check adds both JSON files to TEXT_GLOBS. Its fresh build already runs the generator, so a hash that no longer matches the inputs shows up as assets/og/card-inputs.json: content differs from a fresh regeneration, with the usual "run make build-explainers" line.

The two committed JSON files hold hashes of the current inputs for all 117 cards per theme, written without re-rendering any PNG. They assume the committed cards match today's titles and summaries. I can't confirm that pixel by pixel across platforms, so any card that was already stale before this PR stays as it is until it is edited or forced.

Proof, run on this branch:

  • I changed the popularity-bias title in assets/explainers-data.json and ran only build_explainers.py. The check then failed with exactly the two card-inputs.json lines. Running generate_og_images.py printed Wrote 2 of 234 and changed only assets/og/popularity-bias.png and assets/og-light/popularity-bias.png plus the two JSON files. After that the check passed. I reverted the title afterwards.
  • New tests: test_a_changed_title_re_renders_only_that_cards_two_pngs (only second.png is rewritten in each theme, only its hash changes, and a third run writes 0), test_card_inputs_hash_depends_on_every_input, test_text_globs_cover_the_og_card_input_hashes, and test_main_flags_a_stale_og_card_input_hash. With the old generator the two generator tests fail. Without the TEXT_GLOBS lines the globs test fails.
  • pytest tests/test_generate_images.py tests/test_check_generated_files_current.py tests/test_og_card_consistency.py: 30 passed, 1 skipped (slow). python3 scripts/check_generated_files_current.py passes. ruff check, check_em_dash.py, check_broken_links.py and check_issue_refs.py pass.

The module docstrings, CHANGELOG (Unreleased, Added) and the README tree are updated.

Linked issue

Closes #1197

Signed-off-by: minutechreview <141821420+minutechreview@users.noreply.github.com>
@vercel

vercel Bot commented Oct 29, 2026

Copy link
Copy Markdown
Contributor

@minutechreview is attempting to deploy a commit to the yashkewlani2020-gmailcom's projects Team on Vercel.

A member of the Team first needs to authorize it.

@github-actions

Copy link
Copy Markdown

@yakew7 @Shreyash0712 @ahmdkaml @propcgamer20-png - new PR touching a path you own, please review.

@yakew7
yakew7 merged commit 31c2175 into yakew7:main Oct 30, 2026
19 of 20 checks passed
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.

An OG image is not re-rendered when its explainer's title or summary changes

2 participants