Skip to content

feat: use article body excerpt for OG description - #133

Merged
ro80t merged 3 commits into
mainfrom
feat-og-excerpt-description
Aug 21, 2026
Merged

feat: use article body excerpt for OG description#133
ro80t merged 3 commits into
mainfrom
feat-og-excerpt-description

Conversation

@ro80t

@ro80t ro80t commented Aug 21, 2026

Copy link
Copy Markdown
Owner

Summary

  • Add src/lib/excerpt.ts, which strips common Markdown/MDX syntax (code fences, headings, links, emphasis, etc.) from an article's raw body and returns a short plain-text excerpt.
  • For articles with body content, use that excerpt as the description shown in the OG image and in the description / og:description meta tags, instead of always falling back to the site-wide description.
  • Priority order stays: explicit frontmatter description → excerpt from body → site description (unchanged behavior for body-less/redirect articles, which still show the site description).

Test plan

  • npm run build regenerates all OG images and article pages
  • Verified an article with body content (2024/dns-check) now shows an excerpt of its actual content in both the OG image and <meta name="description"> / <meta property="og:description">
  • Verified a redirect-only article with no body still falls back to the site description
  • npm run lint shows no new issues

🤖 Generated with Claude Code

https://claude.ai/code/session_01Myi55GMKN6FaoJdCGcVvnb

@github-actions

Copy link
Copy Markdown
Contributor

🔍 Preview deployed to: https://wktk.moe/pr-preview-133/

github-actions Bot added a commit that referenced this pull request Aug 21, 2026
…kdown

Regex-stripping raw Markdown/MDX source couldn't reliably handle the
site's remark/rehype pipeline (math, admonitions, link cards, autolink
headings, etc). Astro's content loader already stores the fully
rendered HTML for each entry (`entry.rendered.html`), so strip that
instead, which only requires handling real HTML tags/entities.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Myi55GMKN6FaoJdCGcVvnb
github-actions Bot added a commit that referenced this pull request Aug 21, 2026
Replace the manual HTML-tag-stripping regex with hast-util-from-html
(parse5-backed HTML parser), hast-util-to-text (innerText-like plain
text extraction), and unist-util-remove (drop the decorative "#"
heading-anchor links before extracting text) — all official packages
from the same unified/syntax-tree collective that already powers this
site's Markdown pipeline.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Myi55GMKN6FaoJdCGcVvnb
github-actions Bot added a commit that referenced this pull request Aug 21, 2026
@ro80t
ro80t merged commit 13c4372 into main Aug 21, 2026
5 checks passed
@ro80t
ro80t deleted the feat-og-excerpt-description branch August 21, 2026 12:49
github-actions Bot added a commit that referenced this pull request Aug 21, 2026
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.

1 participant