Skip to content

Trim bio on index page before truncating#462

Merged
jbampton merged 1 commit intoNextCommunity:mainfrom
jbampton:index-bio-trim
May 2, 2026
Merged

Trim bio on index page before truncating#462
jbampton merged 1 commit intoNextCommunity:mainfrom
jbampton:index-bio-trim

Conversation

@jbampton
Copy link
Copy Markdown
Member

@jbampton jbampton commented May 2, 2026

Minor whitespace removed from a short bio at the end as seen in these two images. A little cleaner.

Screenshot 2026-05-03 at 2 01 07 am Screenshot 2026-05-03 at 2 01 25 am

@jbampton jbampton added this to the Turbo milestone May 2, 2026
@jbampton jbampton self-assigned this May 2, 2026
@jbampton jbampton requested a review from BaseMax as a code owner May 2, 2026 16:12
@jbampton jbampton added this to Next May 2, 2026
@jbampton jbampton added good first issue Good for newcomers nunjucks labels May 2, 2026
@github-project-automation github-project-automation Bot moved this to In progress in Next May 2, 2026
@jbampton jbampton moved this from In progress to Review in progress in Next May 2, 2026
@jbampton jbampton requested a review from Copilot May 2, 2026 16:13
@jbampton
Copy link
Copy Markdown
Member Author

jbampton commented May 2, 2026

/gemini review

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request updates the bio display in src/index.njk by applying a trim filter before truncation to ensure cleaner text output. A review comment points out that the conditional check {% if bio %} should also be updated to {% if bio | trim %} to prevent the UI from rendering empty quotes when the bio contains only whitespace.

Comment thread src/index.njk
{% set bio = person.data.bio %}
{% if bio %}
<p class="mt-4 text-[var(--text-muted)] text-sm italic line-clamp-3">"{{ bio | truncate(120) }}"</p>
<p class="mt-4 text-[var(--text-muted)] text-sm italic line-clamp-3">"{{ bio | trim | truncate(120) }}"</p>
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

The current check {% if bio %} on line 48 evaluates to true for strings containing only whitespace. With the addition of the trim filter, such cases will now render as an empty pair of quotes ("") within a <p> tag, creating unnecessary vertical space and a minor UI glitch. It is recommended to update the condition on line 48 to {% if bio | trim %} to ensure the bio section only renders when there is actual content.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR cleans up how short bios are displayed on the index page by trimming leading/trailing whitespace before truncation, preventing stray spaces from appearing at the end of the quoted bio snippet.

Changes:

  • Apply Nunjucks trim to person.data.bio before truncate(120) on the index page.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces the trim filter to the bio field in src/index.njk to ensure cleaner formatting within quotes. Feedback suggests increasing the truncation limit to 300 to better align with the CSS line-clamping and recommends trimming the bio before the existence check to prevent rendering empty quotes for whitespace-only strings.

Comment thread src/index.njk
{% set bio = person.data.bio %}
{% if bio %}
<p class="mt-4 text-[var(--text-muted)] text-sm italic line-clamp-3">"{{ bio | truncate(120) }}"</p>
<p class="mt-4 text-[var(--text-muted)] text-sm italic line-clamp-3">"{{ bio | trim | truncate(120) }}"</p>
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

Adding the trim filter is a good improvement to ensure the quotes wrap the content tightly. However, there are two points to consider:

  1. Truncation vs. Line-clamp: Using truncate(120) alongside line-clamp-3 is often counter-productive. On most screens, 120 characters will only fill 1-2 lines, leaving the third line empty and making the CSS clamp redundant. Increasing the limit (e.g., to 300) allows the CSS to handle the truncation more responsively across different screen sizes while still providing a safety limit for very long bios.
  2. Whitespace-only strings: If bio contains only whitespace (e.g., " "), the {% if bio %} check on line 48 will pass, but bio | trim will be empty, resulting in empty quotes "" being rendered. Ideally, the bio should be trimmed before the truthiness check on line 48.
          <p class="mt-4 text-[var(--text-muted)] text-sm italic line-clamp-3">"{{ bio | trim | truncate(300) }}"</p>

@jbampton jbampton merged commit ef98585 into NextCommunity:main May 2, 2026
16 of 17 checks passed
@jbampton jbampton deleted the index-bio-trim branch May 2, 2026 16:28
@github-project-automation github-project-automation Bot moved this from Review in progress to Done in Next May 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants