mirror of
https://github.com/saicaca/fuwari.git
synced 2026-01-12 07:12:52 +01:00
refactor: improve code quality
This commit is contained in:
@@ -14,11 +14,11 @@ export function getHue(): number {
|
||||
|
||||
export function setHue(hue: number): void {
|
||||
localStorage.setItem('hue', String(hue))
|
||||
const r = document.querySelector(':root')
|
||||
const r = document.querySelector(':root') as HTMLElement
|
||||
if (!r) {
|
||||
return
|
||||
}
|
||||
r.style.setProperty('--hue', hue)
|
||||
r.style.setProperty('--hue', String(hue))
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -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}/`)
|
||||
|
||||
Reference in New Issue
Block a user