Skip to content

Commit 6a7a4f7

Browse files
TMHSDigitalclaude
andcommitted
Keep the summary in entry meta descriptions (#286)
seoDescription clipped "lead + first sentence" as one string, so clipText cut at the lead's own full stop and dropped the summary whenever the pair ran past 155 characters. About 80 entry pages carried only the licence lead, and pages sharing a licence shared one description. Clip the summary to the room the lead leaves instead, with a word cut and an ellipsis; the lead stands alone only when fewer than 20 characters are left. Built site: 422 entry descriptions, no duplicates, none over 160. Fixes #286 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LpkeXPtfg3jGzhfoGMshTE
1 parent 1bcc458 commit 6a7a4f7

2 files changed

Lines changed: 15 additions & 1 deletion

File tree

‎site/lib/lib.test.mjs‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1668,6 +1668,12 @@ await section("engine scope and limits on entry pages (#173)", async () => {
16681668
has("seo: limits lead the description", seoDescription({ ...base, limits: "No redistribution" }), "no credit needed. No redistribution. A thing.");
16691669
has("seo: an engine lock reads as its badge", seoDescription({ ...base, engine_lock: "unreal" }), "no credit needed. UE only.");
16701670
eq("seo: no scope, no limits, unchanged", seoDescription(base), "MIT, commercial use OK, no credit needed. A thing.");
1671+
// #286: a long first sentence is clipped, not dropped at the lead's full stop.
1672+
const long = { ...base, summary: "Behavior tree addon for Godot 4 that gives enemy and NPC logic a visible structure instead of a growing pile of state booleans. More." };
1673+
const d = seoDescription(long, undefined, { scope: "Godot" });
1674+
has("seo: a long summary keeps its start (#286)", d, "For Godot only. Behavior tree addon for Godot 4");
1675+
eq("seo: a clipped summary ends in an ellipsis (#286)", d.endsWith("…"), true);
1676+
eq("seo: a clipped summary still fits (#286)", d.length <= 155, true);
16711677
});
16721678

16731679
/* heading anchors: validator and guide renderer agree ---------------------- */

‎site/lib/shared.mjs‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,8 @@ export function clipText(text, max) {
161161
/** Search-result limits (Google truncates around these). */
162162
export const SEO_TITLE_MAX = 60;
163163
export const SEO_DESCRIPTION_MAX = 160;
164+
/** Fewer summary characters than this say nothing; the lead stands alone. */
165+
const SEO_SUMMARY_MIN = 20;
164166

165167
/**
166168
* An entry page's `<title>`: "name · licence", the name alone when that is
@@ -221,7 +223,13 @@ export function seoDescription(entry, max = SEO_DESCRIPTION_MAX - 5, { scope = n
221223
const summary = String(entry.summary || "").trim();
222224
if (!summary) return clipText(lead, max);
223225
const first = summary.split(/(?<=[.!?])\s+/)[0];
224-
return clipText(`${lead} ${first}`, max);
226+
// Clip the summary to the room the lead leaves, not the joined string:
227+
// clipping the whole would cut at the lead's own full stop and drop the
228+
// summary entirely, leaving pages that share a licence with one description
229+
// (#286).
230+
const room = max - lead.length - 1;
231+
if (room < SEO_SUMMARY_MIN) return clipText(lead, max);
232+
return `${lead} ${clipText(first, room)}`;
225233
}
226234

227235
/** The commercial-use colour an entry row carries (`--edge`). */

0 commit comments

Comments
 (0)