sync(upstream): ⬆️ deps, style and feat
This commit is contained in:
parent
e7fe451583
commit
316919f4b1
|
@ -1,20 +1,37 @@
|
|||
{
|
||||
"root": true,
|
||||
"extends": [
|
||||
"eslint:recommended",
|
||||
"plugin:@typescript-eslint/recommended",
|
||||
"plugin:svelte/recommended",
|
||||
"prettier"
|
||||
],
|
||||
"parser": "@typescript-eslint/parser",
|
||||
"extends": ["eslint:recommended", "plugin:@typescript-eslint/recommended", "prettier"],
|
||||
"plugins": ["svelte3", "@typescript-eslint"],
|
||||
"ignorePatterns": ["*.cjs"],
|
||||
"overrides": [{ "files": ["*.svelte"], "processor": "svelte3/svelte3" }],
|
||||
"settings": {
|
||||
"svelte3/typescript": true
|
||||
},
|
||||
"plugins": [
|
||||
"@typescript-eslint",
|
||||
"svelte"
|
||||
],
|
||||
"parserOptions": {
|
||||
"sourceType": "module",
|
||||
"ecmaVersion": 2019
|
||||
"ecmaVersion": 2020,
|
||||
"extraFileExtensions": [
|
||||
".svelte"
|
||||
]
|
||||
},
|
||||
"env": {
|
||||
"browser": true,
|
||||
"es2017": true,
|
||||
"node": true
|
||||
}
|
||||
},
|
||||
"overrides": [
|
||||
{
|
||||
"files": [
|
||||
"*.svelte"
|
||||
],
|
||||
"parser": "svelte-eslint-parser",
|
||||
"parserOptions": {
|
||||
"parser": "@typescript-eslint/parser"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -23,5 +23,4 @@ src/routes/**/+page.md
|
|||
src/routes/post/+page.svelte
|
||||
src/routes/talk/+page.svelte
|
||||
src/static
|
||||
*.config.js
|
||||
urara.js
|
|
@ -9,5 +9,19 @@
|
|||
"trailingComma": "none",
|
||||
"bracketSpacing": true,
|
||||
"bracketSameLine": true,
|
||||
"htmlWhitespaceSensitivity": "ignore"
|
||||
"htmlWhitespaceSensitivity": "ignore",
|
||||
"plugins": [
|
||||
"prettier-plugin-svelte"
|
||||
],
|
||||
"pluginSearchDirs": [
|
||||
"."
|
||||
],
|
||||
"overrides": [
|
||||
{
|
||||
"files": "*.svelte",
|
||||
"options": {
|
||||
"parser": "svelte"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
|
@ -1,15 +1,9 @@
|
|||
/* eslint-disable @typescript-eslint/no-explicit-any */
|
||||
|
||||
// mdsvex config type
|
||||
import type { MdsvexOptions } from 'mdsvex'
|
||||
|
||||
// rehype plugins
|
||||
import rehypeSlug from 'rehype-slug'
|
||||
import rehypeAutolinkHeadings from 'rehype-autolink-headings'
|
||||
import rehypeExternalLinks from 'rehype-external-links'
|
||||
|
||||
// urara remark plugins
|
||||
import type { Node, Data } from 'unist'
|
||||
import { parse, join } from 'node:path'
|
||||
import { visit } from 'unist-util-visit'
|
||||
import { toString } from 'mdast-util-to-string'
|
||||
|
@ -24,41 +18,42 @@ import { renderCodeToHTML, runTwoSlash, createShikiHighlighter } from 'shiki-two
|
|||
|
||||
const remarkUraraFm =
|
||||
() =>
|
||||
(tree: Node<Data>, { data, filename }: { data: { fm?: Record<string, unknown> }; filename?: string }) => {
|
||||
const filepath = filename ? filename.split('/src/routes')[1] : 'unknown'
|
||||
const { dir, name } = parse(filepath)
|
||||
if (!data.fm) data.fm = {}
|
||||
// Generate slug & path
|
||||
data.fm.slug = filepath
|
||||
data.fm.path = join(dir, `/${name}`.replace('/+page', '').replace('.svelte', ''))
|
||||
// Generate ToC
|
||||
if (data.fm.toc !== false) {
|
||||
const [slugs, toc]: [slugs: Slugger, toc: { depth: number; title: string; slug: string }[]] = [new Slugger(), []]
|
||||
visit(tree, 'heading', (node: { depth: number }) => {
|
||||
toc.push({
|
||||
depth: node.depth,
|
||||
title: toString(node),
|
||||
slug: slugs.slug(toString(node), false)
|
||||
})
|
||||
(tree, { data, filename }) => {
|
||||
const filepath = filename ? filename.split('/src/routes')[1] : 'unknown'
|
||||
const { dir, name } = parse(filepath)
|
||||
if (!data.fm) data.fm = {}
|
||||
// Generate slug & path
|
||||
data.fm.slug = filepath
|
||||
data.fm.path = join(dir, `/${name}`.replace('/+page', '').replace('.svelte', ''))
|
||||
// Generate ToC
|
||||
if (data.fm.toc !== false) {
|
||||
const [slugs, toc] = [new Slugger(), []]
|
||||
visit(tree, 'heading', node => {
|
||||
toc.push({
|
||||
depth: node.depth,
|
||||
title: toString(node),
|
||||
slug: slugs.slug(toString(node), false)
|
||||
})
|
||||
if (toc.length > 0) data.fm.toc = toc
|
||||
else data.fm.toc = false
|
||||
}
|
||||
})
|
||||
if (toc.length > 0) data.fm.toc = toc
|
||||
else data.fm.toc = false
|
||||
}
|
||||
}
|
||||
|
||||
// Better type definitions needed
|
||||
const remarkUraraSpoiler = () => (tree: Node<Data>) =>
|
||||
visit(tree, 'paragraph', (node: any) => {
|
||||
const remarkUraraSpoiler = () => tree =>
|
||||
visit(tree, 'paragraph', node => {
|
||||
const { children } = node
|
||||
const text = children[0].value
|
||||
const re = /\|\|(.{1,}?)\|\|/g
|
||||
if (re.test(children[0].value)) {
|
||||
children[0].type = 'html'
|
||||
children[0].value = text.replace(re, (_match: unknown, p1: string) => `<span class="spoiler">${p1}</span>`)
|
||||
children[0].value = text.replace(re, (_match, p1) => `<span class="spoiler">${p1}</span>`)
|
||||
}
|
||||
return node
|
||||
})
|
||||
|
||||
/** @type {import("mdsvex").MdsvexOptions} */
|
||||
export default {
|
||||
extensions: ['.svelte.md', '.md'],
|
||||
smartypants: {
|
||||
|
@ -69,18 +64,17 @@ export default {
|
|||
},
|
||||
highlight: {
|
||||
highlighter: async (code, lang, meta) => {
|
||||
let fence: any
|
||||
let twoslash: any
|
||||
let fence, twoslash
|
||||
try {
|
||||
fence = parseFence(lex([lang, meta].filter(Boolean).join(' ')))
|
||||
} catch (error) {
|
||||
throw new Error(`Could not parse the codefence for this code sample \n${code}`)
|
||||
}
|
||||
if (fence?.twoslash === true) twoslash = runTwoSlash(code, lang as string)
|
||||
if (fence?.twoslash === true) twoslash = runTwoSlash(code, lang)
|
||||
return `{@html \`${escapeSvelte(
|
||||
renderCodeToHTML(
|
||||
code,
|
||||
lang as string,
|
||||
lang,
|
||||
fence ?? {},
|
||||
{ themeName: 'material-default' },
|
||||
await createShikiHighlighter({ theme: 'material-default' }),
|
||||
|
@ -97,12 +91,12 @@ export default {
|
|||
target: 'mdsvex',
|
||||
autofill: {
|
||||
provider: 'fs',
|
||||
path: (path: string) => path.replace('/src/routes/', '/urara/')
|
||||
path: path => path.replace('/src/routes/', '/urara/')
|
||||
},
|
||||
strict: {
|
||||
media: {
|
||||
type: 'string',
|
||||
array: false,
|
||||
array: false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -112,7 +106,7 @@ export default {
|
|||
[remarkFootnotes, { inlineNotes: true }]
|
||||
],
|
||||
rehypePlugins: [
|
||||
rehypeSlug as any,
|
||||
rehypeSlug,
|
||||
[rehypeAutolinkHeadings, { behavior: 'wrap' }],
|
||||
[
|
||||
rehypeExternalLinks,
|
||||
|
@ -122,6 +116,4 @@ export default {
|
|||
}
|
||||
]
|
||||
]
|
||||
} as MdsvexOptions
|
||||
|
||||
/* eslint-enable @typescript-eslint/no-explicit-any */
|
||||
}
|
68
package.json
68
package.json
|
@ -15,49 +15,48 @@
|
|||
"urara:watch": "node urara.js watch",
|
||||
"kit:dev": "cross-env NODE_OPTIONS=--max_old_space_size=7680 vite dev",
|
||||
"kit:build": "cross-env NODE_OPTIONS=--max_old_space_size=7680 vite build",
|
||||
"dev:parallel": "npm-run-all -p -r tsc:watch urara:watch \"kit:dev {@} \" --",
|
||||
"dev": "npm-run-all -s tsc \"dev:parallel {@} \" --",
|
||||
"build": "npm-run-all -s tsc urara:build kit:build clean",
|
||||
"dev:parallel": "run-p -r tsc:watch urara:watch \"kit:dev {@} \" --",
|
||||
"dev": "run-s tsc \"dev:parallel {@} \" --",
|
||||
"build": "run-s tsc urara:build kit:build clean",
|
||||
"preview": "vite preview",
|
||||
"start": "cross-env ADAPTER=node pnpm build && node build",
|
||||
"check": "svelte-check --tsconfig ./tsconfig.json",
|
||||
"check:watch": "svelte-check --tsconfig ./tsconfig.json --watch",
|
||||
"lint": "prettier --check --plugin-search-dir=. . && eslint --ignore-path .gitignore .",
|
||||
"format": "prettier --write --plugin-search-dir=. ."
|
||||
},
|
||||
"devDependencies": {
|
||||
"@iconify-json/heroicons-outline": "^1.1.7",
|
||||
"@iconify-json/heroicons-solid": "^1.1.8",
|
||||
"@iconify-json/simple-icons": "^1.1.40",
|
||||
"@sveltejs/adapter-auto": "^1.0.0",
|
||||
"@sveltejs/adapter-node": "^1.1.0",
|
||||
"@iconify-json/heroicons-outline": "^1.1.6",
|
||||
"@iconify-json/heroicons-solid": "^1.1.7",
|
||||
"@sveltejs/adapter-netlify": "^2.0.7",
|
||||
"@sveltejs/adapter-static": "^2.0.2",
|
||||
"@sveltejs/adapter-vercel": "^2.4.3",
|
||||
"@sveltejs/kit": "^1.19.0",
|
||||
"@tailwindcss/typography": "^0.5.9",
|
||||
"@types/node": "^20.2.5",
|
||||
"@types/unist": "^2.0.6",
|
||||
"@typescript-eslint/eslint-plugin": "^5.59.7",
|
||||
"@typescript-eslint/parser": "^5.59.7",
|
||||
"@unocss/extractor-svelte": "^0.52.4",
|
||||
"@sveltejs/adapter-auto": "^2.1.0",
|
||||
"@sveltejs/adapter-node": "^1.3.1",
|
||||
"@sveltejs/adapter-static": "^2.0.3",
|
||||
"@sveltejs/kit": "^1.25.0",
|
||||
"@tailwindcss/typography": "^0.5.10",
|
||||
"@types/node": "^20.6.0",
|
||||
"@types/unist": "^3.0.0",
|
||||
"@typescript-eslint/eslint-plugin": "^6.7.0",
|
||||
"@typescript-eslint/parser": "^6.7.0",
|
||||
"@unocss/extractor-svelte": "^0.55.7",
|
||||
"@vite-pwa/sveltekit": "^0.1.3",
|
||||
"chalk": "^5.2.0",
|
||||
"chalk": "^5.3.0",
|
||||
"chokidar": "^3.5.3",
|
||||
"cross-env": "^7.0.3",
|
||||
"daisyui": "^2.51.6",
|
||||
"eslint": "^8.41.0",
|
||||
"eslint-config-prettier": "^8.8.0",
|
||||
"eslint-plugin-svelte3": "^4.0.0",
|
||||
"daisyui": "^3.7.3",
|
||||
"eslint": "^8.49.0",
|
||||
"eslint-config-prettier": "^9.0.0",
|
||||
"eslint-plugin-svelte": "^2.33.1",
|
||||
"fenceparser": "^2.2.0",
|
||||
"fff-flavored-frontmatter": "1.0.0-alpha.1",
|
||||
"github-slugger": "^2.0.0",
|
||||
"mdast-util-to-string": "^3.2.0",
|
||||
"mdsvex": "^0.10.6",
|
||||
"mdsvex": "^0.11.0",
|
||||
"npm-run-all": "^4.1.5",
|
||||
"postcss": "^8.4.23",
|
||||
"postcss": "^8.4.29",
|
||||
"postcss-lightningcss": "^0.7.0",
|
||||
"prettier": "^2.8.8",
|
||||
"prettier-plugin-svelte": "^2.10.0",
|
||||
"prettier": "^3.0.3",
|
||||
"prettier-plugin-svelte": "^3.0.3",
|
||||
"rehype-autolink-headings": "^6.1.1",
|
||||
"rehype-external-links": "^2.1.0",
|
||||
"rehype-slug": "^5.1.0",
|
||||
|
@ -66,16 +65,17 @@
|
|||
"remark-footnotes": "~2.0.0",
|
||||
"svelte-bricks": "^0.2.0",
|
||||
"shiki-twoslash": "^3.1.2",
|
||||
"svelte": "^3.59.1",
|
||||
"svelte-check": "^3.4.3",
|
||||
"svelte": "^4.2.0",
|
||||
"svelte-check": "^3.5.1",
|
||||
"svelte-eslint-parser": "^0.33.0",
|
||||
"svelte-preprocess": "^5.0.4",
|
||||
"sveltekit-embed": "^0.0.13",
|
||||
"tailwindcss": "^3.3.2",
|
||||
"tslib": "^2.5.2",
|
||||
"sveltekit-embed": "^0.0.14",
|
||||
"tailwindcss": "^3.3.3",
|
||||
"tslib": "^2.6.2",
|
||||
"typescript": "^4.9.5",
|
||||
"unist-util-visit": "^4.1.2",
|
||||
"unocss": "^0.52.4",
|
||||
"vite": "^4.3.9",
|
||||
"unocss": "^0.55.7",
|
||||
"vite": "^4.4.9",
|
||||
"vite-plugin-pwa": "^0.14.7",
|
||||
"workbox-build": "^6.6.0",
|
||||
"workbox-window": "^6.6.0"
|
||||
|
@ -85,4 +85,4 @@
|
|||
"vite>rollup": "^3.10.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
1828
pnpm-lock.yaml
1828
pnpm-lock.yaml
File diff suppressed because it is too large
Load Diff
|
@ -1,4 +1,4 @@
|
|||
<!DOCTYPE html>
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head prefix="og: https://ogp.me/ns#">
|
||||
<meta charset="utf-8" />
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
<meta property="og:description" content={post.summary} />
|
||||
{/if}
|
||||
{#if post.image}
|
||||
<meta property="og:image" content={site.protocol + site.domain + post.image} />
|
||||
<meta property="og:image" content={(post.image.startsWith('http') ? '' : site.protocol + site.domain) + post.image} />
|
||||
<meta name="twitter:card" content="summary_large_image" />
|
||||
{:else}
|
||||
<meta property="og:image" content={maskable['512'].src ?? any['512'].src ?? any['192'].src} />
|
||||
|
|
|
@ -54,7 +54,7 @@
|
|||
<header
|
||||
id="header"
|
||||
class:-translate-y-32={!pin && scrollY > 0}
|
||||
class="fixed z-50 w-screen transition-all duration-500 ease-in-out border-b-2 border-transparent max-h-[4.125rem] {scrollY >
|
||||
class="fixed z-50 w-full transition-all duration-500 ease-in-out border-b-2 border-transparent max-h-[4.125rem] {scrollY >
|
||||
32 && 'backdrop-blur !border-base-content/10 bg-base-100/30 md:bg-base-200/30'}">
|
||||
{#if !search}
|
||||
<div in:fly={{ x: -50, duration: 300, delay: 300 }} out:fly={{ x: -50, duration: 300 }} class="navbar">
|
||||
|
|
|
@ -28,8 +28,8 @@ const render = (posts = genPosts({ postHtml: true, postLimit: feed.limit, filter
|
|||
<id>${site.protocol + site.domain + post.path}</id>
|
||||
<published>${new Date(post.published ?? post.created).toJSON()}</published>
|
||||
<updated>${new Date(post.updated ?? post.published ?? post.created).toJSON()}</updated>${
|
||||
post.summary ? `\n <summary type="html"><![CDATA[${post.summary.toString()}]]></summary>` : ''
|
||||
}
|
||||
post.summary ? `\n <summary type="html"><![CDATA[${post.summary.toString()}]]></summary>` : ''
|
||||
}
|
||||
<content type="html">
|
||||
<![CDATA[${post.html}]]>
|
||||
</content>${post.tags
|
||||
|
|
41
svelte.config.js
Normal file
41
svelte.config.js
Normal file
|
@ -0,0 +1,41 @@
|
|||
// svelte adapter
|
||||
import adapterAuto from '@sveltejs/adapter-auto'
|
||||
import adapterNode from '@sveltejs/adapter-node'
|
||||
import adapterStatic from '@sveltejs/adapter-static'
|
||||
// svelte preprocessor
|
||||
import { mdsvex } from 'mdsvex'
|
||||
import mdsvexConfig from './mdsvex.config.js'
|
||||
import { vitePreprocess } from '@sveltejs/kit/vite'
|
||||
|
||||
const adapter = {
|
||||
auto: adapterAuto(),
|
||||
node: adapterNode(),
|
||||
static: adapterStatic({
|
||||
pages: 'build',
|
||||
assets: 'build',
|
||||
fallback: undefined
|
||||
})
|
||||
}
|
||||
|
||||
/** @type {import("@svletejs/kit".Config)} */
|
||||
export default {
|
||||
extensions: ['.svelte', ...mdsvexConfig.extensions],
|
||||
preprocess: [mdsvex(mdsvexConfig), vitePreprocess()],
|
||||
kit: {
|
||||
adapter:
|
||||
process.env.ADAPTER
|
||||
? adapter[process.env.ADAPTER.toLowerCase()]
|
||||
: Object.keys(process.env).some(key => ['VERCEL', 'CF_PAGES', 'NETLIFY', 'GITHUB_ACTION_REPOSITORY', 'SST'].includes(key))
|
||||
? adapter['auto']
|
||||
: adapter['static'],
|
||||
prerender: {
|
||||
handleMissingId: 'warn'
|
||||
},
|
||||
csp: {
|
||||
mode: 'auto',
|
||||
directives: {
|
||||
'style-src': ['self', 'unsafe-inline', 'https://giscus.app']
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,35 +0,0 @@
|
|||
// sveltekit config type
|
||||
import type { Config } from '@sveltejs/kit'
|
||||
// svelte adapter
|
||||
import adapterVercel from '@sveltejs/adapter-vercel'
|
||||
import adapterNetlify from '@sveltejs/adapter-netlify'
|
||||
import adapterStatic from '@sveltejs/adapter-static'
|
||||
// svelte preprocessor
|
||||
import { mdsvex } from 'mdsvex'
|
||||
import mdsvexConfig from './mdsvex.config.js'
|
||||
import { vitePreprocess } from '@sveltejs/kit/vite'
|
||||
|
||||
export default {
|
||||
extensions: ['.svelte', ...(mdsvexConfig.extensions as string[])],
|
||||
preprocess: [mdsvex(mdsvexConfig), vitePreprocess()],
|
||||
kit: {
|
||||
adapter: Object.keys(process.env).some(key => key === 'VERCEL')
|
||||
? adapterVercel()
|
||||
: Object.keys(process.env).some(key => key === 'NETLIFY')
|
||||
? adapterNetlify()
|
||||
: adapterStatic({
|
||||
pages: 'build',
|
||||
assets: 'build',
|
||||
fallback: undefined
|
||||
}),
|
||||
prerender: {
|
||||
handleMissingId: 'warn'
|
||||
},
|
||||
csp: {
|
||||
mode: 'auto',
|
||||
directives: {
|
||||
'style-src': ['self', 'unsafe-inline', 'https://giscus.app']
|
||||
}
|
||||
}
|
||||
}
|
||||
} as Config
|
|
@ -1,9 +1,9 @@
|
|||
import { theme } from './src/lib/config/general'
|
||||
// @ts-ignore Could not find a declaration file for module '@tailwindcss/typography'.
|
||||
import type { Config } from 'tailwindcss'
|
||||
import typography from '@tailwindcss/typography'
|
||||
// @ts-ignore Could not find a declaration file for module 'daisyui'.
|
||||
import daisyui from 'daisyui'
|
||||
|
||||
import { theme } from './src/lib/config/general'
|
||||
|
||||
export default {
|
||||
content: ['./src/**/*.{html,md,js,svelte,ts}'],
|
||||
theme: {
|
||||
|
@ -27,4 +27,4 @@ export default {
|
|||
},
|
||||
plugins: [typography, daisyui],
|
||||
daisyui: { themes: theme.map(({ name }) => name) }
|
||||
}
|
||||
} satisfies Config
|
||||
|
|
|
@ -7,5 +7,5 @@
|
|||
"skipLibCheck": true,
|
||||
"allowSyntheticDefaultImports": true
|
||||
},
|
||||
"include": ["urara.ts", "svelte.config.ts", "mdsvex.config.ts"]
|
||||
"include": ["urara.ts"]
|
||||
}
|
||||
|
|
|
@ -9,6 +9,7 @@ import { SvelteKitPWA } from '@vite-pwa/sveltekit'
|
|||
// postcss & tailwindcss
|
||||
import TailwindCSS from 'tailwindcss'
|
||||
import tailwindConfig from './tailwind.config'
|
||||
// @ts-expect-error ts(7016)
|
||||
import LightningCSS from 'postcss-lightningcss'
|
||||
|
||||
export default defineConfig({
|
||||
|
@ -26,7 +27,7 @@ export default defineConfig({
|
|||
},
|
||||
plugins: [
|
||||
UnoCSS({
|
||||
include: [/\.svelte$/, /\.md?$/, /\.ts$/],
|
||||
content: { pipeline: { include: [/\.svelte$/, /\.md?$/, /\.ts$/] } },
|
||||
extractors: [extractorSvelte],
|
||||
presets: [
|
||||
presetTagify({
|
||||
|
|
Loading…
Reference in New Issue
Block a user