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:
@ -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
|
||||
}
|
||||
|
@ -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
|
||||
}
|
||||
|
Reference in New Issue
Block a user