Skip to content

An open source design system that's fully customizable and agent ready

TypeScript

fix(docsite): parse CRLF blog frontmatter (#4031)

Harjoth Khara0c160d5dca81
diff --git a/apps/docsite/src/__tests__/blog.test.ts b/apps/docsite/src/__tests__/blog.test.ts
index b7a524c128..8d2143a6c8 100644
--- a/apps/docsite/src/__tests__/blog.test.ts
+++ b/apps/docsite/src/__tests__/blog.test.ts
@@ -229,6 +229,17 @@ describe('discoverPosts (temp fixtures)', () => {
expect(discoverPosts(path.join(dir, 'nope'))).toEqual([]);
});
+ it('discovers posts with CRLF line endings', () => {
+ write('windows.md', fm({title: 'Windows'}).replace(/\n/g, '\r\n'));
+ expect(discoverPosts(dir)).toEqual([
+ expect.objectContaining({
+ slug: 'windows',
+ title: 'Windows',
+ body: 'Body content here.',
+ }),
+ ]);
+ });
+
it('discovers posts and sorts latest-first', () => {
write('older.md', fm({date: '2026-01-01', title: 'Older'}));
write('newer.md', fm({date: '2026-06-01', title: 'Newer'}));
diff --git a/apps/docsite/src/lib/blog/posts.mjs b/apps/docsite/src/lib/blog/posts.mjs
index f371c427a0..feb4f47036 100644
--- a/apps/docsite/src/lib/blog/posts.mjs
+++ b/apps/docsite/src/lib/blog/posts.mjs
@@ -207,7 +207,7 @@ export function parseYamlFrontmatter(text) {
* @returns {{data: Record<string, unknown>, body: string}}
*/
export function parseFrontmatter(raw) {
- const normalized = raw.replace(/^\uFEFF/, '');
+ const normalized = raw.replace(/^\uFEFF/, '').replace(/\r\n?/g, '\n');
const match = normalized.match(/^---\n([\s\S]*?)\n---\n?([\s\S]*)$/);
if (!match) {
return {data: {}, body: normalized.trim()};