Files
website/astro/src/lib/routing.ts
2026-03-08 15:49:52 +01:00

10 lines
428 B
TypeScript

export function getBlogRoute(blogSettings: BlogSettings, blog: BlogPost) {
const date = new Date(blog.date);
return blogSettings.blogRouteTemplate
.replaceAll("%Y", date.getFullYear().toString())
.replaceAll("%M", (date.getMonth() + 1).toString().padStart(2, '0'))
.replaceAll("%D", date.getDate().toString().padStart(2, '0'))
.replaceAll("%R", blog.url)
.replace(/\/+/g, '/');
}