87 lines
2.8 KiB
TypeScript
87 lines
2.8 KiB
TypeScript
import { fonts } from './utils/fonts'
|
|
|
|
export default defineNuxtConfig({
|
|
compatibilityDate: '2024-04-03',
|
|
devtools: { enabled: true },
|
|
modules: ['@unocss/nuxt', '@vueuse/nuxt', '@nuxt/eslint', '@vue-macros/nuxt', '@pinia/nuxt'],
|
|
eslint: {
|
|
config: {
|
|
stylistic: {
|
|
quoteProps: 'as-needed',
|
|
},
|
|
},
|
|
},
|
|
app: {
|
|
head: {
|
|
style: [
|
|
{
|
|
children: Object.entries(fonts)
|
|
.map(([className, fontFamily]) => /* css */ `.${className} { font-family: '${fontFamily.name}', monospace; }`)
|
|
.join('\n'),
|
|
},
|
|
],
|
|
link: [
|
|
{
|
|
rel: 'preconnect',
|
|
href: 'https://fonts.bunny.net',
|
|
},
|
|
{
|
|
rel: 'stylesheet',
|
|
href: `https://fonts.bunny.net/css?family=${Object.values(fonts).map(({ link }) => link).join('|')}`,
|
|
},
|
|
],
|
|
script: [
|
|
{
|
|
type: 'text/javascript',
|
|
innerHTML: /* js */ `
|
|
// Function to get a cookie value by name
|
|
function getCookie(name) {
|
|
const nameEQ = name + "=";
|
|
const ca = document.cookie.split(';');
|
|
for (let i = 0; i < ca.length; i++) {
|
|
let c = ca[i];
|
|
while (c.charAt(0) === ' ') c = c.substring(1, c.length);
|
|
if (c.indexOf(nameEQ) === 0) return c.substring(nameEQ.length, c.length);
|
|
}
|
|
return null;
|
|
}
|
|
|
|
// Function to set a cookie with a name, value, and optional expiration days
|
|
function setCookie(name, value, days) {
|
|
let expires = "";
|
|
if (days) {
|
|
const date = new Date();
|
|
date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
|
|
expires = "; expires=" + date.toUTCString();
|
|
}
|
|
document.cookie = name + "=" + (value || "") + expires + "; path=/";
|
|
}
|
|
|
|
const theme = getCookie('theme');
|
|
|
|
// If no theme cookie exists, set it to 'catppuccin-mocha'
|
|
if (!theme) {
|
|
setCookie('theme', 'catppuccin-mocha');
|
|
document.body.classList.add('catppuccin-mocha');
|
|
} else {
|
|
document.body.classList.add(theme); // Apply the existing theme class
|
|
}
|
|
|
|
// Retrieve the font value from cookies
|
|
const font = getCookie('font');
|
|
|
|
// If no font cookie exists, set it to 'jetbrains-mono'
|
|
if (!font) {
|
|
setCookie('font', 'jetbrains-mono');
|
|
document.body.classList.add('jetbrains-mono');
|
|
} else {
|
|
document.body.classList.add(font); // Apply the existing font class
|
|
}
|
|
`,
|
|
tagPosition: 'bodyClose',
|
|
},
|
|
],
|
|
},
|
|
},
|
|
})
|