feat: add social preview metadata for posts #225

Merged
erik merged 1 commit from feat/task-8bf18a24-post-preview-metadata into main 2026-06-28 07:39:43 -05:00
Owner

Summary

  • Add reusable OpenGraph/Twitter preview metadata support to the public page renderer.
  • Wire post detail pages to emit og:type=article, absolute canonical/preview URLs, and first Markdown image metadata when available.
  • Use safe no-image fallback behavior with twitter:card=summary.
  • Document social crawler cache behavior, including Mastodon preview caching.

Verification

  • npm exec --workspace @slugkit/template-site -- vitest run --config ./vitest.config.ts src/routes/tests/public.test.ts
  • npm run typecheck --workspace @slugkit/template-site
  • npm run lint
  • ./scripts/pre-pr.sh

Task: #task-8bf18a24

## Summary - Add reusable OpenGraph/Twitter preview metadata support to the public page renderer. - Wire post detail pages to emit `og:type=article`, absolute canonical/preview URLs, and first Markdown image metadata when available. - Use safe no-image fallback behavior with `twitter:card=summary`. - Document social crawler cache behavior, including Mastodon preview caching. ## Verification - npm exec --workspace @slugkit/template-site -- vitest run --config ./vitest.config.ts src/routes/__tests__/public.test.ts - npm run typecheck --workspace @slugkit/template-site - npm run lint - ./scripts/pre-pr.sh Task: #task-8bf18a24
feat: add social preview metadata for posts
All checks were successful
CI / build-lint-test (pull_request) Successful in 50s
9278953135
Task: #task-8bf18a24
Author
Owner

Review summary

Approved.

Acceptance criteria

  • Generated/template post detail pages can emit og:title, og:description, og:url, og:type, and image metadata where available. Evidence: public page renderer now emits OpenGraph metadata; post detail route passes preview: { type: "article", ...extractFirstImagePreview(...) }; tests assert all required OpenGraph tags for an image-backed article.
  • Twitter card metadata is supported, including summary_large_image for image-backed posts. Evidence: renderer emits twitter:card, twitter:title, twitter:description, and image tags; tests assert summary_large_image for image-backed article and summary for no-image article.
  • Preview image URLs are absolute and reachable when generated. Evidence: renderer converts preview image paths through toAbsoluteUrl; tests assert http://localhost:3000/media/hero.png for /media/hero.png.
  • Existing page title/description/canonical behavior remains compatible. Evidence: canonical URL now uses the same computed absolute URL; existing public route tests pass and metadata tests assert canonical remains present.
  • Tests or template snapshots cover preview metadata behavior. Evidence: public route tests cover image-backed and no-image post metadata.
  • Documentation notes crawler cache behavior, especially Mastodon preview caching. Evidence: template README social preview metadata section documents aggressive crawler caching and Mastodon behavior.

Blocking issues

  • None.

Warnings

  • None.

Verification reviewed

  • ./scripts/pre-pr.sh passed locally.
  • Forgejo CI run #312 passed.
  • Diff reviewed with git diff --check main...HEAD.

Final verdict

Approved. Ready for human merge approval.

### Review summary Approved. ### Acceptance criteria - [x] Generated/template post detail pages can emit `og:title`, `og:description`, `og:url`, `og:type`, and image metadata where available. Evidence: public page renderer now emits OpenGraph metadata; post detail route passes `preview: { type: "article", ...extractFirstImagePreview(...) }`; tests assert all required OpenGraph tags for an image-backed article. - [x] Twitter card metadata is supported, including `summary_large_image` for image-backed posts. Evidence: renderer emits `twitter:card`, `twitter:title`, `twitter:description`, and image tags; tests assert `summary_large_image` for image-backed article and `summary` for no-image article. - [x] Preview image URLs are absolute and reachable when generated. Evidence: renderer converts preview image paths through `toAbsoluteUrl`; tests assert `http://localhost:3000/media/hero.png` for `/media/hero.png`. - [x] Existing page title/description/canonical behavior remains compatible. Evidence: canonical URL now uses the same computed absolute URL; existing public route tests pass and metadata tests assert canonical remains present. - [x] Tests or template snapshots cover preview metadata behavior. Evidence: public route tests cover image-backed and no-image post metadata. - [x] Documentation notes crawler cache behavior, especially Mastodon preview caching. Evidence: template README social preview metadata section documents aggressive crawler caching and Mastodon behavior. ### Blocking issues - None. ### Warnings - None. ### Verification reviewed - `./scripts/pre-pr.sh` passed locally. - Forgejo CI run #312 passed. - Diff reviewed with `git diff --check main...HEAD`. ### Final verdict Approved. Ready for human merge approval.
erik merged commit c0ade041f4 into main 2026-06-28 07:39:43 -05:00
erik deleted branch feat/task-8bf18a24-post-preview-metadata 2026-06-28 07:39:43 -05:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
erik/slugkit!225
No description provided.