Skip to content

Fix blog teaser ellipsis rendering#8201

Open
arechaithanya wants to merge 1 commit intowebpack:mainfrom
arechaithanya:codex/fix-blog-teaser-ellipsis
Open

Fix blog teaser ellipsis rendering#8201
arechaithanya wants to merge 1 commit intowebpack:mainfrom
arechaithanya:codex/fix-blog-teaser-ellipsis

Conversation

@arechaithanya
Copy link
Copy Markdown
Contributor

This PR updates how blog teasers are generated so that an ellipsis (...) is only added when the preview text is actually truncated.

Previously, the logic in src/utilities/content-tree-enhancers.mjs always appended ... to teasers, even when the full content was already shown. This could make short blog previews look incomplete and could also result in unnecessary ellipses for empty content.

The change keeps the existing teaser rules but adds a check to determine whether truncation actually occurred — either because there were more than three non-heading lines or because the text exceeded the 240-character limit.

What kind of change does this PR introduce?

fix

Did you add tests for your changes?

Yes.

Added tests to cover:

cases where the teaser is not truncated (no ellipsis expected)
cases where the teaser is truncated (ellipsis should be present)

Also verified with:

npm run jest -- src/utilities/content-tree-enhancers.test.mjs
npm run lint:js -- src/utilities/content-tree-enhancers.mjs src/utilities/content-tree-enhancers.test.mjs
npx prettier --check src/utilities/content-tree-enhancers.mjs src/utilities/content-tree-enhancers.test.mjs
git diff --check

Pre-commit checks passed as well.

Does this PR introduce a breaking change?

No.

If relevant, what needs to be documented once your changes are merged or what have you already documented?

No documentation changes are needed. This is an internal improvement to how blog previews are generated.

Use of AI

AI was used to help review the existing logic, suggest a minimal fix, and assist in drafting test cases. The final implementation and validations were reviewed and verified manually.

@vercel
Copy link
Copy Markdown

vercel bot commented Apr 17, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
webpack-js-org Ready Ready Preview, Comment Apr 17, 2026 5:14pm

Request Review

@alexander-akait
Copy link
Copy Markdown
Member

Can you show me where we have a bug on our site?

@arechaithanya
Copy link
Copy Markdown
Contributor Author

Can you show me where we have a bug on our site?

Thanks for taking a look!

This shows up in blog previews where the teaser isn’t actually truncated but still ends with ....

For example:

If a post has fewer than three non-heading lines and stays within the 240-character limit, the full text is already shown.
But the current logic still adds ..., which makes it look like something is cut off when it isn’t.

You can also run into this when the teaser is empty, where ... may still appear.

This change makes sure ... is only added when truncation actually happens, so the preview better reflects what’s really there.

@alexander-akait
Copy link
Copy Markdown
Member

Can you show me this bug on our site?

@arechaithanya
Copy link
Copy Markdown
Contributor Author

Can you show me this bug on our site?

Thanks — the bug shows up in blog teaser previews when the teaser is not actually truncated but still gets ... appended.

I do not think there is a clean public example on the live site right now, because the issue is in the teaser-generation logic itself. I can add a minimal reproduction example if that would help, but the current behavior is that short teaser text can still end with ... even when the full text is already shown.

The fix makes sure ... is only added when truncation really happens.

const isBlogItem = normalizedPath.includes("/blog/");
if (isBlogItem) {
const teaser = (body || "")
const teaserLines = (body || "")
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no point changing variable names and its prototype chaining

@evenstensberg
Copy link
Copy Markdown
Member

got a screenshot of the changes in this PR?

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.

3 participants