Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions apps/svelte.dev/src/lib/server/content.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,15 @@ export const index = await create_index(documents, assets, '../../../content', r
const months = 'Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec'.split(' ');

function format_date(date: string) {
if (!/^\d{4}-\d{2}-\d{2}$/.test(date)) {
throw new Error(`Invalid blog post date for date ${date}, should be in the format YYYY-MM-DD`);
}

const [y, m, d] = date.split('-');
const month = months[+m - 1];
if (month === undefined) {
throw new Error(`Invalid blog post month for date ${date}`);
}
return `${months[+m - 1]} ${+d} ${y}`;
}

Expand Down