diff --git a/mdsvex.config.ts b/mdsvex.config.ts index 3287664e..6e417835 100644 --- a/mdsvex.config.ts +++ b/mdsvex.config.ts @@ -41,7 +41,8 @@ const remarkUraraFm = slug: slugs.slug(toString(node), false) }) }) - data.fm.toc = toc + if (toc.length > 0) data.fm.toc = toc + else data.fm.toc = false } } diff --git a/src/lib/components/header.svelte b/src/lib/components/header.svelte index bcfb6260..4253070b 100644 --- a/src/lib/components/header.svelte +++ b/src/lib/components/header.svelte @@ -41,7 +41,8 @@ if (browser) currentTheme = - localStorage.getItem('theme') ?? (window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light') + localStorage.getItem('theme') ?? + (window.matchMedia('(prefers-color-scheme: dark)').matches ? theme?.[1].name : theme[0].name ?? theme[0].name) diff --git a/src/lib/components/post_toc.svelte b/src/lib/components/post_toc.svelte index 3049654b..3c8017b5 100644 --- a/src/lib/components/post_toc.svelte +++ b/src/lib/components/post_toc.svelte @@ -4,7 +4,6 @@ - -{#if title} - - // @ts-ignore Object is possibly 'null'. ts(2531) - document.getElementById(slug).scrollIntoView({ behavior: 'smooth' })} - id={`toc-link-${slug}`} - class="cursor-pointer border-l-4 border-transparent transition-all hover:border-primary hover:bg-base-content hover:bg-opacity-10 active:bg-primary active:text-primary-content active:font-bold pr-4 {depth <= - 2 - ? 'py-3' - : 'py-2'}" - class:pl-4={depth <= 2} - class:pl-8={depth === 3} - class:pl-12={depth === 4} - class:pl-16={depth === 5} - class:pl-20={depth === 6}> - {title} - -{/if} -{#if children} - -{/if} diff --git a/src/lib/config/general.ts b/src/lib/config/general.ts index 69763cae..fe9c5979 100644 --- a/src/lib/config/general.ts +++ b/src/lib/config/general.ts @@ -2,120 +2,52 @@ import type { ThemeConfig, HeadConfig, HeaderConfig, FooterConfig, DateConfig, F export const theme: ThemeConfig = [ { - name: 'lemonade', + name: 'garden', text: 'Light' }, { - name: 'night', + name: 'dracula', text: 'Dark' }, - { - name: 'cupcake', - text: 'Cupcake' - }, - { - name: 'bumblebee', - text: 'Bumblebee' - }, - { - name: 'emerald', - text: 'Emerald' - }, - { - name: 'corporate', - text: 'Corporate' - }, { name: 'valentine', text: 'Valentine' }, + { + name: 'aqua', + text: 'Aqua' + }, { name: 'synthwave', text: 'Synthwave' }, { - name: 'retro', - text: 'Retro' - }, - { - name: 'cyberpunk', - text: 'Cyberpunk' - }, - { - name: 'halloween', - text: 'Halloween' - }, - { - name: 'garden', - text: 'Garden' - }, - { - name: 'forest', - text: 'Forest' - }, - { - name: 'aqua', - text: 'Aqua' + name: 'night', + text: 'Night' }, { name: 'lofi', text: 'Lo-Fi' }, { - name: 'pastel', - text: 'Pastel' + name: 'lemonade', + text: 'Lemonade' }, { - name: 'fantasy', - text: 'Fantasy' - }, - { - name: 'wirefream', - text: 'Wireframe' - }, - { - name: 'black', - text: 'Black' - }, - { - name: 'luxury', - text: 'Luxury' - }, - { - name: 'dracula', - text: 'Dracula' + name: 'cupcake', + text: 'Cupcake' }, { name: 'cmyk', text: 'CMYK' }, { - name: 'autumn', - text: 'Autumn' + name: 'retro', + text: 'Retro' }, { - name: 'business', - text: 'Business' - }, - { - name: 'acid', - text: 'Acid' - }, - // { - // name: 'lemonade', - // text: 'Lemonade' - // }, - // { - // name: 'night', - // text: '🌃 Night' - // }, - { - name: 'coffee', - text: 'Coffee' - }, - { - name: 'winter', - text: 'Winter' + name: 'black', + text: 'Black' } ] @@ -184,26 +116,6 @@ export const footer: FooterConfig = { } export const date: DateConfig = { - // toPublishedString: { - // locales: 'en-US', - // options: { - // year: 'numeric', - // weekday: 'short', - // month: 'short', - // day: 'numeric', - // timeZone: 'Asia/Shanghai' - // } - // }, - // toUpdatedString: { - // locales: 'en-US', - // options: { - // year: 'numeric', - // weekday: 'short', - // month: 'short', - // day: 'numeric', - // timeZone: 'Asia/Shanghai' - // } - // }, locales: 'en-US', options: { year: 'numeric', diff --git a/src/routes/+layout.ts b/src/routes/+layout.ts index 6d5ca307..2b28436b 100644 --- a/src/routes/+layout.ts +++ b/src/routes/+layout.ts @@ -1,5 +1,9 @@ import type { LayoutLoad } from './$types' export const prerender = true +export const trailingSlash = + !Object.keys(process.env).some(key => ['VERCEL', 'CF_PAGES', 'NETLIFY'].includes(key)) && process.env.ADAPTER !== 'node' + ? 'always' + : undefined export const load: LayoutLoad = async ({ url, fetch }) => ({ path: url.pathname, res: await fetch('/posts.json').then(res => res.json()) diff --git a/svelte.config.ts b/svelte.config.ts index 6231f723..780348a1 100644 --- a/svelte.config.ts +++ b/svelte.config.ts @@ -8,7 +8,6 @@ import adapterStatic from '@sveltejs/adapter-static' import { mdsvex } from 'mdsvex' import mdsvexConfig from './mdsvex.config.js' import preprocess from 'svelte-preprocess' -import { prerendered } from '$service-worker' const defineConfig = (config: Config) => config diff --git a/tailwind.config.ts b/tailwind.config.ts index 202433a3..00006ade 100644 --- a/tailwind.config.ts +++ b/tailwind.config.ts @@ -1,3 +1,4 @@ +import { theme } from './src/lib/config/general' // @ts-ignore Could not find a declaration file for module '@tailwindcss/typography'. import typography from '@tailwindcss/typography' // @ts-ignore Could not find a declaration file for module 'daisyui'. @@ -5,41 +6,7 @@ import daisyui from 'daisyui' export default { content: ['./src/**/*.{html,md,js,svelte,ts}'], - theme: { - extend: {} - }, + theme: { extend: {} }, plugins: [typography, daisyui], - daisyui: { - themes: [ - 'light', - 'dark', - 'cupcake', - 'bumblebee', - 'emerald', - 'corporate', - 'synthwave', - 'retro', - 'cyberpunk', - 'valentine', - 'halloween', - 'garden', - 'forest', - 'aqua', - 'lofi', - 'pastel', - 'fantasy', - 'wireframe', - 'black', - 'luxury', - 'dracula', - 'cmyk', - 'autumn', - 'business', - 'acid', - 'lemonade', - 'night', - 'coffee', - 'winter' - ] - } + daisyui: { themes: theme.map(({ name }) => name) } } diff --git a/vite.config.ts b/vite.config.ts index 22befab9..20cfad4d 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -43,7 +43,11 @@ export default defineConfig({ SvelteKitPWA({ registerType: 'autoUpdate', manifest: false, - scope: '/' + scope: '/', + workbox: { + globPatterns: ['posts.json', '**/*.{js,css,html,svg,ico,png,webp,avif}'], + globIgnores: ['**/sw*', '**/workbox-*'] + } }) ] })