refactor: code cleanup

This commit is contained in:
saicaca authored and saica.go committed 2024-02-18 18:26:40 +08:00
1 parent 3cd21c2da9
commit af29b9160f
51 files changed
+872 -2264

No files matched your search

+10 -11
View File
@@ -1,5 +1,5 @@
import {i18n} from "@i18n/translation.ts";
import i18nKey from "@i18n/i18nKey.ts";
import i18nKey from '@i18n/i18nKey'
import { i18n } from '@i18n/translation'
export function pathsEqual(path1: string, path2: string) {
const normalizedPath1 = path1.replace(/^\/|\/$/g, '').toLowerCase()
@@ -18,17 +18,16 @@ export function getPostUrlBySlug(slug: string): string | null {
}
export function getCategoryUrl(category: string): string | null {
if (!category)
return null
if (!category) return null
if (category === i18n(i18nKey.uncategorized))
return '/archive/category/uncategorized'
return '/archive/category/uncategorized'
return `/archive/category/${category}`
}
export function getDir(path: string): string {
const lastSlashIndex = path.lastIndexOf('/')
if (lastSlashIndex < 0) {
return '/'
}
return path.substring(0, lastSlashIndex + 1)
}
const lastSlashIndex = path.lastIndexOf('/')
if (lastSlashIndex < 0) {
return '/'
}
return path.substring(0, lastSlashIndex + 1)
}