mirror of
https://github.com/Sevichecc/Urara-Blog.git
synced 2025-04-30 04:19:31 +08:00
merge with upsteam 1ad522ad69
This commit is contained in:
parent
7933868ed4
commit
abf0af9d0a
9 changed files with 57 additions and 191 deletions
|
@ -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
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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)
|
||||
</script>
|
||||
|
||||
<svelte:head>
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
|
||||
<script lang="ts">
|
||||
import { onMount, onDestroy } from 'svelte'
|
||||
import Tree from '$lib/components/post_toc_tree.svelte'
|
||||
export let toc: Urara.Post.Toc[]
|
||||
|
||||
let intersecting: string[] = []
|
||||
|
@ -34,7 +33,7 @@
|
|||
// @ts-ignore: Cannot find name 'headingsObserver'
|
||||
if (typeof headingsObserver !== 'undefined') headingsObserver.disconnect()
|
||||
// @ts-ignore: Cannot find name 'articleObserver'
|
||||
if (typeof headingsObserver !== 'undefined') articleObserver.disconnect()
|
||||
if (typeof articleObserver !== 'undefined') articleObserver.disconnect()
|
||||
})
|
||||
|
||||
$: if (intersecting.length > 0) bordered = intersecting
|
||||
|
@ -53,16 +52,28 @@
|
|||
aria-label="TableOfContent"
|
||||
dir="rtl"
|
||||
class="max-h-[calc(100vh-12rem)] overflow-y-hidden hover:overflow-y-auto">
|
||||
<Tree
|
||||
toc={toc.reduce(
|
||||
(acc, heading) => {
|
||||
let parent = acc
|
||||
// @ts-ignore Type 'Toc | undefined' is not assignable to type 'Toc.' ts(2322)
|
||||
while (parent.depth + 1 < heading.depth) parent = parent.children.at(-1)
|
||||
parent.children = [...(parent.children ?? []), { ...heading, children: [] }]
|
||||
return acc
|
||||
},
|
||||
{ depth: toc[0].depth - 1, children: [] }
|
||||
)} />
|
||||
<ul dir="ltr" id="toc-list-root">
|
||||
{#each toc as { depth, title, slug }}
|
||||
<li id={`toc-item-${slug}`} class="flex flex-col">
|
||||
<span
|
||||
dir="ltr"
|
||||
on:click={() =>
|
||||
// @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}
|
||||
</span>
|
||||
</li>
|
||||
{/each}
|
||||
</ul>
|
||||
</nav>
|
||||
</aside>
|
||||
</aside>
|
|
@ -1,33 +0,0 @@
|
|||
<script lang="ts">
|
||||
export let toc: Urara.Post.Toc
|
||||
const { title, slug, depth, children } = toc
|
||||
</script>
|
||||
|
||||
{#if title}
|
||||
<span
|
||||
dir="ltr"
|
||||
on:click={() =>
|
||||
// @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}
|
||||
</span>
|
||||
{/if}
|
||||
{#if children}
|
||||
<ul dir="ltr" id={`toc-list-${slug ?? 'root'}`}>
|
||||
{#each children as child}
|
||||
<li id={`toc-item-${child.slug}`} class="flex flex-col">
|
||||
<svelte:self toc={child} />
|
||||
</li>
|
||||
{/each}
|
||||
</ul>
|
||||
{/if}
|
|
@ -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',
|
||||
|
|
|
@ -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())
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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) }
|
||||
}
|
||||
|
|
|
@ -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-*']
|
||||
}
|
||||
})
|
||||
]
|
||||
})
|
||||
|
|
Loading…
Reference in a new issue