From e90714b9e61afb066cc2381f32bb80466bea7ccf Mon Sep 17 00:00:00 2001 From: Alaev Date: Tue, 10 Jan 2023 12:01:50 +0200 Subject: [PATCH] Changes: - Added default value to cleanSlug for simpler structure. - Removed Nullish coalescing operator, --- src/utils/blog.ts | 2 +- src/utils/permalinks.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/utils/blog.ts b/src/utils/blog.ts index 9f58afb..af54638 100644 --- a/src/utils/blog.ts +++ b/src/utils/blog.ts @@ -11,7 +11,7 @@ const getNormalizedPost = async (post: CollectionEntry<'blog'>): Promise = return { id: id, - slug: cleanSlug(slug.split('/').pop() ?? ''), + slug: cleanSlug(slug.split('/').pop()), publishDate: new Date(publishDate), category: cleanSlug(category), diff --git a/src/utils/permalinks.ts b/src/utils/permalinks.ts index c6dcb63..0db7970 100644 --- a/src/utils/permalinks.ts +++ b/src/utils/permalinks.ts @@ -14,7 +14,7 @@ const createPath = (...params: string[]) => { const BASE_PATHNAME = SITE.basePathname; -export const cleanSlug = (text: string) => +export const cleanSlug = (text = '') => trimSlash(text) .split('/') .map((slug) => slugify(slug))