Implement content generation

This commit is contained in:
2026-03-07 11:18:05 +03:00
parent 4b04afb912
commit 22866db191
8 changed files with 102 additions and 8 deletions

10
src/utils/articles.ts Normal file
View File

@@ -0,0 +1,10 @@
/**
* Парсит дату из ID статьи (формат: "2019-05-01-slug").
*/
export function parseDateFromId(id: string): Date {
const match = id.match(/^(\d{4})-(\d{2})-(\d{2})-/);
if (!match) {
throw new Error(`Cannot parse date from article id: ${id}`);
}
return new Date(`${match[1]}-${match[2]}-${match[3]}`);
}