Changes:
- Added default value to cleanSlug for simpler structure. - Removed Nullish coalescing operator,
This commit is contained in:
@ -11,7 +11,7 @@ const getNormalizedPost = async (post: CollectionEntry<'blog'>): Promise<Post> =
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
id: id,
|
id: id,
|
||||||
slug: cleanSlug(slug.split('/').pop() ?? ''),
|
slug: cleanSlug(slug.split('/').pop()),
|
||||||
|
|
||||||
publishDate: new Date(publishDate),
|
publishDate: new Date(publishDate),
|
||||||
category: cleanSlug(category),
|
category: cleanSlug(category),
|
||||||
|
@ -14,7 +14,7 @@ const createPath = (...params: string[]) => {
|
|||||||
|
|
||||||
const BASE_PATHNAME = SITE.basePathname;
|
const BASE_PATHNAME = SITE.basePathname;
|
||||||
|
|
||||||
export const cleanSlug = (text: string) =>
|
export const cleanSlug = (text = '') =>
|
||||||
trimSlash(text)
|
trimSlash(text)
|
||||||
.split('/')
|
.split('/')
|
||||||
.map((slug) => slugify(slug))
|
.map((slug) => slugify(slug))
|
||||||
|
Reference in New Issue
Block a user