fix(collections): tolerate unquoted colons in titles + cleaner excerpts#22
Merged
Conversation
The model keeps emitting YAML values like \`title: Commute Mastery: Owning the Road\` — the second colon makes front-matter's strict YAML parse throw. buildCollections then fell back to an empty data object, which made \`post.title\` resolve to the filename (\`commute-mastery.md\`), which slugified to \`commute-mastery-md\`, and the excerpt extraction was also running against the un-stripped source so the user saw front-matter \`---\` lines in their blog list. Three fixes, one file each: 1. src/runtime/frontMatter.ts (new) — shared YAML front-matter parser used by both the markdown renderer and buildCollections. Three tiers: strict \`fm()\` parse, fenced split + \`fm()\`, and a naive \`key: value\` per-line fallback that splits on the first colon only so "Commute Mastery: Owning the Road" comes through as a complete string. markdownRender re-exports parseFrontMatter from here so existing callers are unchanged. 2. src/runtime/nunjucksRender.ts buildCollections — strips leading headings, markdown images, and raw HTML tags from the body before truncating to 180 chars. Previous excerpts surfaced hero <img> tags as the lead text. 3. scripts/ — a local verify harness for the exact site the user flagged confirmed all three blog posts now resolve to proper titles, dates, and prose excerpts. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
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.
Blog list pages were showing raw YAML in the excerpt and filenames as link text because the model's
title: Foo: Bartripped the strict YAML parser. Shared front-matter helper falls back to a naive first-colon split; excerpts now strip headings / images / HTML. Verified locally against site 2980b971.