7e3299e3bd
Introduce formatBlogDate, slugifyTag and getTagHref in src/lib/blog.ts and a reading time helper getReadingTime in src/lib/readingTime.ts. Update blog index and post pages to display ISO dates, reading times and link tags to /blog/tag/<slug>. Add a tag listing page at src/pages/blog/tag/[tag].astro with styles and static paths generation
18 lines
409 B
TypeScript
18 lines
409 B
TypeScript
export function formatBlogDate(date: Date) {
|
|
return date.toISOString().split("T")[0];
|
|
}
|
|
|
|
export function slugifyTag(tag: string) {
|
|
return tag
|
|
.toLowerCase()
|
|
.trim()
|
|
.replace(/&/g, " and ")
|
|
.replace(/[^a-z0-9\s-]/g, "")
|
|
.replace(/\s+/g, "-")
|
|
.replace(/-+/g, "-");
|
|
}
|
|
|
|
export function getTagHref(tag: string) {
|
|
return `/blog/tag/${slugifyTag(tag)}`;
|
|
}
|