refactor: improve code quality

This commit is contained in:
saicaca
2024-07-21 15:47:49 +08:00
parent 743d8dd9c2
commit 003c644146
20 changed files with 76 additions and 69 deletions

View File

@@ -12,13 +12,11 @@ function joinUrl(...parts: string[]): string {
return joined.replace(/\/+/g, '/');
}
export function getPostUrlBySlug(slug: string): string | null {
if (!slug) return null
export function getPostUrlBySlug(slug: string): string {
return url(`/posts/${slug}/`)
}
export function getCategoryUrl(category: string): string | null {
if (!category) return null
export function getCategoryUrl(category: string): string {
if (category === i18n(i18nKey.uncategorized))
return url('/archive/category/uncategorized/')
return url(`/archive/category/${category}/`)