1
1
mirror of https://github.com/theoludwig/theoludwig.git synced 2025-05-29 22:37:44 +02:00

chore: better Prettier config for easier reviews

This commit is contained in:
2023-10-23 23:11:59 +02:00
parent c7ad15a465
commit e566ef6c38
105 changed files with 2138 additions and 2080 deletions

View File

@ -1,9 +1,9 @@
import UniversalCookie from 'universal-cookie'
import UniversalCookie from "universal-cookie"
import { DEFAULT_THEME } from '@/utils/constants'
import type { CookiesStore, Theme } from '@/utils/constants'
import { DEFAULT_THEME } from "@/utils/constants"
import type { CookiesStore, Theme } from "@/utils/constants"
export const useTheme = (cookiesStore: CookiesStore): Theme => {
const universalCookie = new UniversalCookie(cookiesStore)
return universalCookie.get('theme') ?? DEFAULT_THEME
return universalCookie.get("theme") ?? DEFAULT_THEME
}

View File

@ -1,19 +1,19 @@
'use server'
"use server"
import { cookies } from 'next/headers'
import { cookies } from "next/headers"
import type { Theme } from '@/utils/constants'
import { COOKIE_MAX_AGE, DEFAULT_THEME, THEMES } from '@/utils/constants'
import type { Theme } from "@/utils/constants"
import { COOKIE_MAX_AGE, DEFAULT_THEME, THEMES } from "@/utils/constants"
export const setTheme = (theme: Theme): void => {
cookies().set('theme', theme, {
path: '/',
maxAge: COOKIE_MAX_AGE
cookies().set("theme", theme, {
path: "/",
maxAge: COOKIE_MAX_AGE,
})
}
export const getTheme = (): Theme => {
const theme = cookies().get('theme')?.value ?? DEFAULT_THEME
const theme = cookies().get("theme")?.value ?? DEFAULT_THEME
if (THEMES.includes(theme as Theme)) {
return theme as Theme
}