Skip to content

Strip shortcodes out of excerpts on the way in - #77

Merged
ssavutu merged 1 commit into
mainfrom
fix/shortcode-excerpts
Aug 7, 2026
Merged

Strip shortcodes out of excerpts on the way in#77
ssavutu merged 1 commit into
mainfrom
fix/shortcode-excerpts

Conversation

@ssavutu

@ssavutu ssavutu commented Aug 7, 2026

Copy link
Copy Markdown
Member

Article bodies still hold unexpanded WordPress shortcodes. The body expands them into embeds (expandShortcodes), but an excerpt has no room for one: the crossword post "What's on Tea-V?" is a single [puzzleme ...] shortcode, and its excerpt reached the Comics & Puzzles listing, the RSS feed and <meta name="description"> as literal shortcode text.

DrexelTriangle/triangle-cms#211 stops the CMS deriving excerpts like this, and the affected row is cleared directly — but excerpts stored before that still carry shortcodes, so this strips on the way in as well.

  • stripShortcodes in utils/shortcodes.ts, matching the CMS's shortcodePattern: known shortcode names, plus any bracketed token carrying attributes. Editorial brackets ([sic], [Editor's note]) carry no = and survive.
  • Applied at the data boundary in utils/db.js. Excerpts ride inside a different shape on every endpoint and reach the page through cards, the feed, the infinite-scroll route and the layout head, so one walk over each parsed payload covers all of them rather than ~10 render sites.
  • truncateDescription in ArticleLayout.astro strips too: the meta description's last fallback is the raw body, which is exactly where the shortcode would resurface once the excerpt is clean.

astro check: 0 errors. eslint clean.

🤖 Generated with Claude Code

Article bodies still hold unexpanded WordPress shortcodes. The body
expands them into embeds, but the excerpt has no room for one: a
crossword post whose whole body is [puzzleme ...] derived an excerpt that
was the shortcode source, and it reached the Comics & Puzzles listing,
the RSS feed and <meta name="description"> as literal text.

The CMS no longer derives excerpts like this, but excerpts stored before
that still carry shortcodes, so strip on the way in as well. Excerpts
ride inside a different shape on every endpoint and reach the page
through cards, the feed, the infinite-scroll route and the layout head,
so this walks each parsed payload once at the data boundary rather than
touching ~10 render sites. The meta description also falls back to the
raw body, which would otherwise be where the shortcode resurfaced.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@ssavutu
ssavutu merged commit 38ee6cd into main Aug 7, 2026
1 check passed
@ssavutu
ssavutu deleted the fix/shortcode-excerpts branch August 7, 2026 20:52
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