34 lines
1.4 KiB
TypeScript
34 lines
1.4 KiB
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, '/');
|
|
}
|
|
|
|
export function getProjectRoute(projectSettings: ProjectSettings, project: ProjectPost) {
|
|
const date = new Date(project.date);
|
|
|
|
return projectSettings.projectRouteTemplate
|
|
.replaceAll("%Y", date.getFullYear().toString())
|
|
.replaceAll("%M", (date.getMonth() + 1).toString().padStart(2, '0'))
|
|
.replaceAll("%D", date.getDate().toString().padStart(2, '0'))
|
|
.replaceAll("%R", project.url)
|
|
.replace(/\/+/g, '/');
|
|
}
|
|
|
|
export function getAlbumRoute(photoSettings: WebsitePhotoSettings, album: PhotoAlbum) {
|
|
const date = new Date(album.startDate);
|
|
|
|
return photoSettings.album.routeTemplate
|
|
.replaceAll("%Y", date.getFullYear().toString())
|
|
.replaceAll("%M", (date.getMonth() + 1).toString().padStart(2, '0'))
|
|
.replaceAll("%D", date.getDate().toString().padStart(2, '0'))
|
|
.replaceAll("%C", album.category.url)
|
|
.replaceAll("%R", album.url)
|
|
.replace(/\/+/g, '/');
|
|
}
|