mirror of
https://github.com/saicaca/fuwari.git
synced 2026-01-11 23:02:53 +01:00
format all code (#386)
This commit is contained in:
committed by
GitHub
parent
7ea2f7f40f
commit
286b050fa8
@@ -1,35 +1,35 @@
|
||||
import i18nKey from '@i18n/i18nKey'
|
||||
import { i18n } from '@i18n/translation'
|
||||
import i18nKey from "@i18n/i18nKey";
|
||||
import { i18n } from "@i18n/translation";
|
||||
|
||||
export function pathsEqual(path1: string, path2: string) {
|
||||
const normalizedPath1 = path1.replace(/^\/|\/$/g, '').toLowerCase()
|
||||
const normalizedPath2 = path2.replace(/^\/|\/$/g, '').toLowerCase()
|
||||
return normalizedPath1 === normalizedPath2
|
||||
const normalizedPath1 = path1.replace(/^\/|\/$/g, "").toLowerCase();
|
||||
const normalizedPath2 = path2.replace(/^\/|\/$/g, "").toLowerCase();
|
||||
return normalizedPath1 === normalizedPath2;
|
||||
}
|
||||
|
||||
function joinUrl(...parts: string[]): string {
|
||||
const joined = parts.join('/')
|
||||
return joined.replace(/\/+/g, '/')
|
||||
const joined = parts.join("/");
|
||||
return joined.replace(/\/+/g, "/");
|
||||
}
|
||||
|
||||
export function getPostUrlBySlug(slug: string): string {
|
||||
return url(`/posts/${slug}/`)
|
||||
return url(`/posts/${slug}/`);
|
||||
}
|
||||
|
||||
export function getCategoryUrl(category: string): string {
|
||||
if (category === i18n(i18nKey.uncategorized))
|
||||
return url('/archive/category/uncategorized/')
|
||||
return url(`/archive/category/${category}/`)
|
||||
if (category === i18n(i18nKey.uncategorized))
|
||||
return url("/archive/category/uncategorized/");
|
||||
return url(`/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);
|
||||
}
|
||||
|
||||
export function url(path: string) {
|
||||
return joinUrl('', import.meta.env.BASE_URL, path)
|
||||
return joinUrl("", import.meta.env.BASE_URL, path);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user