Trim bio on index page before truncating#462
Conversation
|
/gemini review |
There was a problem hiding this comment.
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.
| {% 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> |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
trimtoperson.data.biobeforetruncate(120)on the index page.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
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.
| {% 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> |
There was a problem hiding this comment.
Adding the trim filter is a good improvement to ensure the quotes wrap the content tightly. However, there are two points to consider:
- Truncation vs. Line-clamp: Using
truncate(120)alongsideline-clamp-3is 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. - Whitespace-only strings: If
biocontains only whitespace (e.g.," "), the{% if bio %}check on line 48 will pass, butbio | trimwill 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>
Minor whitespace removed from a short bio at the end as seen in these two images. A little cleaner.