Strip shortcodes out of excerpts on the way in - #77
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.
stripShortcodesinutils/shortcodes.ts, matching the CMS'sshortcodePattern: known shortcode names, plus any bracketed token carrying attributes. Editorial brackets ([sic],[Editor's note]) carry no=and survive.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.truncateDescriptioninArticleLayout.astrostrips 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