10 lines
428 B
TypeScript
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, '/');
|
|
} |