From 7809bf12c753bf7ea911fd5a83593a341efab3b2 Mon Sep 17 00:00:00 2001 From: biss Date: Tue, 1 Dec 2026 18:47:17 +0800 Subject: [PATCH] Standardize blog source formatting with Prettier --- .prettierrc.json | 11 + package-lock.json | 69 +++ package.json | 6 + public/js/external-links.js | 10 +- public/js/pwa.js | 45 +- public/js/random.js | 155 +++--- public/js/search/typesense-search.js | 234 +++++---- public/js/shuoshuo.js | 679 +++++++++++++------------ public/js/shuoshuoshouye.js | 216 ++++---- scripts/generate-abbrlinks.mjs | 4 +- scripts/version-service-worker.mjs | 15 +- site.config.mjs | 21 +- src/components/ArchiveTimeline.astro | 56 +- src/components/ArticleSidebar.astro | 127 +++-- src/components/CustomContextMenu.astro | 45 +- src/components/HitokotoCard.astro | 48 +- src/components/Pagination.astro | 17 +- src/components/PostCard.astro | 7 +- src/components/PostChangelog.astro | 28 +- src/components/PostCopyrightCard.astro | 50 +- src/components/PostSeries.astro | 53 +- src/components/SiteInfoCard.astro | 29 +- src/components/StatsChart.astro | 198 ++++--- src/components/TwikooComments.astro | 2 +- src/content.config.ts | 45 +- src/layouts/BaseLayout.astro | 211 ++++++-- src/lib/pagination.ts | 6 +- src/lib/posts.ts | 49 +- src/lib/remarkHexoLinkCards.mjs | 60 ++- src/pages/about.astro | 8 +- src/pages/api/posts.json.js | 5 +- src/pages/archives/index.astro | 25 +- src/pages/archives/page/[page].astro | 30 +- src/pages/atom.xml.js | 25 +- src/pages/categories/[category].astro | 3 +- src/pages/categories/index.astro | 25 +- src/pages/cc.astro | 6 +- src/pages/cookie.astro | 18 +- src/pages/go.astro | 5 +- src/pages/link.astro | 22 +- src/pages/posts/[slug].astro | 192 ++++--- src/pages/privacy.astro | 12 +- src/pages/rss.astro | 34 +- src/pages/shuoshuo.astro | 7 +- src/pages/tags/index.astro | 21 +- src/styles/site.css | 36 +- src/styles/site/01-base.css | 5 +- src/styles/site/02-navigation.css | 13 +- src/styles/site/03-overlays.css | 23 +- src/styles/site/04-layout.css | 7 +- src/styles/site/05-cards-sidebar.css | 14 +- src/styles/site/06-article-prose.css | 55 +- src/styles/site/07-post-comments.css | 14 +- src/styles/site/08-archives-stats.css | 3 +- src/styles/site/09-shuoshuo.css | 9 +- src/styles/site/10-pages.css | 6 +- src/styles/site/11-footer.css | 1 - src/styles/site/12-theme.css | 141 +++-- src/styles/site/13-responsive.css | 1 - src/styles/site/14-animations.css | 8 +- src/styles/site/15-reading-series.css | 132 ++++- src/styles/site/16-pwa.css | 90 +++- src/styles/site/17-revisions.css | 32 +- src/styles/site/18-worklog.css | 97 ++-- 64 files changed, 2239 insertions(+), 1382 deletions(-) create mode 100644 .prettierrc.json diff --git a/.prettierrc.json b/.prettierrc.json new file mode 100644 index 0000000..6f356b6 --- /dev/null +++ b/.prettierrc.json @@ -0,0 +1,11 @@ +{ + "plugins": ["prettier-plugin-astro"], + "singleQuote": true, + "printWidth": 100, + "overrides": [ + { + "files": "*.astro", + "options": { "parser": "astro" } + } + ] +} diff --git a/package-lock.json b/package-lock.json index b32240e..6a4179c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -15,8 +15,19 @@ "rehype-mathjax": "^7.1.0", "remark-math": "^6.0.0", "typesense": "^3.3.0" + }, + "devDependencies": { + "prettier": "3.10.1", + "prettier-plugin-astro": "0.14.1" } }, + "node_modules/@astrojs/compiler": { + "version": "2.13.1", + "resolved": "https://registry.npmjs.org/@astrojs/compiler/-/compiler-2.13.1.tgz", + "integrity": "sha512-f3FN83d2G/v32ipNClRKgYv30onQlMZX1vCeZMjPsMMPl1mDpmbl0+N5BYo4S/ofzqJyS5hvwacEo0CCVDn/Qg==", + "dev": true, + "license": "MIT" + }, "node_modules/@astrojs/compiler-binding": { "version": "0.5.3", "resolved": "https://registry.npmjs.org/@astrojs/compiler-binding/-/compiler-binding-0.5.3.tgz", @@ -5517,6 +5528,37 @@ "node": "^10 || ^12 || >=14" } }, + "node_modules/prettier": { + "version": "3.10.1", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.10.1.tgz", + "integrity": "sha512-70vp3ZUYoPlFbF9uiTdXHUUCGEIp7d4+6p+8DYbkm2jP7x/3i/paXVF6dopSI3zd/CEitrZN1rc4i85xWmmXlg==", + "dev": true, + "license": "MIT", + "bin": { + "prettier": "bin/prettier.cjs" + }, + "engines": { + "node": ">=14" + }, + "funding": { + "url": "https://github.com/prettier/prettier?sponsor=1" + } + }, + "node_modules/prettier-plugin-astro": { + "version": "0.14.1", + "resolved": "https://registry.npmjs.org/prettier-plugin-astro/-/prettier-plugin-astro-0.14.1.tgz", + "integrity": "sha512-RiBETaaP9veVstE4vUwSIcdATj6dKmXljouXc/DDNwBSPTp8FRkLGDSGFClKsAFeeg+13SB0Z1JZvbD76bigJw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@astrojs/compiler": "^2.9.1", + "prettier": "^3.0.0", + "sass-formatter": "^0.7.6" + }, + "engines": { + "node": "^14.15.0 || >=16.0.0" + } + }, "node_modules/prismjs": { "version": "1.30.0", "resolved": "https://registry.npmjs.org/prismjs/-/prismjs-1.30.0.tgz", @@ -5943,6 +5985,23 @@ "@rolldown/binding-win32-x64-msvc": "1.2.16" } }, + "node_modules/s.color": { + "version": "0.0.15", + "resolved": "https://registry.npmjs.org/s.color/-/s.color-0.0.15.tgz", + "integrity": "sha512-AUNrbEUHeKY8XsYr/DYpl+qk5+aM+DChopnWOPEzn8YKzOhv4l2zH6LzZms3tOZP3wwdOyc0RmTciyi46HLIuA==", + "dev": true, + "license": "MIT" + }, + "node_modules/sass-formatter": { + "version": "0.7.9", + "resolved": "https://registry.npmjs.org/sass-formatter/-/sass-formatter-0.7.9.tgz", + "integrity": "sha512-CWZ8XiSim+fJVG0cFLStwDvft1VI7uvXdCNJYXhDvowiv+DsbD1nXLiQ4zrE5UBvj5DWZJ93cwN0NX5PMsr1Pw==", + "dev": true, + "license": "MIT", + "dependencies": { + "suf-log": "^2.5.3" + } + }, "node_modules/satteri": { "version": "0.11.7", "resolved": "https://registry.npmjs.org/satteri/-/satteri-0.11.7.tgz", @@ -6202,6 +6261,16 @@ "inline-style-parser": "0.2.7" } }, + "node_modules/suf-log": { + "version": "2.5.3", + "resolved": "https://registry.npmjs.org/suf-log/-/suf-log-2.5.3.tgz", + "integrity": "sha512-KvC8OPjzdNOe+xQ4XWJV2whQA0aM1kGVczMQ8+dStAO6KfEB140JEVQ9dE76ONZ0/Ylf67ni4tILPJB41U0eow==", + "dev": true, + "license": "MIT", + "dependencies": { + "s.color": "0.0.15" + } + }, "node_modules/svgo": { "version": "4.1.0", "resolved": "https://registry.npmjs.org/svgo/-/svgo-4.1.0.tgz", diff --git a/package.json b/package.json index 020f508..7da8dc5 100644 --- a/package.json +++ b/package.json @@ -3,6 +3,8 @@ "version": "3.1.1", "private": true, "scripts": { + "format": "prettier --write \"*.mjs\" \"{public,scripts,src,workers}/**/*.{astro,css,js,mjs,ts}\"", + "format:check": "prettier --check \"*.mjs\" \"{public,scripts,src,workers}/**/*.{astro,css,js,mjs,ts}\"", "prebuild": "node scripts/generate-abbrlinks.mjs", "build": "astro build", "postbuild": "node scripts/version-service-worker.mjs", @@ -19,5 +21,9 @@ "rehype-mathjax": "^7.1.0", "remark-math": "^6.0.0", "typesense": "^3.3.0" + }, + "devDependencies": { + "prettier": "3.10.1", + "prettier-plugin-astro": "0.14.1" } } diff --git a/public/js/external-links.js b/public/js/external-links.js index 4c9ad82..acb5842 100644 --- a/public/js/external-links.js +++ b/public/js/external-links.js @@ -25,7 +25,15 @@ document.addEventListener('click', (event) => { const anchor = event.target.closest?.('a[href]'); if (!anchor) return; - if (event.defaultPrevented || event.button !== 0 || event.metaKey || event.ctrlKey || event.shiftKey || event.altKey) return; + if ( + event.defaultPrevented || + event.button !== 0 || + event.metaKey || + event.ctrlKey || + event.shiftKey || + event.altKey + ) + return; const externalUrl = getExternalUrl(anchor); if (!externalUrl) return; diff --git a/public/js/pwa.js b/public/js/pwa.js index 465f9cc..24bf90d 100644 --- a/public/js/pwa.js +++ b/public/js/pwa.js @@ -39,7 +39,13 @@ installPrompt = event; if (!installDismissedRecently()) { window.setTimeout(() => { - if (installPrompt) showToast('install', '安装 Bi\'s Blog', '添加到桌面,像应用一样打开并阅读缓存过的文章。', '立即安装'); + if (installPrompt) + showToast( + 'install', + "安装 Bi's Blog", + '添加到桌面,像应用一样打开并阅读缓存过的文章。', + '立即安装', + ); }, 2500); } }); @@ -69,7 +75,9 @@ close?.addEventListener('click', () => { if (toastMode === 'install') { - try { localStorage.setItem('pwa-install-dismissed-at', String(Date.now())); } catch {} + try { + localStorage.setItem('pwa-install-dismissed-at', String(Date.now())); + } catch {} } hideToast(); }); @@ -78,24 +86,27 @@ if (refreshing) window.location.reload(); }); - navigator.serviceWorker.register('/sw.js', { scope: '/' }).then((registration) => { - if (registration.waiting && navigator.serviceWorker.controller) { - waitingWorker = registration.waiting; - showToast('update', '发现新版本', '刷新后即可使用博客的最新内容和功能。', '立即更新'); - } + navigator.serviceWorker + .register('/sw.js', { scope: '/' }) + .then((registration) => { + if (registration.waiting && navigator.serviceWorker.controller) { + waitingWorker = registration.waiting; + showToast('update', '发现新版本', '刷新后即可使用博客的最新内容和功能。', '立即更新'); + } - registration.addEventListener('updatefound', () => { - const worker = registration.installing; - worker?.addEventListener('statechange', () => { - if (worker.state === 'installed' && navigator.serviceWorker.controller) { - waitingWorker = worker; - showToast('update', '发现新版本', '刷新后即可使用博客的最新内容和功能。', '立即更新'); - } + registration.addEventListener('updatefound', () => { + const worker = registration.installing; + worker?.addEventListener('statechange', () => { + if (worker.state === 'installed' && navigator.serviceWorker.controller) { + waitingWorker = worker; + showToast('update', '发现新版本', '刷新后即可使用博客的最新内容和功能。', '立即更新'); + } + }); }); + }) + .catch((error) => { + console.warn('PWA registration failed:', error); }); - }).catch((error) => { - console.warn('PWA registration failed:', error); - }); const params = new URLSearchParams(window.location.search); if (params.get('action') === 'search') { diff --git a/public/js/random.js b/public/js/random.js index 91d37b5..af0074f 100644 --- a/public/js/random.js +++ b/public/js/random.js @@ -1,14 +1,15 @@ function randomPost(trigger) { - const source = trigger instanceof Element - ? trigger - : document.activeElement?.closest?.('.nav-random, [onclick*="randomPost"]'); - const overlay = document.createElement('div'); - const reduceMotion = window.matchMedia?.('(prefers-reduced-motion: reduce)').matches; + const source = + trigger instanceof Element + ? trigger + : document.activeElement?.closest?.('.nav-random, [onclick*="randomPost"]'); + const overlay = document.createElement('div'); + const reduceMotion = window.matchMedia?.('(prefers-reduced-motion: reduce)').matches; - overlay.className = 'random-post-transition'; - overlay.setAttribute('role', 'status'); - overlay.setAttribute('aria-live', 'polite'); - overlay.innerHTML = ` + overlay.className = 'random-post-transition'; + overlay.setAttribute('role', 'status'); + overlay.setAttribute('aria-live', 'polite'); + overlay.innerHTML = `
@@ -16,78 +17,86 @@ function randomPost(trigger) {
`; - source?.classList.add('is-randomizing'); - source?.setAttribute('aria-busy', 'true'); - document.body.appendChild(overlay); - requestAnimationFrame(() => overlay.classList.add('is-visible')); + source?.classList.add('is-randomizing'); + source?.setAttribute('aria-busy', 'true'); + document.body.appendChild(overlay); + requestAnimationFrame(() => overlay.classList.add('is-visible')); - const finish = href => { - const delay = reduceMotion ? 80 : 1250; - window.setTimeout(() => { - location.href = href; - }, delay); - }; + const finish = (href) => { + const delay = reduceMotion ? 80 : 1250; + window.setTimeout(() => { + location.href = href; + }, delay); + }; - const startCardFlight = posts => { - if (reduceMotion) return; + const startCardFlight = (posts) => { + if (reduceMotion) return; - const flight = overlay.querySelector('.random-post-flight'); - if (!flight) return; + const flight = overlay.querySelector('.random-post-flight'); + if (!flight) return; - const candidates = posts - .filter(post => post && typeof post.href === 'string' && post.href.startsWith('/posts/')) - .map(post => ({ - title: typeof post.title === 'string' && post.title.trim() ? post.title.trim() : '\u672a\u547d\u540d\u6587\u7ae0', - meta: typeof post.category === 'string' && post.category.trim() ? post.category.trim() : '\u968f\u673a\u6587\u7ae0', - })); + const candidates = posts + .filter((post) => post && typeof post.href === 'string' && post.href.startsWith('/posts/')) + .map((post) => ({ + title: + typeof post.title === 'string' && post.title.trim() + ? post.title.trim() + : '\u672a\u547d\u540d\u6587\u7ae0', + meta: + typeof post.category === 'string' && post.category.trim() + ? post.category.trim() + : '\u968f\u673a\u6587\u7ae0', + })); - const pool = candidates.length ? candidates : [{ title: '\u968f\u673a\u6587\u7ae0', meta: '\u6b63\u5728\u62bd\u53d6' }]; - const count = Math.min(9, Math.max(5, pool.length)); + const pool = candidates.length + ? candidates + : [{ title: '\u968f\u673a\u6587\u7ae0', meta: '\u6b63\u5728\u62bd\u53d6' }]; + const count = Math.min(9, Math.max(5, pool.length)); - for (let index = 0; index < count; index += 1) { - const post = pool[Math.floor(Math.random() * pool.length)]; - const card = document.createElement('div'); - card.className = 'random-post-flying-card'; - card.style.setProperty('--flight-delay', `${index * 0.11}s`); - card.style.setProperty('--flight-y', `${-42 + Math.random() * 84}px`); - card.style.setProperty('--flight-rotate', `${-8 + Math.random() * 16}deg`); - const meta = document.createElement('small'); - const title = document.createElement('strong'); - meta.textContent = post.meta; - title.textContent = post.title; - card.append(meta, title); - flight.appendChild(card); - } - }; + for (let index = 0; index < count; index += 1) { + const post = pool[Math.floor(Math.random() * pool.length)]; + const card = document.createElement('div'); + card.className = 'random-post-flying-card'; + card.style.setProperty('--flight-delay', `${index * 0.11}s`); + card.style.setProperty('--flight-y', `${-42 + Math.random() * 84}px`); + card.style.setProperty('--flight-rotate', `${-8 + Math.random() * 16}deg`); + const meta = document.createElement('small'); + const title = document.createElement('strong'); + meta.textContent = post.meta; + title.textContent = post.title; + card.append(meta, title); + flight.appendChild(card); + } + }; - const reset = () => { - source?.classList.remove('is-randomizing'); - source?.removeAttribute('aria-busy'); - overlay.classList.remove('is-visible'); - window.setTimeout(() => overlay.remove(), reduceMotion ? 0 : 180); - }; + const reset = () => { + source?.classList.remove('is-randomizing'); + source?.removeAttribute('aria-busy'); + overlay.classList.remove('is-visible'); + window.setTimeout(() => overlay.remove(), reduceMotion ? 0 : 180); + }; - fetch('/api/posts.json') - .then(res => { - if (!res.ok) throw new Error(`Failed to load posts: ${res.status}`); - return res.json(); - }) - .then(posts => { - const postLinks = posts - .map(post => post && post.href) - .filter(href => typeof href === 'string' && href.startsWith('/posts/')); + fetch('/api/posts.json') + .then((res) => { + if (!res.ok) throw new Error(`Failed to load posts: ${res.status}`); + return res.json(); + }) + .then((posts) => { + const postLinks = posts + .map((post) => post && post.href) + .filter((href) => typeof href === 'string' && href.startsWith('/posts/')); - if (postLinks.length === 0) { - console.warn('No posts available for random navigation.'); - reset(); - return; - } + if (postLinks.length === 0) { + console.warn('No posts available for random navigation.'); + reset(); + return; + } - startCardFlight(posts); - finish(postLinks[Math.floor(Math.random() * postLinks.length)]); - }) - .catch(error => { - console.error('Random post navigation failed:', error); - reset(); - }); + startCardFlight(posts); + finish(postLinks[Math.floor(Math.random() * postLinks.length)]); + }) + .catch((error) => { + console.error('Random post navigation failed:', error); + reset(); + }); } diff --git a/public/js/search/typesense-search.js b/public/js/search/typesense-search.js index 94f9436..20aed5e 100644 --- a/public/js/search/typesense-search.js +++ b/public/js/search/typesense-search.js @@ -7,14 +7,25 @@ const CONFIG = window.SITE_CONFIG?.search; const assets = document.currentScript?.dataset || {}; let dependenciesPromise; - const escapeHtml = (value) => String(value ?? '').replace(/[&<>"']/g, (char) => ({ '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' })[char]); - const safeHighlight = (value) => String(value ?? '').split(/(<\/?mark>)/i) - .map((part) => /^<\/?mark>$/i.test(part) ? part.toLowerCase() : escapeHtml(part)).join(''); + const escapeHtml = (value) => + String(value ?? '').replace( + /[&<>"']/g, + (char) => ({ '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' })[char], + ); + const safeHighlight = (value) => + String(value ?? '') + .split(/(<\/?mark>)/i) + .map((part) => (/^<\/?mark>$/i.test(part) ? part.toLowerCase() : escapeHtml(part))) + .join(''); function safeResultUrl(value) { try { const url = new URL(value, location.origin); - return url.origin === location.origin && /^\/posts\//.test(url.pathname) ? url.pathname + url.search + url.hash : ''; - } catch { return ''; } + return url.origin === location.origin && /^\/posts\//.test(url.pathname) + ? url.pathname + url.search + url.hash + : ''; + } catch { + return ''; + } } function loadDependencies() { if (dependenciesPromise) return dependenciesPromise; @@ -22,14 +33,18 @@ css.rel = 'stylesheet'; css.href = assets.searchCss; document.head.appendChild(css); - const loadScript = (src) => new Promise((resolve, reject) => { - const script = document.createElement('script'); - script.src = src; - script.onload = resolve; - script.onerror = () => reject(new Error('搜索依赖加载失败')); - document.head.appendChild(script); - }); - dependenciesPromise = Promise.all([loadScript(assets.searchJs), loadScript(assets.adapterJs)]).catch((error) => { + const loadScript = (src) => + new Promise((resolve, reject) => { + const script = document.createElement('script'); + script.src = src; + script.onload = resolve; + script.onerror = () => reject(new Error('搜索依赖加载失败')); + document.head.appendChild(script); + }); + dependenciesPromise = Promise.all([ + loadScript(assets.searchJs), + loadScript(assets.adapterJs), + ]).catch((error) => { dependenciesPromise = null; css.remove(); throw error; @@ -59,15 +74,15 @@ function showErrorMessage() { const hitsContainer = document.getElementById('hits'); if (!hitsContainer) return; - - hitsContainer.innerHTML = + + hitsContainer.innerHTML = '
' + - '
' + - '
搜索服务加载失败
' + - '
请检查网络连接后重试。
' + - '
' + - '' + - '
' + + '
' + + '
搜索服务加载失败
' + + '
请检查网络连接后重试。
' + + '
' + + '' + + '
' + '
'; } @@ -330,13 +345,15 @@ container.focus(); if (!isInitialized) { - loadDependencies().then(() => { - initTypesense(); - if (isSearchOpen) focusSearchInput(); - }).catch((error) => { - console.error(error); - showErrorMessage(); - }); + loadDependencies() + .then(() => { + initTypesense(); + if (isSearchOpen) focusSearchInput(); + }) + .catch((error) => { + console.error(error); + showErrorMessage(); + }); } focusSearchInput(); } @@ -347,7 +364,7 @@ mask.classList.remove('active'); document.body.style.overflow = previousOverflow; if (previousFocus instanceof HTMLElement) previousFocus.focus(); - closeTimer = setTimeout(function() { + closeTimer = setTimeout(function () { if (isSearchOpen) return; mask.style.display = 'none'; closeTimer = null; @@ -362,7 +379,7 @@ input.focus(); input.select(); } else if (!input && retryCount < (CONFIG.ui.maxRetries || 10)) { - setTimeout(function() { + setTimeout(function () { focusSearchInput(retryCount + 1); }, CONFIG.ui.retryDelay || 100); } @@ -371,7 +388,7 @@ // ============================================================================ // 事件监听 // ============================================================================ - document.addEventListener('click', function(e) { + document.addEventListener('click', function (e) { if (e.target.closest('.search-typesense-trigger')) { e.preventDefault(); openSearch(); @@ -379,13 +396,13 @@ }); closeBtn.addEventListener('click', closeSearch); - mask.addEventListener('click', function(e) { + mask.addEventListener('click', function (e) { if (e.target === mask) closeSearch(); }); - container.addEventListener('click', function(e) { + container.addEventListener('click', function (e) { e.stopPropagation(); }); - window.addEventListener('keydown', function(e) { + window.addEventListener('keydown', function (e) { if (e.key === 'Escape' && isSearchOpen) { closeSearch(); } @@ -394,15 +411,27 @@ openSearch(); } if (e.key === 'Tab' && isSearchOpen) { - const focusable = [...container.querySelectorAll('a[href], button:not([disabled]), input:not([disabled]), [tabindex]:not([tabindex="-1"])')] - .filter((element) => element.getClientRects().length); - if (!focusable.length) { e.preventDefault(); container.focus(); return; } + const focusable = [ + ...container.querySelectorAll( + 'a[href], button:not([disabled]), input:not([disabled]), [tabindex]:not([tabindex="-1"])', + ), + ].filter((element) => element.getClientRects().length); + if (!focusable.length) { + e.preventDefault(); + container.focus(); + return; + } const first = focusable[0]; const last = focusable[focusable.length - 1]; - if (e.shiftKey && (document.activeElement === first || document.activeElement === container)) { - e.preventDefault(); last.focus(); + if ( + e.shiftKey && + (document.activeElement === first || document.activeElement === container) + ) { + e.preventDefault(); + last.focus(); } else if (!e.shiftKey && document.activeElement === last) { - e.preventDefault(); first.focus(); + e.preventDefault(); + first.focus(); } } }); @@ -417,16 +446,17 @@ } var instantsearchLoaded = typeof instantsearch !== 'undefined'; - var adapterLoaded = typeof TypesenseInstantSearchAdapter !== 'undefined' || - typeof window.TypesenseInstantSearchAdapter !== 'undefined'; - + var adapterLoaded = + typeof TypesenseInstantSearchAdapter !== 'undefined' || + typeof window.TypesenseInstantSearchAdapter !== 'undefined'; + console.log('📦 依赖库检查 (' + (initRetryCount + 1) + '/' + MAX_INIT_RETRIES + '):'); console.log(' instantsearch.js:', instantsearchLoaded ? '✅ 已加载' : '❌ 未加载'); console.log(' TypesenseAdapter:', adapterLoaded ? '✅ 已加载' : '❌ 未加载'); - + if (!instantsearchLoaded || !adapterLoaded) { initRetryCount++; - + if (initRetryCount >= MAX_INIT_RETRIES) { console.error(''); console.error('❌ Typesense 依赖库加载失败!'); @@ -436,8 +466,12 @@ console.error(''); console.error('inject:'); console.error(' bottom: # ⚠️ 使用 bottom 而不是 head'); - console.error(' - '); - console.error(' - '); + console.error( + ' - ', + ); + console.error( + ' - ', + ); console.error(' - '); console.error(''); console.error('💡 或在控制台手动检查:'); @@ -445,16 +479,16 @@ console.error(' typeof TypesenseInstantSearchAdapter'); console.error(''); console.error('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━'); - + showErrorMessage(); return; } - + console.warn('⏳ 100ms 后重试...'); setTimeout(initTypesense, 100); return; } - + initRetryCount = 0; console.log('🚀 开始初始化 Typesense...'); @@ -462,20 +496,22 @@ const typesenseAdapter = new TypesenseInstantSearchAdapter({ server: { apiKey: CONFIG.apiKey, - nodes: [{ - host: CONFIG.server.host, - port: CONFIG.server.port, - protocol: CONFIG.server.protocol - }], - cacheSearchResultsForSeconds: 120 + nodes: [ + { + host: CONFIG.server.host, + port: CONFIG.server.port, + protocol: CONFIG.server.protocol, + }, + ], + cacheSearchResultsForSeconds: 120, }, - additionalSearchParameters: CONFIG.searchParams + additionalSearchParameters: CONFIG.searchParams, }); searchInstance = instantsearch({ searchClient: typesenseAdapter.searchClient, indexName: CONFIG.indexName, - routing: false + routing: false, }); searchInstance.addWidgets([ @@ -485,64 +521,79 @@ autofocus: false, showReset: true, showSubmit: false, - showLoadingIndicator: true + showLoadingIndicator: true, }), instantsearch.widgets.stats({ container: '#stats', templates: { - text: function(data) { + text: function (data) { if (!data.query) return ''; - return '找到 ' + data.nbHits + ' 条结果 (' + data.processingTimeMS + 'ms)'; - } - } + return ( + '找到 ' + data.nbHits + ' 条结果 (' + data.processingTimeMS + 'ms)' + ); + }, + }, }), instantsearch.widgets.hits({ container: '#hits', templates: { - empty: function(results) { - return '
' + + empty: function (results) { + return ( + '
' + '
' + - '
找不到与 "' + escapeHtml(results.query) + '" 相关的内容
' + + '
找不到与 "' + + escapeHtml(results.query) + + '" 相关的内容
' + '
试试其他关键词吧 (´·ω·`)
' + - '
'; + '
' + ); }, - item: function(hit) { + item: function (hit) { // 使用 _highlightResult 获取高亮文本 - var titleHighlight = hit._highlightResult && hit._highlightResult.title - ? hit._highlightResult.title.value - : (hit.title || ''); - - var contentHighlight = hit._highlightResult && hit._highlightResult.content - ? hit._highlightResult.content.value - : (hit.content || ''); - + var titleHighlight = + hit._highlightResult && hit._highlightResult.title + ? hit._highlightResult.title.value + : hit.title || ''; + + var contentHighlight = + hit._highlightResult && hit._highlightResult.content + ? hit._highlightResult.content.value + : hit.content || ''; + // 截取内容长度 if (contentHighlight.length > 200) { contentHighlight = contentHighlight.substring(0, 200) + '...'; } - + const url = safeResultUrl(hit.url); if (!url) return ''; - return '' + - '
' + safeHighlight(titleHighlight) + '
' + - '
' + safeHighlight(contentHighlight) + '
' + - '
'; - } - } + return ( + '' + + '
' + + safeHighlight(titleHighlight) + + '
' + + '
' + + safeHighlight(contentHighlight) + + '
' + + '
' + ); + }, + }, }), instantsearch.widgets.pagination({ container: '#pagination', padding: 2, showFirst: false, - showLast: false - }) + showLast: false, + }), ]); searchInstance.start(); isInitialized = true; - - console.log('✅ Typesense 初始化成功!'); + console.log('✅ Typesense 初始化成功!'); } catch (error) { console.error('❌ 初始化失败:', error); showErrorMessage(); @@ -569,8 +620,11 @@ window.TypesenseSearch = { open: openSearch, close: closeSearch, - isOpen: function() { return isSearchOpen; }, - getInstance: function() { return searchInstance; } + isOpen: function () { + return isSearchOpen; + }, + getInstance: function () { + return searchInstance; + }, }; - })(); diff --git a/public/js/shuoshuo.js b/public/js/shuoshuo.js index 32b3983..4f91671 100644 --- a/public/js/shuoshuo.js +++ b/public/js/shuoshuo.js @@ -1,243 +1,258 @@ function renderTalks() { - const talkContainer = document.querySelector('#talk'); - if (!talkContainer) return; - const config = window.SITE_CONFIG?.talks || {}; - const escapeHtml = (value) => String(value ?? '').replace(/[&<>"']/g, (char) => ({ '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' })[char]); - const safeUrl = (value) => { - try { - const url = new URL(value, window.location.origin); - return ['http:', 'https:'].includes(url.protocol) ? url.href : ''; - } catch { return ''; } - }; - talkContainer.innerHTML = ''; - const generateIconSVG = () => { - return ``; + const talkContainer = document.querySelector('#talk'); + if (!talkContainer) return; + const config = window.SITE_CONFIG?.talks || {}; + const escapeHtml = (value) => + String(value ?? '').replace( + /[&<>"']/g, + (char) => ({ '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' })[char], + ); + const safeUrl = (value) => { + try { + const url = new URL(value, window.location.origin); + return ['http:', 'https:'].includes(url.protocol) ? url.href : ''; + } catch { + return ''; + } + }; + talkContainer.innerHTML = ''; + const generateIconSVG = () => { + return ``; + }; + const waterfall = (a) => { + function b(a, b) { + var c = window.getComputedStyle(b); + return parseFloat(c['margin' + a]) || 0; } - const waterfall = (a) => { - function b(a, b) { - var c = window.getComputedStyle(b); - return parseFloat(c["margin" + a]) || 0 - } - function c(a) { - return a + "px" - } + function c(a) { + return a + 'px'; + } - function d(a) { - return parseFloat(a.style.top) - } + function d(a) { + return parseFloat(a.style.top); + } - function e(a) { - return parseFloat(a.style.left) - } + function e(a) { + return parseFloat(a.style.left); + } - function f(a) { - return a.clientWidth - } + function f(a) { + return a.clientWidth; + } - function g(a) { - return a.clientHeight - } + function g(a) { + return a.clientHeight; + } - function h(a) { - return d(a) + g(a) + b("Bottom", a) - } + function h(a) { + return d(a) + g(a) + b('Bottom', a); + } - function i(a) { - return e(a) + f(a) + b("Right", a) - } + function i(a) { + return e(a) + f(a) + b('Right', a); + } - function j(a) { - a = a.sort(function (a, b) { - return h(a) === h(b) ? e(b) - e(a) : h(b) - h(a) - }) - } + function j(a) { + a = a.sort(function (a, b) { + return h(a) === h(b) ? e(b) - e(a) : h(b) - h(a); + }); + } - function k(b) { - f(a) != t && (b.target.removeEventListener(b.type, arguments.callee), waterfall(a)) - } - "string" == typeof a && (a = document.querySelector(a)); - var l = [].map.call(a.children, function (a) { - return a.style.position = "absolute", a - }); - a.style.position = "relative"; - var m = []; - l.length && (l[0].style.top = "0px", l[0].style.left = c(b("Left", l[0])), m.push(l[0])); - for (var n = 1; n < l.length; n++) { - var o = l[n - 1], - p = l[n], - q = i(o) + f(p) <= f(a); - if (!q) break; - p.style.top = o.style.top, p.style.left = c(i(o) + b("Left", p)), m.push(p) - } - for (; n < l.length; n++) { - j(m); - var p = l[n], - r = m.pop(); - p.style.top = c(h(r) + b("Top", p)), p.style.left = c(e(r)), m.push(p) - } - j(m); - var s = m[0]; - a.style.height = c(h(s) + b("Bottom", s)); - var t = f(a); - window.addEventListener ? window.addEventListener("resize", k) : document.body.onresize = k - }; + function k(b) { + f(a) != t && (b.target.removeEventListener(b.type, arguments.callee), waterfall(a)); + } + 'string' == typeof a && (a = document.querySelector(a)); + var l = [].map.call(a.children, function (a) { + return ((a.style.position = 'absolute'), a); + }); + a.style.position = 'relative'; + var m = []; + l.length && ((l[0].style.top = '0px'), (l[0].style.left = c(b('Left', l[0]))), m.push(l[0])); + for (var n = 1; n < l.length; n++) { + var o = l[n - 1], + p = l[n], + q = i(o) + f(p) <= f(a); + if (!q) break; + ((p.style.top = o.style.top), (p.style.left = c(i(o) + b('Left', p))), m.push(p)); + } + for (; n < l.length; n++) { + j(m); + var p = l[n], + r = m.pop(); + ((p.style.top = c(h(r) + b('Top', p))), (p.style.left = c(e(r))), m.push(p)); + } + j(m); + var s = m[0]; + a.style.height = c(h(s) + b('Bottom', s)); + var t = f(a); + window.addEventListener ? window.addEventListener('resize', k) : (document.body.onresize = k); + }; - const fetchAndRenderTalks = () => { - const url = config.apiUrl; - if (!url) return; - const cacheKey = config.cacheKey || 'talksCache'; - const cacheTimeKey = config.cacheTimeKey || 'talksCacheTime'; - const cacheDuration = config.cacheDurationMs || 30 * 60 * 1000; - let cachedData = null; - let cachedTime = 0; - try { - const parsed = JSON.parse(localStorage.getItem(cacheKey) || 'null'); - if (Array.isArray(parsed)) cachedData = parsed; - cachedTime = Number(localStorage.getItem(cacheTimeKey)) || 0; - } catch { /* Cache is optional. */ } - const now = Date.now(); + const fetchAndRenderTalks = () => { + const url = config.apiUrl; + if (!url) return; + const cacheKey = config.cacheKey || 'talksCache'; + const cacheTimeKey = config.cacheTimeKey || 'talksCacheTime'; + const cacheDuration = config.cacheDurationMs || 30 * 60 * 1000; + let cachedData = null; + let cachedTime = 0; + try { + const parsed = JSON.parse(localStorage.getItem(cacheKey) || 'null'); + if (Array.isArray(parsed)) cachedData = parsed; + cachedTime = Number(localStorage.getItem(cacheTimeKey)) || 0; + } catch { + /* Cache is optional. */ + } + const now = Date.now(); - if (cachedData && cachedTime && (now - cachedTime < cacheDuration)) { - renderTalksList(cachedData); - } else { - fetch(url, { - method: 'POST', - headers: { 'Content-Type': 'application/json' }, - body: JSON.stringify({ page: 1, pageSize: config.pageSize || 30 }) - }) - .then(res => { - if (!res.ok) throw new Error(`HTTP ${res.status}`); - return res.json(); - }) - .then(data => { - if (data.code === 1 && data.data && Array.isArray(data.data.items)) { - try { - localStorage.setItem(cacheKey, JSON.stringify(data.data.items)); - localStorage.setItem(cacheTimeKey, now.toString()); - } catch { /* Rendering does not depend on cache availability. */ } - renderTalksList(data.data.items); - } else throw new Error('Unexpected API response format'); - }) - .catch(err => { - console.warn('说说加载失败:', err); - if (cachedData) renderTalksList(cachedData); - else talkContainer.textContent = '说说暂时无法加载,请稍后再试。'; - }); - } - }; - - const renderTalksList = (list) => { - list.map(formatTalk).forEach(item => talkContainer.appendChild(generateTalkElement(item))); - if (list.length) waterfall('#talk'); - else talkContainer.textContent = '暂无说说。'; - }; - - const withImageParams = (url) => { - if (!url) return ''; - try { - const parsedUrl = new URL(url, window.location.origin); - if (!parsedUrl.searchParams.has('fmt')) parsedUrl.searchParams.set('fmt', 'webp'); - if (!parsedUrl.searchParams.has('q')) parsedUrl.searchParams.set('q', '75'); - return safeUrl(parsedUrl.toString()); - } catch { - return ''; - } - }; - - const getImageUrl = (image) => { - if (!image) return ''; - if (typeof image === 'string') return image; - return image.image_url || image.url || image.src || image.file?.url || ''; - }; - - const getTalkImages = (item) => { - if (Array.isArray(item.images) && item.images.length > 0) { - return item.images.map(getImageUrl).filter(Boolean); - } - - if (Array.isArray(item.echo_files) && item.echo_files.length > 0) { - return item.echo_files - .map((echoFile) => getImageUrl(echoFile.file || echoFile)) - .filter(Boolean); - } - - return []; - }; - - const formatTalk = (item) => { - const date = formatTime(item.created_at); - let content = escapeHtml(item.content || ''); - content = content.replace(/\[(.*?)\]\((.*?)\)/g, (match, label, href) => { - const url = safeUrl(href); - return url ? `@${label}` : label; + if (cachedData && cachedTime && now - cachedTime < cacheDuration) { + renderTalksList(cachedData); + } else { + fetch(url, { + method: 'POST', + headers: { 'Content-Type': 'application/json' }, + body: JSON.stringify({ page: 1, pageSize: config.pageSize || 30 }), + }) + .then((res) => { + if (!res.ok) throw new Error(`HTTP ${res.status}`); + return res.json(); }) - .replace(/- \[ \]/g, '⚪') - .replace(/- \[x\]/g, '⚫') - .replace(/\n/g, '
'); - content = `
${content}
`; - - // 图片 - const images = getTalkImages(item); - if (images.length > 0) { - const imgDiv = document.createElement('div'); - imgDiv.className = 'zone_imgbox'; - images.forEach(url => { - const imageUrl = withImageParams(url); - if (!imageUrl) return; - const link = document.createElement('a'); - link.href = imageUrl; - link.setAttribute('data-fancybox', 'gallery'); - link.className = 'fancybox'; - const imgTag = document.createElement('img'); - imgTag.src = imageUrl; - imgTag.loading = 'lazy'; - imgTag.alt = ''; - link.appendChild(imgTag); - imgDiv.appendChild(link); - }); - content += imgDiv.outerHTML; - } - - // 外链 / GitHub 项目 - // 外链 / GitHub 项目 - if (['WEBSITE', 'GITHUBPROJ'].includes(item.extension_type)) { - let siteUrl = '', title = ''; - let extensionBack = "https://pic.biss.click/image/1971bdc1-4349-4bb9-b683-20404f5da7d7.webp"; - - // 解析 extension 字段 + .then((data) => { + if (data.code === 1 && data.data && Array.isArray(data.data.items)) { try { - const extObj = typeof item.extension === 'string' ? JSON.parse(item.extension) : item.extension; - siteUrl = extObj.site || extObj.url || item.extension; - title = extObj.title || siteUrl; + localStorage.setItem(cacheKey, JSON.stringify(data.data.items)); + localStorage.setItem(cacheTimeKey, now.toString()); } catch { - siteUrl = item.extension; - title = siteUrl; + /* Rendering does not depend on cache availability. */ } + renderTalksList(data.data.items); + } else throw new Error('Unexpected API response format'); + }) + .catch((err) => { + console.warn('说说加载失败:', err); + if (cachedData) renderTalksList(cachedData); + else talkContainer.textContent = '说说暂时无法加载,请稍后再试。'; + }); + } + }; - // 特殊处理 GitHub 项目 - if (item.extension_type === 'GITHUBPROJ') { - extensionBack = "https://pic.biss.click/image/ed410d4e-d3f8-4b26-8840-50dd58f7dc4e.webp"; + const renderTalksList = (list) => { + list.map(formatTalk).forEach((item) => talkContainer.appendChild(generateTalkElement(item))); + if (list.length) waterfall('#talk'); + else talkContainer.textContent = '暂无说说。'; + }; - // 提取 GitHub 项目名 - const match = siteUrl.match(/^https?:\/\/github\.com\/[^/]+\/([^/?#]+)/i); - if (match) { - title = match[1]; // 获取仓库名 - } else { - // fallback:从最后一个路径段提取 - try { - const parts = new URL(siteUrl).pathname.split('/').filter(Boolean); - title = parts.pop() || siteUrl; - } catch { - // 如果 URL 无效则保留原始 - } - } - } + const withImageParams = (url) => { + if (!url) return ''; + try { + const parsedUrl = new URL(url, window.location.origin); + if (!parsedUrl.searchParams.has('fmt')) parsedUrl.searchParams.set('fmt', 'webp'); + if (!parsedUrl.searchParams.has('q')) parsedUrl.searchParams.set('q', '75'); + return safeUrl(parsedUrl.toString()); + } catch { + return ''; + } + }; - siteUrl = safeUrl(siteUrl); - // 输出 HTML 结构 - if (siteUrl) { - content += ` + const getImageUrl = (image) => { + if (!image) return ''; + if (typeof image === 'string') return image; + return image.image_url || image.url || image.src || image.file?.url || ''; + }; + + const getTalkImages = (item) => { + if (Array.isArray(item.images) && item.images.length > 0) { + return item.images.map(getImageUrl).filter(Boolean); + } + + if (Array.isArray(item.echo_files) && item.echo_files.length > 0) { + return item.echo_files + .map((echoFile) => getImageUrl(echoFile.file || echoFile)) + .filter(Boolean); + } + + return []; + }; + + const formatTalk = (item) => { + const date = formatTime(item.created_at); + let content = escapeHtml(item.content || ''); + content = content + .replace(/\[(.*?)\]\((.*?)\)/g, (match, label, href) => { + const url = safeUrl(href); + return url + ? `@${label}` + : label; + }) + .replace(/- \[ \]/g, '⚪') + .replace(/- \[x\]/g, '⚫') + .replace(/\n/g, '
'); + content = `
${content}
`; + + // 图片 + const images = getTalkImages(item); + if (images.length > 0) { + const imgDiv = document.createElement('div'); + imgDiv.className = 'zone_imgbox'; + images.forEach((url) => { + const imageUrl = withImageParams(url); + if (!imageUrl) return; + const link = document.createElement('a'); + link.href = imageUrl; + link.setAttribute('data-fancybox', 'gallery'); + link.className = 'fancybox'; + const imgTag = document.createElement('img'); + imgTag.src = imageUrl; + imgTag.loading = 'lazy'; + imgTag.alt = ''; + link.appendChild(imgTag); + imgDiv.appendChild(link); + }); + content += imgDiv.outerHTML; + } + + // 外链 / GitHub 项目 + // 外链 / GitHub 项目 + if (['WEBSITE', 'GITHUBPROJ'].includes(item.extension_type)) { + let siteUrl = '', + title = ''; + let extensionBack = 'https://pic.biss.click/image/1971bdc1-4349-4bb9-b683-20404f5da7d7.webp'; + + // 解析 extension 字段 + try { + const extObj = + typeof item.extension === 'string' ? JSON.parse(item.extension) : item.extension; + siteUrl = extObj.site || extObj.url || item.extension; + title = extObj.title || siteUrl; + } catch { + siteUrl = item.extension; + title = siteUrl; + } + + // 特殊处理 GitHub 项目 + if (item.extension_type === 'GITHUBPROJ') { + extensionBack = 'https://pic.biss.click/image/ed410d4e-d3f8-4b26-8840-50dd58f7dc4e.webp'; + + // 提取 GitHub 项目名 + const match = siteUrl.match(/^https?:\/\/github\.com\/[^/]+\/([^/?#]+)/i); + if (match) { + title = match[1]; // 获取仓库名 + } else { + // fallback:从最后一个路径段提取 + try { + const parts = new URL(siteUrl).pathname.split('/').filter(Boolean); + title = parts.pop() || siteUrl; + } catch { + // 如果 URL 无效则保留原始 + } + } + } + + siteUrl = safeUrl(siteUrl); + // 输出 HTML 结构 + if (siteUrl) { + content += ` `; - } - } + } + } + // 音乐 + if (item.extension_type === 'MUSIC' && item.extension) { + const link = item.extension; + let server = ''; + if (link.includes('music.163.com')) server = 'netease'; + else if (link.includes('y.qq.com')) server = 'tencent'; + const idMatch = link.match(/id=(\d+)/); + const id = idMatch ? idMatch[1] : ''; + if (server && id) { + content += ``; + } + } - // 音乐 - if (item.extension_type === 'MUSIC' && item.extension) { - const link = item.extension; - let server = ''; - if (link.includes('music.163.com')) server = 'netease'; - else if (link.includes('y.qq.com')) server = 'tencent'; - const idMatch = link.match(/id=(\d+)/); - const id = idMatch ? idMatch[1] : ''; - if (server && id) { - content += ``; - } - } - - // 视频 - if (item.extension_type === 'VIDEO' && item.extension) { - const video = item.extension; - if (/^BV[a-zA-Z0-9]+$/.test(video)) { - const bilibiliUrl = `https://www.bilibili.com/blackboard/html5mobileplayer.html?bvid=${video}&as_wide=1&high_quality=1&danmaku=0`; - content += ` + // 视频 + if (item.extension_type === 'VIDEO' && item.extension) { + const video = item.extension; + if (/^BV[a-zA-Z0-9]+$/.test(video)) { + const bilibiliUrl = `https://www.bilibili.com/blackboard/html5mobileplayer.html?bvid=${video}&as_wide=1&high_quality=1&danmaku=0`; + content += `
`; - } else if (/^[a-zA-Z0-9_-]{11}$/.test(video)) { - const youtubeUrl = `https://www.youtube.com/embed/${video}`; - content += ` + } else if (/^[a-zA-Z0-9_-]{11}$/.test(video)) { + const youtubeUrl = `https://www.youtube.com/embed/${video}`; + content += `
`; - } - } + } + } - return { - content, - user: item.username || '匿名', - avatar: config.fallbackAvatar || window.SITE_CONFIG?.author?.avatar || '', - date, - location: '', - tags: Array.isArray(item.tags) && item.tags.length ? item.tags.map(t => t.name) : ['无标签'], - text: String(item.content || '').replace(/\[(.*?)\]\((.*?)\)/g, '$1') - }; + return { + content, + user: item.username || '匿名', + avatar: config.fallbackAvatar || window.SITE_CONFIG?.author?.avatar || '', + date, + location: '', + tags: + Array.isArray(item.tags) && item.tags.length ? item.tags.map((t) => t.name) : ['无标签'], + text: String(item.content || '').replace(/\[(.*?)\]\((.*?)\)/g, '$1'), }; + }; - const generateTalkElement = (item) => { - const talkItem = document.createElement('div'); - talkItem.className = 'talk_item'; + const generateTalkElement = (item) => { + const talkItem = document.createElement('div'); + talkItem.className = 'talk_item'; - const talkMeta = document.createElement('div'); - talkMeta.className = 'talk_meta'; - const avatar = document.createElement('img'); - avatar.className = 'no-lightbox avatar'; - avatar.src = item.avatar; + const talkMeta = document.createElement('div'); + talkMeta.className = 'talk_meta'; + const avatar = document.createElement('img'); + avatar.className = 'no-lightbox avatar'; + avatar.src = item.avatar; - const info = document.createElement('div'); - info.className = 'info'; - const nick = document.createElement('span'); - nick.className = 'talk_nick'; - nick.textContent = `${item.user} `; - nick.insertAdjacentHTML('beforeend', generateIconSVG()); - const date = document.createElement('span'); - date.className = 'talk_date'; - date.textContent = item.date; - info.appendChild(nick); - info.appendChild(date); - talkMeta.appendChild(avatar); - talkMeta.appendChild(info); + const info = document.createElement('div'); + info.className = 'info'; + const nick = document.createElement('span'); + nick.className = 'talk_nick'; + nick.textContent = `${item.user} `; + nick.insertAdjacentHTML('beforeend', generateIconSVG()); + const date = document.createElement('span'); + date.className = 'talk_date'; + date.textContent = item.date; + info.appendChild(nick); + info.appendChild(date); + talkMeta.appendChild(avatar); + talkMeta.appendChild(info); - const talkContent = document.createElement('div'); - talkContent.className = 'talk_content'; - talkContent.innerHTML = item.content; + const talkContent = document.createElement('div'); + talkContent.className = 'talk_content'; + talkContent.innerHTML = item.content; - const talkBottom = document.createElement('div'); - talkBottom.className = 'talk_bottom'; - const tags = document.createElement('div'); - const tag = document.createElement('span'); - tag.className = 'talk_tag'; - tag.textContent = `🏷️${item.tags}`; - //const loc = document.createElement('span'); - //loc.className = 'location_tag'; - //loc.textContent = `🌍${item.location}`; - tags.appendChild(tag); - //tags.appendChild(loc); + const talkBottom = document.createElement('div'); + talkBottom.className = 'talk_bottom'; + const tags = document.createElement('div'); + const tag = document.createElement('span'); + tag.className = 'talk_tag'; + tag.textContent = `🏷️${item.tags}`; + //const loc = document.createElement('span'); + //loc.className = 'location_tag'; + //loc.textContent = `🌍${item.location}`; + tags.appendChild(tag); + //tags.appendChild(loc); - const commentLink = document.createElement('a'); - commentLink.href = '#post-comment'; - commentLink.setAttribute('aria-label', '引用这条说说到评论区'); - commentLink.onclick = (event) => { event.preventDefault(); goComment(item.text); }; - const icon = document.createElement('span'); - icon.className = 'icon'; - icon.innerHTML = ''; - commentLink.appendChild(icon); - - talkBottom.appendChild(tags); - talkBottom.appendChild(commentLink); - - talkItem.appendChild(talkMeta); - talkItem.appendChild(talkContent); - talkItem.appendChild(talkBottom); - - return talkItem; + const commentLink = document.createElement('a'); + commentLink.href = '#post-comment'; + commentLink.setAttribute('aria-label', '引用这条说说到评论区'); + commentLink.onclick = (event) => { + event.preventDefault(); + goComment(item.text); }; + const icon = document.createElement('span'); + icon.className = 'icon'; + icon.innerHTML = ''; + commentLink.appendChild(icon); - const goComment = (text) => { - const textarea = document.querySelector('#twikoo-wrap textarea'); - if (!textarea) { - document.getElementById('post-comment')?.scrollIntoView({ behavior: 'smooth' }); - btf.snackbarShow('评论区尚未加载完成,请稍后再试'); - return; - } - textarea.value = `${text.split(/\r?\n/).map(line => `> ${line}`).join('\n')}\n\n`; - textarea.dispatchEvent(new Event('input', { bubbles: true })); - textarea.focus(); - btf.snackbarShow("已为您引用该说说,不删除空格效果更佳"); - }; + talkBottom.appendChild(tags); + talkBottom.appendChild(commentLink); - const formatTime = (time) => { - const timestamp = Number(time); - const d = Number.isFinite(timestamp) - ? new Date(timestamp < 100000000000 ? timestamp * 1000 : timestamp) - : new Date(time); - const pad = (n) => n.toString().padStart(2, '0'); - if (Number.isNaN(d.getTime())) return ''; - return `${d.getFullYear()}-${pad(d.getMonth()+1)}-${pad(d.getDate())} ${pad(d.getHours())}:${pad(d.getMinutes())}`; - }; + talkItem.appendChild(talkMeta); + talkItem.appendChild(talkContent); + talkItem.appendChild(talkBottom); - fetchAndRenderTalks(); + return talkItem; + }; + + const goComment = (text) => { + const textarea = document.querySelector('#twikoo-wrap textarea'); + if (!textarea) { + document.getElementById('post-comment')?.scrollIntoView({ behavior: 'smooth' }); + btf.snackbarShow('评论区尚未加载完成,请稍后再试'); + return; + } + textarea.value = `${text + .split(/\r?\n/) + .map((line) => `> ${line}`) + .join('\n')}\n\n`; + textarea.dispatchEvent(new Event('input', { bubbles: true })); + textarea.focus(); + btf.snackbarShow('已为您引用该说说,不删除空格效果更佳'); + }; + + const formatTime = (time) => { + const timestamp = Number(time); + const d = Number.isFinite(timestamp) + ? new Date(timestamp < 100000000000 ? timestamp * 1000 : timestamp) + : new Date(time); + const pad = (n) => n.toString().padStart(2, '0'); + if (Number.isNaN(d.getTime())) return ''; + return `${d.getFullYear()}-${pad(d.getMonth() + 1)}-${pad(d.getDate())} ${pad(d.getHours())}:${pad(d.getMinutes())}`; + }; + + fetchAndRenderTalks(); } renderTalks(); diff --git a/public/js/shuoshuoshouye.js b/public/js/shuoshuoshouye.js index f61015b..9405284 100644 --- a/public/js/shuoshuoshouye.js +++ b/public/js/shuoshuoshouye.js @@ -5,116 +5,126 @@ const cacheTimeKey = 'talksCacheTime'; const cacheDuration = 30 * 60 * 1000; // 缓存有效期 30分钟 function indexTalk() { - if (talkTimer) { - clearInterval(talkTimer); - talkTimer = null; + if (talkTimer) { + clearInterval(talkTimer); + talkTimer = null; + } + + if (!document.getElementById('bber-talk')) return; + const config = window.SITE_CONFIG?.talks || {}; + const talksCacheKey = config.cacheKey || cacheKey; + const talksCacheTimeKey = config.cacheTimeKey || cacheTimeKey; + const talksCacheDuration = config.cacheDurationMs || cacheDuration; + + function toText(ls) { + return ls.map((item) => { + let c = String(item.content || '').replace( + /[&<>"']/g, + (char) => ({ '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' })[char], + ); + + const hasImg = /\!\[.*?\]\(.*?\)/.test(c); + const hasLink = /\[.*?\]\(.*?\)/.test(c); + + c = c + .replace(/#(.*?)\s/g, '') + .replace(/\{.*?\}/g, '') + .replace(/\!\[.*?\]\(.*?\)/g, '') + .replace(/\[.*?\]\(.*?\)/g, ''); + + const icons = []; + + if (item.images?.length && !hasImg) icons.push('fa-solid fa-image'); + if (item.extension_type === 'VIDEO') icons.push('fa-solid fa-video'); + if (item.extension_type === 'MUSIC') icons.push('fa-solid fa-music'); + if (item.extension_type === 'WEBSITE' && !hasLink) icons.push('fa-solid fa-link'); + if (item.extension_type === 'GITHUBPROJ' && !hasLink) icons.push('fab fa-github'); + + if (icons.length) c += ' ' + icons.map((i) => ``).join(' '); + return c; + }); + } + + // 渲染与轮播 + function talk(ls) { + let html = ''; + ls.forEach((item, i) => { + html += `
  • ${item}
  • `; + }); + + let box = document.querySelector('#bber-talk .talk-list'); + if (!box) return; + + box.innerHTML = html || '
  • 暂无说说
  • '; + + talkTimer = setInterval(() => { + if (box.children.length > 0) { + box.appendChild(box.children[0]); + } + }, 3000); + } + + let cachedData = null; + let cachedTime = 0; + try { + const parsed = JSON.parse(localStorage.getItem(talksCacheKey) || 'null'); + if (Array.isArray(parsed)) cachedData = parsed; + cachedTime = Number(localStorage.getItem(talksCacheTimeKey)) || 0; + } catch { + /* Cache is optional. */ + } + const currentTime = new Date().getTime(); + + // 判断缓存是否有效 + if (cachedData && cachedTime && currentTime - cachedTime < talksCacheDuration) { + const data = toText(cachedData); + talk(data.slice(0, config.homeLimit || 6)); // 使用缓存渲染数据 + } else { + if (!config.apiUrl) { + talk([]); + return; } - if (!document.getElementById('bber-talk')) return; - const config = window.SITE_CONFIG?.talks || {}; - const talksCacheKey = config.cacheKey || cacheKey; - const talksCacheTimeKey = config.cacheTimeKey || cacheTimeKey; - const talksCacheDuration = config.cacheDurationMs || cacheDuration; + fetch(config.apiUrl, { + method: 'POST', + headers: { 'Content-Type': 'application/json' }, + body: JSON.stringify({ page: 1, pageSize: config.pageSize || 30 }), + }) + .then((res) => { + if (!res.ok) throw new Error(`HTTP ${res.status}`); + return res.json(); + }) + .then((data) => { + // 适配新版结构:code=1 且 data.items 存在 + if (data.code === 1 && data.data && Array.isArray(data.data.items)) { + try { + localStorage.setItem(talksCacheKey, JSON.stringify(data.data.items)); + localStorage.setItem(talksCacheTimeKey, currentTime.toString()); + } catch { + /* Rendering does not depend on cache availability. */ + } - function toText(ls) { - return ls.map(item => { - let c = String(item.content || '').replace(/[&<>"']/g, char => ({ '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' })[char]); - - const hasImg = /\!\[.*?\]\(.*?\)/.test(c); - const hasLink = /\[.*?\]\(.*?\)/.test(c); - - c = c - .replace(/#(.*?)\s/g, '') - .replace(/\{.*?\}/g, '') - .replace(/\!\[.*?\]\(.*?\)/g, '') - .replace(/\[.*?\]\(.*?\)/g, ''); - - const icons = []; - - if (item.images?.length && !hasImg) icons.push('fa-solid fa-image'); - if (item.extension_type === 'VIDEO') icons.push('fa-solid fa-video'); - if (item.extension_type === 'MUSIC') icons.push('fa-solid fa-music'); - if (item.extension_type === 'WEBSITE' && !hasLink) icons.push('fa-solid fa-link'); - if (item.extension_type === 'GITHUBPROJ' && !hasLink) icons.push('fab fa-github'); - - if (icons.length) c += ' ' + icons.map(i => ``).join(' '); - return c; - }); - } - - // 渲染与轮播 - function talk(ls) { - let html = ''; - ls.forEach((item, i) => { - html += `
  • ${item}
  • `; - }); - - let box = document.querySelector("#bber-talk .talk-list"); - if (!box) return; - - box.innerHTML = html || '
  • 暂无说说
  • '; - - talkTimer = setInterval(() => { - if (box.children.length > 0) { - box.appendChild(box.children[0]); - } - }, 3000); - } - - let cachedData = null; - let cachedTime = 0; - try { - const parsed = JSON.parse(localStorage.getItem(talksCacheKey) || 'null'); - if (Array.isArray(parsed)) cachedData = parsed; - cachedTime = Number(localStorage.getItem(talksCacheTimeKey)) || 0; - } catch { /* Cache is optional. */ } - const currentTime = new Date().getTime(); - - // 判断缓存是否有效 - if (cachedData && cachedTime && (currentTime - cachedTime < talksCacheDuration)) { - const data = toText(cachedData); - talk(data.slice(0, config.homeLimit || 6)); // 使用缓存渲染数据 - } else { - if (!config.apiUrl) { talk([]); return; } - - fetch(config.apiUrl, { - method: 'POST', - headers: { 'Content-Type': 'application/json' }, - body: JSON.stringify({ page: 1, pageSize: config.pageSize || 30 }) - }) - .then(res => { - if (!res.ok) throw new Error(`HTTP ${res.status}`); - return res.json(); - }) - .then(data => { - // 适配新版结构:code=1 且 data.items 存在 - if (data.code === 1 && data.data && Array.isArray(data.data.items)) { - try { - localStorage.setItem(talksCacheKey, JSON.stringify(data.data.items)); - localStorage.setItem(talksCacheTimeKey, currentTime.toString()); - } catch { /* Rendering does not depend on cache availability. */ } - - const formattedData = toText(data.data.items); - talk(formattedData.slice(0, config.homeLimit || 6)); - } else { - throw new Error('Unexpected API response format'); - } - }) - .catch(error => { - console.warn('说说加载失败:', error); - if (cachedData) talk(toText(cachedData).slice(0, config.homeLimit || 6)); - else { - const box = document.querySelector('#bber-talk .talk-list'); - if (box) box.innerHTML = '
  • 说说暂时无法加载
  • '; - } - }); - } + const formattedData = toText(data.data.items); + talk(formattedData.slice(0, config.homeLimit || 6)); + } else { + throw new Error('Unexpected API response format'); + } + }) + .catch((error) => { + console.warn('说说加载失败:', error); + if (cachedData) talk(toText(cachedData).slice(0, config.homeLimit || 6)); + else { + const box = document.querySelector('#bber-talk .talk-list'); + if (box) box.innerHTML = '
  • 说说暂时无法加载
  • '; + } + }); + } } // pjax 支持 function whenDOMReady() { - indexTalk(); + indexTalk(); } whenDOMReady(); -document.addEventListener("pjax:complete", whenDOMReady); +document.addEventListener('pjax:complete', whenDOMReady); diff --git a/scripts/generate-abbrlinks.mjs b/scripts/generate-abbrlinks.mjs index 8437380..1314986 100644 --- a/scripts/generate-abbrlinks.mjs +++ b/scripts/generate-abbrlinks.mjs @@ -99,7 +99,9 @@ async function main() { if (existing) { if (existingFiles.has(existing)) { - throw new Error(`Duplicate abbrlink "${existing}" in ${relative(process.cwd(), existingFiles.get(existing))} and ${relative(process.cwd(), file)}`); + throw new Error( + `Duplicate abbrlink "${existing}" in ${relative(process.cwd(), existingFiles.get(existing))} and ${relative(process.cwd(), file)}`, + ); } existingFiles.set(existing, file); usedAbbrlinks.add(existing); diff --git a/scripts/version-service-worker.mjs b/scripts/version-service-worker.mjs index 5aaef4a..c1ea38b 100644 --- a/scripts/version-service-worker.mjs +++ b/scripts/version-service-worker.mjs @@ -11,10 +11,12 @@ hash.update('\0'); async function collect(directory) { const entries = await readdir(directory, { withFileTypes: true }); - const files = await Promise.all(entries.map((entry) => { - const path = join(directory, entry.name); - return entry.isDirectory() ? collect(path) : [path]; - })); + const files = await Promise.all( + entries.map((entry) => { + const path = join(directory, entry.name); + return entry.isDirectory() ? collect(path) : [path]; + }), + ); return files.flat(); } @@ -26,6 +28,9 @@ for (const path of files) { hash.update('\0'); } -const versioned = source.replace(/^const CACHE_VERSION = '[^']+';/m, `const CACHE_VERSION = '${hash.digest('hex').slice(0, 16)}';`); +const versioned = source.replace( + /^const CACHE_VERSION = '[^']+';/m, + `const CACHE_VERSION = '${hash.digest('hex').slice(0, 16)}';`, +); if (versioned === source) throw new Error('Service worker cache version was not found'); await writeFile(worker, versioned); diff --git a/site.config.mjs b/site.config.mjs index d781ced..04e42d3 100644 --- a/site.config.mjs +++ b/site.config.mjs @@ -42,7 +42,12 @@ export const siteConfig = { social: [ { label: '发送邮件', href: 'mailto:bishsh2006@gmail.com', icon: 'fa-solid fa-envelope' }, { label: '订阅 RSS', href: '/rss/', icon: 'fa-solid fa-rss' }, - { label: 'GitHub', href: 'https://github.com/bishshi', icon: 'fa-brands fa-github', external: true }, + { + label: 'GitHub', + href: 'https://github.com/bishshi', + icon: 'fa-brands fa-github', + external: true, + }, ], pagination: { postsPerPage: 16, @@ -68,13 +73,7 @@ export const siteConfig = { }, externalLinks: { waitSeconds: 10, - whitelist: [ - 'blog.biss.click', - 'biss.click', - 'github.com', - 'localhost', - '127.0.0.1', - ], + whitelist: ['blog.biss.click', 'biss.click', 'github.com', 'localhost', '127.0.0.1'], }, talks: { apiUrl: 'https://mm.biss.click/api/echo/page', @@ -112,9 +111,11 @@ export const siteConfig = { cdn: { instantsearchCss: 'https://cdn.jsdmirror.com/npm/instantsearch.css/themes/reset-min.css', fancyboxCss: 'https://cdn.jsdmirror.com/npm/@fancyapps/ui@5.0/dist/fancybox/fancybox.css', - fontawesomeCss: 'https://cdn.jsdmirror.com/npm/@fortawesome/fontawesome-free@6.7.2/css/all.min.css', + fontawesomeCss: + 'https://cdn.jsdmirror.com/npm/@fortawesome/fontawesome-free@6.7.2/css/all.min.css', instantsearchJs: 'https://cdn.jsdmirror.com/npm/instantsearch.js@4.56.0', - typesenseAdapterJs: 'https://cdn.jsdmirror.com/npm/typesense-instantsearch-adapter@2.7.0/dist/typesense-instantsearch-adapter.min.js', + typesenseAdapterJs: + 'https://cdn.jsdmirror.com/npm/typesense-instantsearch-adapter@2.7.0/dist/typesense-instantsearch-adapter.min.js', fancyboxJs: 'https://cdn.jsdmirror.com/npm/@fancyapps/ui@5.0/dist/fancybox/fancybox.umd.js', jqueryJs: 'https://code.jquery.com/jquery-4.0.0.min.js', welcomeMessageJs: 'https://cdn.jsdmirror.com/gh/bishshi/welcomemessage/txmap.js', diff --git a/src/components/ArchiveTimeline.astro b/src/components/ArchiveTimeline.astro index 3c07667..545997e 100644 --- a/src/components/ArchiveTimeline.astro +++ b/src/components/ArchiveTimeline.astro @@ -49,31 +49,33 @@ const archiveYears = posts.reduce((years, post) => { ---
    - {archiveYears.map((yearGroup) => ( -
    - -
    -

    {yearGroup.year}

    - {yearGroup.count} 篇 -
    -
    - {yearGroup.months.map((monthGroup) => ( -
    -
    - {monthGroup.label} - {monthGroup.posts.length} 篇 -
    -
    - {monthGroup.posts.map((post) => ( - - - {post.title} - - ))} -
    -
    - ))} -
    -
    - ))} + { + archiveYears.map((yearGroup) => ( +
    +
    + )) + }
    diff --git a/src/components/ArticleSidebar.astro b/src/components/ArticleSidebar.astro index 8e2885c..98ed3f0 100644 --- a/src/components/ArticleSidebar.astro +++ b/src/components/ArticleSidebar.astro @@ -45,50 +45,67 @@ const tocSections = toc.reduce((sections, item) => { - {post.tags.length > 0 && ( - - )} + { + post.tags.length > 0 && ( + + ) + }
    - {toc.length > 0 && ( - - )} + { + toc.length > 0 && ( + + ) + } diff --git a/src/components/CustomContextMenu.astro b/src/components/CustomContextMenu.astro index 6f43094..1b00e11 100644 --- a/src/components/CustomContextMenu.astro +++ b/src/components/CustomContextMenu.astro @@ -23,7 +23,12 @@ 用 Bing 搜索 - @@ -76,7 +81,12 @@
    -
    +
    Ctrl + 右键:浏览器原生菜单
    @@ -97,7 +107,9 @@ const isNativeContextTarget = (target) => target instanceof Element && - Boolean(target.closest('input, textarea, select, [contenteditable="true"], [contenteditable=""]')); + Boolean( + target.closest('input, textarea, select, [contenteditable="true"], [contenteditable=""]'), + ); const getCommentsTarget = () => document.querySelector('.twikoo-comments, #twikoo-wrap, #twikoo, .tk-comments-container'); @@ -185,7 +197,9 @@ const quoteToComments = () => { jumpToComments(); window.setTimeout(() => { - const textarea = document.querySelector('#twikoo textarea, .twikoo-comments textarea, .tk-input textarea'); + const textarea = document.querySelector( + '#twikoo textarea, .twikoo-comments textarea, .tk-input textarea', + ); if (!(textarea instanceof HTMLTextAreaElement) || !lastSelectionText) return; const quote = lastSelectionText @@ -216,9 +230,7 @@ const response = await fetch(imageUrl, { mode: 'cors' }); const blob = await response.blob(); - await navigator.clipboard.write([ - new ClipboardItem({ [blob.type || 'image/png']: blob }), - ]); + await navigator.clipboard.write([new ClipboardItem({ [blob.type || 'image/png']: blob })]); } catch { await copyText(new URL(imageUrl, window.location.href).toString()); } @@ -227,7 +239,11 @@ const openImage = () => { const imageUrl = getImageUrl(); if (!imageUrl) return; - window.open(new URL(imageUrl, window.location.href).toString(), '_blank', 'noopener,noreferrer'); + window.open( + new URL(imageUrl, window.location.href).toString(), + '_blank', + 'noopener,noreferrer', + ); }; document.addEventListener('contextmenu', (event) => { @@ -247,7 +263,8 @@ }); document.addEventListener('click', (event) => { - const actionTarget = event.target instanceof Element ? event.target.closest('[data-context-action]') : null; + const actionTarget = + event.target instanceof Element ? event.target.closest('[data-context-action]') : null; if (!actionTarget || !menu.contains(actionTarget)) { closeMenu(); return; @@ -264,8 +281,10 @@ if (action === 'quote-selection') quoteToComments(); if (action === 'copy-image') copyImage(); if (action === 'open-image') openImage(); - if (action === 'copy-image-url') copyText(new URL(getImageUrl(), window.location.href).toString()); - if (action === 'random-post' && typeof window.randomPost === 'function') window.randomPost(actionTarget); + if (action === 'copy-image-url') + copyText(new URL(getImageUrl(), window.location.href).toString()); + if (action === 'random-post' && typeof window.randomPost === 'function') + window.randomPost(actionTarget); if (action === 'comments') jumpToComments(); if (action === 'print') window.print(); }); @@ -273,7 +292,9 @@ document.addEventListener('keydown', (event) => { if (event.key === 'Escape') closeMenu(); if (event.key === 'Tab' && menu.classList.contains('is-open')) { - const items = [...menu.querySelectorAll(focusableSelector)].filter((item) => !item.closest('[hidden]')); + const items = [...menu.querySelectorAll(focusableSelector)].filter( + (item) => !item.closest('[hidden]'), + ); if (items.length === 0) return; const first = items[0]; const last = items[items.length - 1]; diff --git a/src/components/HitokotoCard.astro b/src/components/HitokotoCard.astro index f319ab6..45d0ea7 100644 --- a/src/components/HitokotoCard.astro +++ b/src/components/HitokotoCard.astro @@ -1,19 +1,44 @@
    {currentPage < totalPages ? ( - + 下一页 ) : ( diff --git a/src/components/PostCard.astro b/src/components/PostCard.astro index f975c14..c42bd8d 100644 --- a/src/components/PostCard.astro +++ b/src/components/PostCard.astro @@ -7,9 +7,10 @@ interface Props { } const { post, index } = Astro.props; -const logNumber = index === undefined - ? post.date.toISOString().slice(5, 10).replace('-', '.') - : String(index + 1).padStart(2, '0'); +const logNumber = + index === undefined + ? post.date.toISOString().slice(5, 10).replace('-', '.') + : String(index + 1).padStart(2, '0'); ---
    diff --git a/src/components/PostChangelog.astro b/src/components/PostChangelog.astro index db7e510..8889cd6 100644 --- a/src/components/PostChangelog.astro +++ b/src/components/PostChangelog.astro @@ -10,7 +10,9 @@ const { entries } = Astro.props;
    - +
    REVISION HISTORY

    文章修订记录

    @@ -18,17 +20,19 @@ const { entries } = Astro.props; {entries.length} 次
      - {entries.map((entry) => ( -
    1. - -
      -
      -

      {entry.title}

      - {entry.date && } + { + entries.map((entry) => ( +
    2. +
    3. - ))} + + )) + }
    diff --git a/src/components/PostCopyrightCard.astro b/src/components/PostCopyrightCard.astro index 2c4f909..f787c8e 100644 --- a/src/components/PostCopyrightCard.astro +++ b/src/components/PostCopyrightCard.astro @@ -40,11 +40,15 @@ const tags = post.tags;
    - {tags.length > 0 && ( -
    - {tags.map((tag) => {tag})} -
    - )} + { + tags.length > 0 && ( +
    + {tags.map((tag) => ( + {tag} + ))} +
    + ) + }
    订阅 打赏 - + - +
    diff --git a/src/components/PostSeries.astro b/src/components/PostSeries.astro index 6fcb7f0..b6ee3bf 100644 --- a/src/components/PostSeries.astro +++ b/src/components/PostSeries.astro @@ -10,7 +10,8 @@ interface Props { const { currentPost, posts } = Astro.props; const currentIndex = posts.findIndex((post) => post.slug === currentPost.slug); const previousPost = currentIndex > 0 ? posts[currentIndex - 1] : undefined; -const nextPost = currentIndex >= 0 && currentIndex < posts.length - 1 ? posts[currentIndex + 1] : undefined; +const nextPost = + currentIndex >= 0 && currentIndex < posts.length - 1 ? posts[currentIndex + 1] : undefined; const labels = siteConfig.series?.labels ?? {}; const seriesKey = currentPost.series ?? ''; const seriesTitle = labels[seriesKey] ?? seriesKey; @@ -26,24 +27,38 @@ const seriesTitle = labels[seriesKey] ?? seriesKey;
      - {posts.map((post, index) => ( -
    1. - - {String(index + 1).padStart(2, '0')} - {post.title} - -
    2. - ))} + { + posts.map((post, index) => ( +
    3. + + {String(index + 1).padStart(2, '0')} + {post.title} + +
    4. + )) + }
    - {(previousPost || nextPost) && ( - - )} + { + (previousPost || nextPost) && ( + + ) + } diff --git a/src/components/SiteInfoCard.astro b/src/components/SiteInfoCard.astro index 01ac38c..65d10a8 100644 --- a/src/components/SiteInfoCard.astro +++ b/src/components/SiteInfoCard.astro @@ -28,15 +28,21 @@ const siteStats = [ const statsEndpoint = siteConfig.analytics.umami.statsEndpoint; --- -
    - {type === 'pie' ? ( -
    - - - {pieItems.map((item) => ( - - ))} - {total} - {totalLabel} - + { + type === 'pie' ? ( +
    + + + {pieItems.map((item) => ( + + ))} + + {total} + + + {totalLabel} + + -
    - {pieItems.map((item, index) => { - const content = ( - <> - - {item.label} - {item.value} - {item.percentText} - - ); +
    + {pieItems.map((item, index) => { + const content = ( + <> + + {item.label} + {item.value} + {item.percentText} + + ); - return item.href ? ( - - {content} - - ) : ( -
    - {content} -
    - ); - })} + return item.href ? ( + + {content} + + ) : ( +
    + {content} +
    + ); + })} +
    -
    - ) : ( -
    - - - - {[0, 0.5, 1].map((ratio) => ( - <> - - - {Math.round(maxValue * ratio)} - - - ))} - {linePoints.length > 0 && } - {linePoints.length > 0 && } - {linePoints.map((point, index) => ( - <> - - {`${point.label}: ${point.value} ${valueLabel}`} - {index % labelStep === 0 && ( - - {point.label} + ) : ( +
    + + + + {[0, 0.5, 1].map((ratio) => ( + <> + + + {Math.round(maxValue * ratio)} - )} - - ))} - -
    - )} + + ))} + {linePoints.length > 0 && } + {linePoints.length > 0 && } + {linePoints.map((point, index) => ( + <> + + {`${point.label}: ${point.value} ${valueLabel}`} + {index % labelStep === 0 && ( + + {point.label} + + )} + + ))} + +
    + ) + } diff --git a/src/components/TwikooComments.astro b/src/components/TwikooComments.astro index 7da4215..1a2f79d 100644 --- a/src/components/TwikooComments.astro +++ b/src/components/TwikooComments.astro @@ -23,7 +23,7 @@ const { envId, path, title, region = '' } = Astro.props;
    diff --git a/src/content.config.ts b/src/content.config.ts index 7652789..1b3565f 100644 --- a/src/content.config.ts +++ b/src/content.config.ts @@ -3,26 +3,31 @@ import { glob } from 'astro/loaders'; const posts = defineCollection({ loader: glob({ pattern: '**/*.md', base: './src/content/posts' }), - schema: z.object({ - title: z.string().trim().min(1), - date: z.union([z.string().refine((value) => !Number.isNaN(new Date(value).valueOf()), 'Invalid date'), z.date()]), - updated: z.any().optional(), - abbrlink: z.any().optional(), - tags: z.union([z.string(), z.array(z.string())]).nullish(), - category: z.union([z.string(), z.array(z.string())]).nullish(), - categories: z.union([z.string(), z.array(z.string())]).nullish(), - summary: z.any().optional(), - description: z.any().optional(), - comments: z.any().optional(), - cover: z.any().optional(), - series: z.any().optional(), - seriesOrder: z.any().optional(), - changelog: z.any().optional(), - newVersion: z.any().optional(), - newVersionTitle: z.any().optional(), - supersededBy: z.any().optional(), - replacement: z.any().optional(), - }).passthrough(), + schema: z + .object({ + title: z.string().trim().min(1), + date: z.union([ + z.string().refine((value) => !Number.isNaN(new Date(value).valueOf()), 'Invalid date'), + z.date(), + ]), + updated: z.any().optional(), + abbrlink: z.any().optional(), + tags: z.union([z.string(), z.array(z.string())]).nullish(), + category: z.union([z.string(), z.array(z.string())]).nullish(), + categories: z.union([z.string(), z.array(z.string())]).nullish(), + summary: z.any().optional(), + description: z.any().optional(), + comments: z.any().optional(), + cover: z.any().optional(), + series: z.any().optional(), + seriesOrder: z.any().optional(), + changelog: z.any().optional(), + newVersion: z.any().optional(), + newVersionTitle: z.any().optional(), + supersededBy: z.any().optional(), + replacement: z.any().optional(), + }) + .passthrough(), }); export const collections = { posts }; diff --git a/src/layouts/BaseLayout.astro b/src/layouts/BaseLayout.astro index 1e47cdd..9356021 100644 --- a/src/layouts/BaseLayout.astro +++ b/src/layouts/BaseLayout.astro @@ -34,7 +34,8 @@ const canonicalUrl = new URL(canonicalPath, siteConfig.site.url).href; const socialImageUrl = new URL(image, siteConfig.site.url).href; const jsonLdHtml = jsonLd ? JSON.stringify(jsonLd).replace(/ {keywords.length > 0 && } - - + + @@ -91,14 +102,17 @@ const consoleSites = [ {modifiedTime && } {type === 'article' && } {keywords.map((keyword) => )} - {jsonLd && } + {jsonLd && - + + } + {needsGallery && - + @@ -555,7 +600,10 @@ const articleJsonLd = { const codeLines = [...code.querySelectorAll(':scope > .line')]; if (codeLines.length > 0) { wrapper.classList.add('has-line-numbers'); - wrapper.style.setProperty('--line-number-width', `${String(codeLines.length).length + 1}ch`); + wrapper.style.setProperty( + '--line-number-width', + `${String(codeLines.length).length + 1}ch`, + ); codeLines.forEach((line, index) => { line.dataset.line = String(index + 1); }); diff --git a/src/pages/privacy.astro b/src/pages/privacy.astro index 201e6c1..ce7b9d8 100644 --- a/src/pages/privacy.astro +++ b/src/pages/privacy.astro @@ -33,16 +33,22 @@ import { siteConfig } from '../../site.config.mjs';

    第三方服务

    - 本站可能使用 CDN、评论、头像、搜索或统计分析服务。第三方服务会根据其自身政策处理数据,建议你阅读对应服务的隐私说明。 + 本站可能使用 + CDN、评论、头像、搜索或统计分析服务。第三方服务会根据其自身政策处理数据,建议你阅读对应服务的隐私说明。

    Cookie 与本地存储

    - 关于 Cookie 和 LocalStorage 的更多说明,请查看 Cookies 页面。你可以在浏览器中清除这些数据。 + 关于 Cookie 和 LocalStorage 的更多说明,请查看 Cookies 页面。你可以在浏览器中清除这些数据。

    联系

    -

    如果你希望删除评论或询问隐私相关问题,可以发送邮件至 {siteConfig.author.email}。

    +

    + 如果你希望删除评论或询问隐私相关问题,可以发送邮件至 {siteConfig.author.email}。 +

    diff --git a/src/pages/rss.astro b/src/pages/rss.astro index 418528b..6a454d6 100644 --- a/src/pages/rss.astro +++ b/src/pages/rss.astro @@ -14,7 +14,10 @@ const feedUrl = new URL('/rss.xml', siteConfig.site.url).href; canonicalPath="/rss/" >
    - +
    @@ -80,7 +93,8 @@ const feedUrl = new URL('/rss.xml', siteConfig.site.url).href; } } - if (copyStatus) copyStatus.textContent = copied ? '订阅地址已复制。' : '复制失败,请手动选择上面的地址。'; + if (copyStatus) + copyStatus.textContent = copied ? '订阅地址已复制。' : '复制失败,请手动选择上面的地址。'; const label = copyButton.querySelector('span'); if (label && copied) { label.textContent = '已复制'; diff --git a/src/pages/shuoshuo.astro b/src/pages/shuoshuo.astro index 2c0015e..9d33328 100644 --- a/src/pages/shuoshuo.astro +++ b/src/pages/shuoshuo.astro @@ -24,7 +24,12 @@ const title = '说说';
    - + diff --git a/src/pages/tags/index.astro b/src/pages/tags/index.astro index 0c7d75a..a7e2fbe 100644 --- a/src/pages/tags/index.astro +++ b/src/pages/tags/index.astro @@ -16,14 +16,21 @@ const tagStats = tags.map((tag) => ({
    - +
    - {tagStats.map((tag) => ( - - {tag.label} - {tag.value} - - ))} + { + tagStats.map((tag) => ( + + {tag.label} + {tag.value} + + )) + }
    diff --git a/src/styles/site.css b/src/styles/site.css index 4668557..9d56a79 100644 --- a/src/styles/site.css +++ b/src/styles/site.css @@ -1,18 +1,18 @@ -@import "./site/01-base.css"; -@import "./site/02-navigation.css"; -@import "./site/03-overlays.css"; -@import "./site/04-layout.css"; -@import "./site/05-cards-sidebar.css"; -@import "./site/06-article-prose.css"; -@import "./site/07-post-comments.css"; -@import "./site/08-archives-stats.css"; -@import "./site/09-shuoshuo.css"; -@import "./site/10-pages.css"; -@import "./site/11-footer.css"; -@import "./site/12-theme.css"; -@import "./site/13-responsive.css"; -@import "./site/14-animations.css"; -@import "./site/15-reading-series.css"; -@import "./site/16-pwa.css"; -@import "./site/17-revisions.css"; -@import "./site/18-worklog.css"; +@import './site/01-base.css'; +@import './site/02-navigation.css'; +@import './site/03-overlays.css'; +@import './site/04-layout.css'; +@import './site/05-cards-sidebar.css'; +@import './site/06-article-prose.css'; +@import './site/07-post-comments.css'; +@import './site/08-archives-stats.css'; +@import './site/09-shuoshuo.css'; +@import './site/10-pages.css'; +@import './site/11-footer.css'; +@import './site/12-theme.css'; +@import './site/13-responsive.css'; +@import './site/14-animations.css'; +@import './site/15-reading-series.css'; +@import './site/16-pwa.css'; +@import './site/17-revisions.css'; +@import './site/18-worklog.css'; diff --git a/src/styles/site/01-base.css b/src/styles/site/01-base.css index 10d917c..5162ede 100644 --- a/src/styles/site/01-base.css +++ b/src/styles/site/01-base.css @@ -1,4 +1,4 @@ -@import url("https://fontsapi.zeoseven.com/7/main/result.css"); +@import url('https://fontsapi.zeoseven.com/7/main/result.css'); :root { color-scheme: light; @@ -42,7 +42,7 @@ html { body { margin: 0; color: var(--text); - font-family: "Zhuque Fangsong (technical preview)"; + font-family: 'Zhuque Fangsong (technical preview)'; font-weight: normal; line-height: 1.75; background: @@ -63,4 +63,3 @@ a { color: inherit; text-decoration: none; } - diff --git a/src/styles/site/02-navigation.css b/src/styles/site/02-navigation.css index ede6552..dd4fee9 100644 --- a/src/styles/site/02-navigation.css +++ b/src/styles/site/02-navigation.css @@ -31,7 +31,7 @@ } .nav::before { - content: ""; + content: ''; position: absolute; inset: 0; background: @@ -140,12 +140,16 @@ } .nav-random::after { - content: ""; + content: ''; position: absolute; inset: 3px; border-radius: inherit; - background: - linear-gradient(120deg, transparent 8%, rgba(255, 255, 255, 0.82) 34%, transparent 58%); + background: linear-gradient( + 120deg, + transparent 8%, + rgba(255, 255, 255, 0.82) 34%, + transparent 58% + ); opacity: 0; transform: translateX(-135%); pointer-events: none; @@ -381,4 +385,3 @@ 0 8px 18px rgba(15, 118, 110, 0.1); transform: translateY(-1px); } - diff --git a/src/styles/site/03-overlays.css b/src/styles/site/03-overlays.css index fcae75e..e1e72bb 100644 --- a/src/styles/site/03-overlays.css +++ b/src/styles/site/03-overlays.css @@ -93,7 +93,7 @@ .random-post-transition-card::before, .random-post-transition-card::after { - content: ""; + content: ''; position: absolute; inset: -10px; border: 1px solid rgba(15, 118, 110, 0.24); @@ -121,7 +121,7 @@ } .random-post-transition-card span::after { - content: ""; + content: ''; display: inline-block; width: 1.25em; text-align: left; @@ -329,8 +329,7 @@ :root[data-theme='dark'] .nav { border-color: rgba(166, 184, 194, 0.2); background: - linear-gradient(135deg, rgba(25, 35, 42, 0.82), rgba(10, 15, 20, 0.66)), - rgba(10, 15, 20, 0.68); + linear-gradient(135deg, rgba(25, 35, 42, 0.82), rgba(10, 15, 20, 0.66)), rgba(10, 15, 20, 0.68); box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.12), inset 0 -18px 38px rgba(0, 0, 0, 0.18), @@ -376,8 +375,7 @@ :root[data-theme='dark'] .random-post-transition-card { border-color: rgba(166, 184, 194, 0.22); background: - linear-gradient(135deg, rgba(25, 35, 42, 0.9), rgba(10, 17, 22, 0.76)), - rgba(14, 22, 28, 0.84); + linear-gradient(135deg, rgba(25, 35, 42, 0.9), rgba(10, 17, 22, 0.76)), rgba(14, 22, 28, 0.84); box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1), 0 28px 74px rgba(0, 0, 0, 0.42); @@ -392,8 +390,7 @@ border-color: rgba(166, 184, 194, 0.2); color: #edf7f5; background: - linear-gradient(135deg, rgba(25, 35, 42, 0.88), rgba(10, 17, 22, 0.72)), - rgba(14, 22, 28, 0.78); + linear-gradient(135deg, rgba(25, 35, 42, 0.88), rgba(10, 17, 22, 0.72)), rgba(14, 22, 28, 0.78); box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1), 0 22px 54px rgba(0, 0, 0, 0.34); @@ -407,8 +404,7 @@ border-color: rgba(166, 184, 194, 0.2); background: radial-gradient(circle at 14% 0%, rgba(125, 211, 199, 0.08), transparent 34%), - linear-gradient(145deg, rgba(24, 34, 42, 0.9), rgba(10, 17, 22, 0.84)), - rgba(14, 22, 28, 0.84); + linear-gradient(145deg, rgba(24, 34, 42, 0.9), rgba(10, 17, 22, 0.84)), rgba(14, 22, 28, 0.84); box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1), 0 28px 80px rgba(0, 0, 0, 0.46); @@ -437,8 +433,7 @@ border-color: rgba(166, 184, 194, 0.2); color: #e2ecef; background: - linear-gradient(145deg, rgba(27, 39, 47, 0.9), rgba(10, 17, 22, 0.82)), - rgba(14, 22, 28, 0.84); + linear-gradient(145deg, rgba(27, 39, 47, 0.9), rgba(10, 17, 22, 0.82)), rgba(14, 22, 28, 0.84); box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1), 0 18px 42px rgba(0, 0, 0, 0.42); @@ -469,8 +464,7 @@ border-color: rgba(166, 184, 194, 0.2); color: #e2ecef; background: - linear-gradient(145deg, rgba(27, 39, 47, 0.9), rgba(10, 17, 22, 0.82)), - rgba(14, 22, 28, 0.84); + linear-gradient(145deg, rgba(27, 39, 47, 0.9), rgba(10, 17, 22, 0.82)), rgba(14, 22, 28, 0.84); box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1), 0 12px 30px rgba(0, 0, 0, 0.32); @@ -482,4 +476,3 @@ background: rgba(255, 255, 255, 0.08); box-shadow: inset 0 -1px 0 rgba(0, 0, 0, 0.18); } - diff --git a/src/styles/site/04-layout.css b/src/styles/site/04-layout.css index 142af6d..ee5a6f7 100644 --- a/src/styles/site/04-layout.css +++ b/src/styles/site/04-layout.css @@ -95,7 +95,7 @@ } .hero-talk .talk-list:empty::before { - content: "说说加载中..."; + content: '说说加载中...'; display: grid; min-height: 58px; align-items: center; @@ -120,7 +120,7 @@ } .hero-talk .item::before { - content: ""; + content: ''; width: 7px; height: 7px; flex: 0 0 auto; @@ -168,7 +168,7 @@ } .page-header-card::after { - content: ""; + content: ''; position: absolute; top: 10px; right: 18px; @@ -258,4 +258,3 @@ .section-heading a { color: var(--muted); } - diff --git a/src/styles/site/05-cards-sidebar.css b/src/styles/site/05-cards-sidebar.css index 83e9f2f..8c9792c 100644 --- a/src/styles/site/05-cards-sidebar.css +++ b/src/styles/site/05-cards-sidebar.css @@ -86,7 +86,7 @@ .profile-name { margin-bottom: 16px; - font-family: Georgia, "Times New Roman", serif; + font-family: Georgia, 'Times New Roman', serif; color: #585b5e; font-size: 1.9rem; letter-spacing: 0; @@ -420,7 +420,14 @@ .article-author-card .profile-name { margin-bottom: 8px; - font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; + font-family: + Inter, + ui-sans-serif, + system-ui, + -apple-system, + BlinkMacSystemFont, + 'Segoe UI', + sans-serif; font-size: 1.45rem; font-weight: 800; } @@ -451,7 +458,7 @@ } .toc-list::before { - content: ""; + content: ''; position: absolute; top: 0; right: 0; @@ -626,4 +633,3 @@ time { font-size: 0.86rem; background: rgba(236, 253, 245, 0.7); } - diff --git a/src/styles/site/06-article-prose.css b/src/styles/site/06-article-prose.css index 1de4aac..f61ddca 100644 --- a/src/styles/site/06-article-prose.css +++ b/src/styles/site/06-article-prose.css @@ -54,7 +54,7 @@ .article-header-cover::before, .article-header-cover::after { - content: ""; + content: ''; position: absolute; inset: 0; pointer-events: none; @@ -63,8 +63,18 @@ .article-header-cover::before { z-index: 1; background: - linear-gradient(180deg, rgba(23, 55, 48, 0.42), rgba(23, 55, 48, 0.18) 38%, rgba(12, 31, 28, 0.68)), - linear-gradient(90deg, rgba(13, 55, 49, 0.52), rgba(19, 90, 79, 0.14) 54%, rgba(13, 55, 49, 0.36)); + linear-gradient( + 180deg, + rgba(23, 55, 48, 0.42), + rgba(23, 55, 48, 0.18) 38%, + rgba(12, 31, 28, 0.68) + ), + linear-gradient( + 90deg, + rgba(13, 55, 49, 0.52), + rgba(19, 90, 79, 0.14) 54%, + rgba(13, 55, 49, 0.36) + ); } .article-header-cover::after { @@ -98,7 +108,7 @@ max-width: 920px; margin: 0; color: #fff; - font-family: Georgia, "Times New Roman", "Microsoft YaHei", serif; + font-family: Georgia, 'Times New Roman', 'Microsoft YaHei', serif; font-size: clamp(2.4rem, 6vw, 4.2rem); font-weight: 700; line-height: 1.12; @@ -123,7 +133,7 @@ .article-hero-meta span:not(:first-child)::before, .article-hero-meta a::before { - content: "|"; + content: '|'; margin-right: 12px; color: rgba(255, 255, 255, 0.62); font-weight: 400; @@ -149,7 +159,7 @@ } .article-summary-card::before { - content: ""; + content: ''; position: absolute; top: 0; bottom: 0; @@ -174,7 +184,7 @@ z-index: 1; margin: 0; color: #465552; - font-family: "LXGW WenKai", "霞鹜文楷", "Microsoft YaHei", ui-sans-serif, system-ui, sans-serif; + font-family: 'LXGW WenKai', '霞鹜文楷', 'Microsoft YaHei', ui-sans-serif, system-ui, sans-serif; font-size: 1rem; line-height: 1.8; overflow-wrap: anywhere; @@ -195,7 +205,7 @@ align-items: center; gap: 8px; color: #376d67; - font-family: "JetBrains Mono", Consolas, "Microsoft YaHei", monospace; + font-family: 'JetBrains Mono', Consolas, 'Microsoft YaHei', monospace; font-size: 0.86rem; font-weight: 800; } @@ -217,7 +227,10 @@ border-radius: 999px; padding: 4px 9px; color: rgba(55, 109, 103, 0.72); - font: 700 0.7rem/1.2 "JetBrains Mono", Consolas, monospace; + font: + 700 0.7rem/1.2 'JetBrains Mono', + Consolas, + monospace; letter-spacing: 0.06em; background: rgba(255, 255, 255, 0.56); white-space: nowrap; @@ -349,7 +362,7 @@ } .prose code { - font-family: "JetBrains Mono", Consolas, monospace; + font-family: 'JetBrains Mono', Consolas, monospace; } .prose :not(pre) > code { @@ -665,7 +678,7 @@ } .prose .code-block.is-collapsible:not(.is-expanded)::after { - content: ""; + content: ''; position: absolute; z-index: 1; right: 0; @@ -744,7 +757,7 @@ .code-block-language { overflow: hidden; color: rgba(232, 237, 242, 0.72); - font-family: "JetBrains Mono", Consolas, monospace; + font-family: 'JetBrains Mono', Consolas, monospace; font-size: 0.8rem; font-weight: 800; letter-spacing: 0; @@ -792,7 +805,14 @@ border-radius: 7px; padding: 6px 10px; color: rgba(255, 255, 255, 0.86); - font: 700 0.78rem/1 Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; + font: + 700 0.78rem/1 Inter, + ui-sans-serif, + system-ui, + -apple-system, + BlinkMacSystemFont, + 'Segoe UI', + sans-serif; background: rgba(255, 255, 255, 0.1); cursor: pointer; backdrop-filter: blur(8px); @@ -890,7 +910,7 @@ color: #223833; } -.prose mjx-container[display="true"] { +.prose mjx-container[display='true'] { max-width: 100%; margin: 1.35em 0; overflow-x: auto; @@ -900,19 +920,18 @@ scrollbar-width: thin; } -.prose mjx-container[display="true"]::-webkit-scrollbar { +.prose mjx-container[display='true']::-webkit-scrollbar { height: 8px; } -.prose mjx-container[display="true"]::-webkit-scrollbar-track { +.prose mjx-container[display='true']::-webkit-scrollbar-track { border-radius: 999px; background: rgba(15, 118, 110, 0.08); } -.prose mjx-container[display="true"]::-webkit-scrollbar-thumb { +.prose mjx-container[display='true']::-webkit-scrollbar-thumb { border-radius: 999px; background: linear-gradient(90deg, rgba(102, 200, 245, 0.72), rgba(62, 184, 190, 0.76)), rgba(62, 184, 190, 0.72); } - diff --git a/src/styles/site/07-post-comments.css b/src/styles/site/07-post-comments.css index 5dbba51..e71a446 100644 --- a/src/styles/site/07-post-comments.css +++ b/src/styles/site/07-post-comments.css @@ -18,15 +18,20 @@ } .post-copyright-card::before { - content: ""; + content: ''; position: absolute; inset: 0; - background: linear-gradient(135deg, rgba(255, 255, 255, 0.44), transparent 44%, rgba(255, 255, 255, 0.22)); + background: linear-gradient( + 135deg, + rgba(255, 255, 255, 0.44), + transparent 44%, + rgba(255, 255, 255, 0.22) + ); pointer-events: none; } .post-copyright-card::after { - content: ""; + content: ''; position: absolute; top: 8px; right: 16px; @@ -55,7 +60,7 @@ border: 1px solid rgba(15, 118, 110, 0.12); border-radius: 999px; color: rgba(15, 118, 110, 0.16); - font-family: Georgia, "Times New Roman", serif; + font-family: Georgia, 'Times New Roman', serif; font-size: clamp(1.85rem, 5vw, 3.4rem); font-weight: 900; line-height: 1; @@ -274,4 +279,3 @@ .twikoo-comments :where(.tk-comments-container, .tk-submit) { color: var(--text); } - diff --git a/src/styles/site/08-archives-stats.css b/src/styles/site/08-archives-stats.css index 83edba8..6ae85dc 100644 --- a/src/styles/site/08-archives-stats.css +++ b/src/styles/site/08-archives-stats.css @@ -7,7 +7,7 @@ } .archive-timeline::before { - content: ""; + content: ''; position: absolute; top: 10px; bottom: 10px; @@ -399,4 +399,3 @@ a.chart-legend-item:hover { fill: var(--muted); font-size: 0.78rem; } - diff --git a/src/styles/site/09-shuoshuo.css b/src/styles/site/09-shuoshuo.css index 5c053e9..c596113 100644 --- a/src/styles/site/09-shuoshuo.css +++ b/src/styles/site/09-shuoshuo.css @@ -9,7 +9,7 @@ } #talk:empty::before { - content: "说说加载中..."; + content: '说说加载中...'; display: grid; min-height: 180px; place-items: center; @@ -269,8 +269,7 @@ meting-js { border-color: rgba(181, 198, 207, 0.24); background: radial-gradient(circle at 14% 0%, rgba(139, 224, 213, 0.1), transparent 34%), - linear-gradient(145deg, rgba(22, 32, 39, 0.92), rgba(8, 14, 19, 0.86)), - rgba(12, 19, 25, 0.88); + linear-gradient(145deg, rgba(22, 32, 39, 0.92), rgba(8, 14, 19, 0.86)), rgba(12, 19, 25, 0.88); box-shadow: var(--shadow); } @@ -295,8 +294,7 @@ meting-js { :root[data-theme='dark'] .hero-talk { border-color: rgba(181, 198, 207, 0.24); background: - linear-gradient(135deg, rgba(22, 32, 39, 0.78), rgba(8, 14, 19, 0.72)), - rgba(12, 19, 25, 0.74); + linear-gradient(135deg, rgba(22, 32, 39, 0.78), rgba(8, 14, 19, 0.72)), rgba(12, 19, 25, 0.74); box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1), 0 18px 46px rgba(0, 0, 0, 0.34); @@ -311,4 +309,3 @@ meting-js { border-color: rgba(139, 224, 213, 0.28); background: rgba(139, 224, 213, 0.13); } - diff --git a/src/styles/site/10-pages.css b/src/styles/site/10-pages.css index ff94069..f809aad 100644 --- a/src/styles/site/10-pages.css +++ b/src/styles/site/10-pages.css @@ -63,7 +63,7 @@ .external-redirect-target code { overflow-wrap: anywhere; color: #33433f; - font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace; + font-family: ui-monospace, SFMono-Regular, Consolas, 'Liberation Mono', monospace; font-size: 0.92rem; } @@ -255,8 +255,7 @@ border-color: rgba(181, 198, 207, 0.24); background: radial-gradient(circle at 14% 0%, rgba(139, 224, 213, 0.1), transparent 34%), - linear-gradient(145deg, rgba(22, 32, 39, 0.92), rgba(8, 14, 19, 0.86)), - rgba(12, 19, 25, 0.88); + linear-gradient(145deg, rgba(22, 32, 39, 0.92), rgba(8, 14, 19, 0.86)), rgba(12, 19, 25, 0.88); box-shadow: var(--shadow); } @@ -284,4 +283,3 @@ :root[data-theme='dark'] .friend-link-card strong { color: #edf7f5; } - diff --git a/src/styles/site/11-footer.css b/src/styles/site/11-footer.css index d47054d..c5f6c55 100644 --- a/src/styles/site/11-footer.css +++ b/src/styles/site/11-footer.css @@ -147,4 +147,3 @@ justify-items: end; text-align: right; } - diff --git a/src/styles/site/12-theme.css b/src/styles/site/12-theme.css index d61e09e..ed13b0a 100644 --- a/src/styles/site/12-theme.css +++ b/src/styles/site/12-theme.css @@ -1,49 +1,47 @@ -:root[data-theme='dark'] :where( - .page-header-card, - .post-card, - .sidebar-card, - .article, - .article-summary-card, - .post-copyright-card, - .twikoo-comments, - .table-scroll, - .stats-chart, - .term-grid a, - .pagination-link, - .pagination-number -) { +:root[data-theme='dark'] + :where( + .page-header-card, + .post-card, + .sidebar-card, + .article, + .article-summary-card, + .post-copyright-card, + .twikoo-comments, + .table-scroll, + .stats-chart, + .term-grid a, + .pagination-link, + .pagination-number + ) { border-color: rgba(181, 198, 207, 0.24); background: radial-gradient(circle at 14% 0%, rgba(139, 224, 213, 0.1), transparent 34%), - linear-gradient(145deg, rgba(22, 32, 39, 0.92), rgba(8, 14, 19, 0.86)), - rgba(12, 19, 25, 0.88); + linear-gradient(145deg, rgba(22, 32, 39, 0.92), rgba(8, 14, 19, 0.86)), rgba(12, 19, 25, 0.88); box-shadow: var(--shadow); } -:root[data-theme='dark'] :where( - .page-header-card::after, - .post-copyright-card::after -) { +:root[data-theme='dark'] :where(.page-header-card::after, .post-copyright-card::after) { background: rgba(255, 255, 255, 0.12); } -:root[data-theme='dark'] :where( - .page-header-card h1, - .content-wrap .page-header-card h1, - .sidebar-card h2, - .stats-chart-head h2, - .chart-legend-item strong, - .pie-chart-total, - .profile-name, - .calendar-summary strong, - .schedule-left strong, - .sidebar-post strong, - .toc-link-main, - .post-copyright-card h2, - .post-copyright-meta dd, - .twikoo-comments h2, - .footer-brand -) { +:root[data-theme='dark'] + :where( + .page-header-card h1, + .content-wrap .page-header-card h1, + .sidebar-card h2, + .stats-chart-head h2, + .chart-legend-item strong, + .pie-chart-total, + .profile-name, + .calendar-summary strong, + .schedule-left strong, + .sidebar-post strong, + .toc-link-main, + .post-copyright-card h2, + .post-copyright-meta dd, + .twikoo-comments h2, + .footer-brand + ) { color: #edf7f5; } @@ -65,16 +63,17 @@ text-shadow: 0 1px 12px rgba(0, 0, 0, 0.48); } -:root[data-theme='dark'] :where( - .notice-card p, - #welcome-info, - #welcome-ip-location-info, - .site-info-list dt, - .toc-link-child, - .same-category-list a, - .profile-links, - .footer-contact p -) { +:root[data-theme='dark'] + :where( + .notice-card p, + #welcome-info, + #welcome-ip-location-info, + .site-info-list dt, + .toc-link-child, + .same-category-list a, + .profile-links, + .footer-contact p + ) { color: #c4d0d5; } @@ -99,30 +98,32 @@ border-top-color: rgba(181, 198, 207, 0.22); } -:root[data-theme='dark'] :where( - .meta-list a, - .article-tag-list a, - .post-copyright-tags a, - .post-copyright-action, - .post-copyright-icon -) { +:root[data-theme='dark'] + :where( + .meta-list a, + .article-tag-list a, + .post-copyright-tags a, + .post-copyright-action, + .post-copyright-icon + ) { border-color: rgba(139, 224, 213, 0.28); color: var(--accent); background: rgba(139, 224, 213, 0.13); box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08); } -:root[data-theme='dark'] :where( - .follow-button, - .calendar-grid .today, - .post-copyright-action.is-primary, - .post-copyright-tags a:hover, - .post-copyright-action:hover, - .post-copyright-icon:hover, - .pagination-link:hover, - .pagination-number:hover, - .pagination-number.is-current -) { +:root[data-theme='dark'] + :where( + .follow-button, + .calendar-grid .today, + .post-copyright-action.is-primary, + .post-copyright-tags a:hover, + .post-copyright-action:hover, + .post-copyright-icon:hover, + .pagination-link:hover, + .pagination-number:hover, + .pagination-number.is-current + ) { color: #081315; background: var(--accent); } @@ -196,8 +197,7 @@ :root[data-theme='dark'] .prose thead th { color: #effaf7; background: - linear-gradient(135deg, rgba(35, 55, 61, 0.86), rgba(18, 31, 38, 0.78)), - rgba(12, 21, 27, 0.84); + linear-gradient(135deg, rgba(35, 55, 61, 0.86), rgba(18, 31, 38, 0.78)), rgba(12, 21, 27, 0.84); } :root[data-theme='dark'] .prose tbody tr:nth-child(even) td { @@ -215,8 +215,7 @@ :root[data-theme='dark'] .site-footer { color: rgba(218, 228, 232, 0.86); background: - linear-gradient(180deg, rgba(10, 16, 21, 0.82), rgba(6, 10, 14, 0.94)), - rgba(7, 11, 15, 0.92); + linear-gradient(180deg, rgba(10, 16, 21, 0.82), rgba(6, 10, 14, 0.94)), rgba(7, 11, 15, 0.92); box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08); } @@ -224,8 +223,7 @@ border-color: rgba(181, 198, 207, 0.24); color: rgba(231, 240, 243, 0.9); background: - linear-gradient(145deg, rgba(28, 40, 48, 0.8), rgba(10, 17, 22, 0.74)), - rgba(14, 22, 28, 0.74); + linear-gradient(145deg, rgba(28, 40, 48, 0.8), rgba(10, 17, 22, 0.74)), rgba(14, 22, 28, 0.74); box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08), 0 10px 24px rgba(0, 0, 0, 0.3); @@ -234,4 +232,3 @@ :root[data-theme='dark'] .footer-bottom { border-top-color: rgba(181, 198, 207, 0.22); } - diff --git a/src/styles/site/13-responsive.css b/src/styles/site/13-responsive.css index efaca98..3e41279 100644 --- a/src/styles/site/13-responsive.css +++ b/src/styles/site/13-responsive.css @@ -466,4 +466,3 @@ text-align: center; } } - diff --git a/src/styles/site/14-animations.css b/src/styles/site/14-animations.css index f1ef974..ffc0273 100644 --- a/src/styles/site/14-animations.css +++ b/src/styles/site/14-animations.css @@ -60,20 +60,20 @@ @keyframes random-loading-dots { 0% { - content: ""; + content: ''; } 25% { - content: "."; + content: '.'; } 50% { - content: ".."; + content: '..'; } 75%, 100% { - content: "..."; + content: '...'; } } diff --git a/src/styles/site/15-reading-series.css b/src/styles/site/15-reading-series.css index 9b6e725..1ea0a06 100644 --- a/src/styles/site/15-reading-series.css +++ b/src/styles/site/15-reading-series.css @@ -40,7 +40,9 @@ animation: reading-resume-in 0.3s ease both; } -.reading-resume[hidden] { display: none; } +.reading-resume[hidden] { + display: none; +} .reading-resume-icon { display: grid; @@ -53,10 +55,18 @@ } .reading-resume strong, -.reading-resume p { margin: 0; } -.reading-resume p { color: var(--muted); font-size: 0.88rem; } +.reading-resume p { + margin: 0; +} +.reading-resume p { + color: var(--muted); + font-size: 0.88rem; +} -.reading-resume-actions { display: flex; gap: 7px; } +.reading-resume-actions { + display: flex; + gap: 7px; +} .reading-resume button { border: 1px solid rgba(15, 118, 110, 0.18); border-radius: 999px; @@ -68,7 +78,10 @@ background: rgba(236, 253, 245, 0.72); cursor: pointer; } -.reading-resume button:first-child { color: #fff; background: #3eb8be; } +.reading-resume button:first-child { + color: #fff; + background: #3eb8be; +} .post-series { margin: 0 0 30px; @@ -86,9 +99,21 @@ padding: 18px 20px; border-bottom: 1px solid rgba(15, 118, 110, 0.14); } -.post-series-head span { color: var(--accent); font-size: 0.72rem; font-weight: 900; letter-spacing: 0.1em; } -.post-series-head h2 { margin: 2px 0 0; font-size: 1.25rem; } -.post-series-head > strong { color: var(--muted); font-size: 0.86rem; white-space: nowrap; } +.post-series-head span { + color: var(--accent); + font-size: 0.72rem; + font-weight: 900; + letter-spacing: 0.1em; +} +.post-series-head h2 { + margin: 2px 0 0; + font-size: 1.25rem; +} +.post-series-head > strong { + color: var(--muted); + font-size: 0.86rem; + white-space: nowrap; +} .post-series-list { display: grid; @@ -106,20 +131,49 @@ border-radius: 8px; padding: 8px 10px; } -.post-series-list a:hover { background: rgba(62, 184, 190, 0.1); } -.post-series-list li.is-current a { color: #fff; background: #3eb8be; } -.post-series-list span { font-variant-numeric: tabular-nums; opacity: 0.7; } -.post-series-list strong { overflow: hidden; font-size: 0.92rem; text-overflow: ellipsis; white-space: nowrap; } +.post-series-list a:hover { + background: rgba(62, 184, 190, 0.1); +} +.post-series-list li.is-current a { + color: #fff; + background: #3eb8be; +} +.post-series-list span { + font-variant-numeric: tabular-nums; + opacity: 0.7; +} +.post-series-list strong { + overflow: hidden; + font-size: 0.92rem; + text-overflow: ellipsis; + white-space: nowrap; +} .post-series-nav { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); border-top: 1px solid rgba(15, 118, 110, 0.14); } -.post-series-nav a { display: grid; gap: 2px; padding: 13px 18px; } -.post-series-nav a:last-child { text-align: right; border-left: 1px solid rgba(15, 118, 110, 0.14); } -.post-series-nav span { color: var(--muted); font-size: 0.76rem; } -.post-series-nav strong { overflow: hidden; color: var(--accent); font-size: 0.88rem; text-overflow: ellipsis; white-space: nowrap; } +.post-series-nav a { + display: grid; + gap: 2px; + padding: 13px 18px; +} +.post-series-nav a:last-child { + text-align: right; + border-left: 1px solid rgba(15, 118, 110, 0.14); +} +.post-series-nav span { + color: var(--muted); + font-size: 0.76rem; +} +.post-series-nav strong { + overflow: hidden; + color: var(--accent); + font-size: 0.88rem; + text-overflow: ellipsis; + white-space: nowrap; +} :root[data-theme='dark'] .reading-resume, :root[data-theme='dark'] .post-series { @@ -127,11 +181,19 @@ color: #edf7f5; background: rgba(13, 23, 29, 0.92); } -:root[data-theme='dark'] .post-series-list a:hover { background: rgba(139, 224, 213, 0.1); } +:root[data-theme='dark'] .post-series-list a:hover { + background: rgba(139, 224, 213, 0.1); +} @keyframes reading-resume-in { - from { opacity: 0; transform: translateY(16px); } - to { opacity: 1; transform: translateY(0); } + from { + opacity: 0; + transform: translateY(16px); + } + to { + opacity: 1; + transform: translateY(0); + } } @media (max-width: 720px) { @@ -140,14 +202,32 @@ bottom: 16px; grid-template-columns: 38px minmax(0, 1fr); } - .reading-resume-icon { width: 38px; height: 38px; } - .reading-resume-actions { grid-column: 1 / -1; } - .reading-resume button { flex: 1; } - .post-series-head { align-items: start; flex-direction: column; gap: 6px; } - .post-series-nav { grid-template-columns: 1fr; } - .post-series-nav a:last-child { border-top: 1px solid rgba(15, 118, 110, 0.14); border-left: 0; } + .reading-resume-icon { + width: 38px; + height: 38px; + } + .reading-resume-actions { + grid-column: 1 / -1; + } + .reading-resume button { + flex: 1; + } + .post-series-head { + align-items: start; + flex-direction: column; + gap: 6px; + } + .post-series-nav { + grid-template-columns: 1fr; + } + .post-series-nav a:last-child { + border-top: 1px solid rgba(15, 118, 110, 0.14); + border-left: 0; + } } @media (prefers-reduced-motion: reduce) { - .reading-resume { animation: none; } + .reading-resume { + animation: none; + } } diff --git a/src/styles/site/16-pwa.css b/src/styles/site/16-pwa.css index f8b57d0..f59fc6a 100644 --- a/src/styles/site/16-pwa.css +++ b/src/styles/site/16-pwa.css @@ -19,29 +19,87 @@ animation: pwa-toast-in 0.3s ease both; } -.pwa-toast[hidden] { display: none; } -.pwa-toast-icon { display: grid; width: 44px; height: 44px; place-items: center; border-radius: 12px; color: #fff; background: #3eb8be; } -.pwa-toast-copy { min-width: 0; } -.pwa-toast-copy strong, .pwa-toast-copy p { margin: 0; } -.pwa-toast-copy p { color: var(--muted); font-size: 0.88rem; line-height: 1.5; } -.pwa-toast-actions { display: flex; gap: 7px; } -.pwa-toast button { border: 1px solid rgba(15, 118, 110, 0.18); border-radius: 999px; padding: 7px 12px; color: var(--accent); font: inherit; font-size: 0.84rem; font-weight: 800; background: rgba(236, 253, 245, 0.72); cursor: pointer; } -.pwa-toast .pwa-toast-primary { color: #fff; background: #3eb8be; } +.pwa-toast[hidden] { + display: none; +} +.pwa-toast-icon { + display: grid; + width: 44px; + height: 44px; + place-items: center; + border-radius: 12px; + color: #fff; + background: #3eb8be; +} +.pwa-toast-copy { + min-width: 0; +} +.pwa-toast-copy strong, +.pwa-toast-copy p { + margin: 0; +} +.pwa-toast-copy p { + color: var(--muted); + font-size: 0.88rem; + line-height: 1.5; +} +.pwa-toast-actions { + display: flex; + gap: 7px; +} +.pwa-toast button { + border: 1px solid rgba(15, 118, 110, 0.18); + border-radius: 999px; + padding: 7px 12px; + color: var(--accent); + font: inherit; + font-size: 0.84rem; + font-weight: 800; + background: rgba(236, 253, 245, 0.72); + cursor: pointer; +} +.pwa-toast .pwa-toast-primary { + color: #fff; + background: #3eb8be; +} -:root[data-theme='dark'] .pwa-toast { border-color: rgba(139, 224, 213, 0.22); color: #edf7f5; background: rgba(13, 23, 29, 0.94); } +:root[data-theme='dark'] .pwa-toast { + border-color: rgba(139, 224, 213, 0.22); + color: #edf7f5; + background: rgba(13, 23, 29, 0.94); +} @keyframes pwa-toast-in { - from { opacity: 0; transform: translateY(16px); } - to { opacity: 1; transform: translateY(0); } + from { + opacity: 0; + transform: translateY(16px); + } + to { + opacity: 1; + transform: translateY(0); + } } @media (max-width: 720px) { - .pwa-toast { right: 16px; bottom: 16px; grid-template-columns: 40px minmax(0, 1fr); } - .pwa-toast-icon { width: 40px; height: 40px; } - .pwa-toast-actions { grid-column: 1 / -1; } - .pwa-toast button { flex: 1; } + .pwa-toast { + right: 16px; + bottom: 16px; + grid-template-columns: 40px minmax(0, 1fr); + } + .pwa-toast-icon { + width: 40px; + height: 40px; + } + .pwa-toast-actions { + grid-column: 1 / -1; + } + .pwa-toast button { + flex: 1; + } } @media (prefers-reduced-motion: reduce) { - .pwa-toast { animation: none; } + .pwa-toast { + animation: none; + } } diff --git a/src/styles/site/17-revisions.css b/src/styles/site/17-revisions.css index cb53e31..07fc523 100644 --- a/src/styles/site/17-revisions.css +++ b/src/styles/site/17-revisions.css @@ -7,7 +7,7 @@ } .article-date-line time + time::before { - content: "·"; + content: '·'; margin-right: 14px; } @@ -141,10 +141,28 @@ } @media (max-width: 720px) { - .article-date-line { display: grid; gap: 1px; } - .article-date-line time + time::before { content: none; } - .post-changelog-head { grid-template-columns: 40px minmax(0, 1fr) auto; padding: 15px; } - .post-changelog-icon { width: 40px; height: 40px; } - .post-changelog-list { padding-right: 15px; padding-left: 27px; } - .post-changelog-entry > div { align-items: flex-start; flex-direction: column; gap: 1px; } + .article-date-line { + display: grid; + gap: 1px; + } + .article-date-line time + time::before { + content: none; + } + .post-changelog-head { + grid-template-columns: 40px minmax(0, 1fr) auto; + padding: 15px; + } + .post-changelog-icon { + width: 40px; + height: 40px; + } + .post-changelog-list { + padding-right: 15px; + padding-left: 27px; + } + .post-changelog-entry > div { + align-items: flex-start; + flex-direction: column; + gap: 1px; + } } diff --git a/src/styles/site/18-worklog.css b/src/styles/site/18-worklog.css index 1eccaeb..39073fb 100644 --- a/src/styles/site/18-worklog.css +++ b/src/styles/site/18-worklog.css @@ -37,7 +37,8 @@ body { color: var(--text); - font-family: Inter, "Segoe UI Variable Text", "Microsoft YaHei UI", "PingFang SC", system-ui, sans-serif; + font-family: + Inter, 'Segoe UI Variable Text', 'Microsoft YaHei UI', 'PingFang SC', system-ui, sans-serif; line-height: 1.68; background-color: var(--bg); background-image: @@ -88,7 +89,7 @@ select { display: inline-flex; align-items: baseline; width: fit-content; - font-family: "Cascadia Code", "SFMono-Regular", Consolas, monospace; + font-family: 'Cascadia Code', 'SFMono-Regular', Consolas, monospace; font-size: 1.12rem; font-weight: 760; letter-spacing: -0.04em; @@ -141,7 +142,7 @@ select { } .home-hero::after { - content: ""; + content: ''; position: absolute; right: 0; bottom: -5px; @@ -156,7 +157,7 @@ select { } .hero-copy::before { - content: ""; + content: ''; position: absolute; top: 4px; bottom: 6px; @@ -166,7 +167,7 @@ select { } .hero-copy::after { - content: ""; + content: ''; position: absolute; top: 4px; left: 0; @@ -183,7 +184,7 @@ select { .hero-talk-head, .article-summary-brand, .article-summary-model { - font-family: "Cascadia Code", "SFMono-Regular", Consolas, monospace; + font-family: 'Cascadia Code', 'SFMono-Regular', Consolas, monospace; } .hero-kicker { @@ -202,7 +203,7 @@ select { align-items: baseline; margin: 0; color: var(--text); - font-family: "Arial Narrow", "Bahnschrift SemiCondensed", "Aptos Display", sans-serif; + font-family: 'Arial Narrow', 'Bahnschrift SemiCondensed', 'Aptos Display', sans-serif; font-size: clamp(4.5rem, 9vw, 8.3rem); font-stretch: condensed; font-weight: 750; @@ -212,7 +213,7 @@ select { .hero h1 em { color: var(--signal); - font-family: "Cascadia Code", Consolas, monospace; + font-family: 'Cascadia Code', Consolas, monospace; font-size: 0.33em; font-style: normal; font-weight: 600; @@ -327,7 +328,7 @@ select { .section-heading h2, .content-wrap h1 { - font-family: "Arial Narrow", "Bahnschrift SemiCondensed", "Microsoft YaHei UI", sans-serif; + font-family: 'Arial Narrow', 'Bahnschrift SemiCondensed', 'Microsoft YaHei UI', sans-serif; font-size: clamp(1.75rem, 3vw, 2.35rem); font-weight: 720; letter-spacing: -0.04em; @@ -410,7 +411,7 @@ select { .post-card-copy time { margin-bottom: 6px; - font-family: "Cascadia Code", Consolas, monospace; + font-family: 'Cascadia Code', Consolas, monospace; font-size: 0.71rem; font-variant-numeric: tabular-nums; letter-spacing: 0.02em; @@ -437,9 +438,11 @@ select { .post-card-open { color: var(--line-strong); - font-family: "Cascadia Code", Consolas, monospace; + font-family: 'Cascadia Code', Consolas, monospace; font-size: 1.05rem; - transition: color 0.18s ease, transform 0.18s ease; + transition: + color 0.18s ease, + transform 0.18s ease; } .post-card-main:hover .post-card-open { @@ -462,7 +465,7 @@ select { border-radius: 0; padding: 0; color: var(--accent); - font-family: "Cascadia Code", Consolas, monospace; + font-family: 'Cascadia Code', Consolas, monospace; font-size: 0.73rem; font-weight: 650; background: transparent; @@ -470,7 +473,7 @@ select { } .meta-list a + a::before { - content: "/"; + content: '/'; margin-right: 15px; color: var(--line-strong); } @@ -542,7 +545,7 @@ select { .profile-name { margin: 0; color: var(--text); - font-family: "Arial Narrow", "Bahnschrift SemiCondensed", sans-serif; + font-family: 'Arial Narrow', 'Bahnschrift SemiCondensed', sans-serif; font-size: 1.6rem; font-weight: 760; letter-spacing: -0.04em; @@ -572,7 +575,7 @@ select { .profile-stats strong { color: var(--text); - font-family: "Cascadia Code", Consolas, monospace; + font-family: 'Cascadia Code', Consolas, monospace; } .follow-button { @@ -593,7 +596,7 @@ select { .profile-links { justify-content: flex-start; - font-family: "Cascadia Code", Consolas, monospace; + font-family: 'Cascadia Code', Consolas, monospace; font-size: 0.72rem; } @@ -675,7 +678,7 @@ select { .page-header-eyebrow { color: var(--signal); - font-family: "Cascadia Code", Consolas, monospace; + font-family: 'Cascadia Code', Consolas, monospace; font-size: 0.66rem; letter-spacing: 0.08em; text-transform: uppercase; @@ -684,7 +687,7 @@ select { .page-header-card h1, .content-wrap .page-header-card h1 { color: var(--text); - font-family: "Arial Narrow", "Bahnschrift SemiCondensed", "Microsoft YaHei UI", sans-serif; + font-family: 'Arial Narrow', 'Bahnschrift SemiCondensed', 'Microsoft YaHei UI', sans-serif; font-weight: 750; letter-spacing: -0.045em; } @@ -713,7 +716,7 @@ select { .article-header h1, .article-header-cover h1 { - font-family: "Arial Narrow", "Bahnschrift SemiCondensed", "Microsoft YaHei UI", sans-serif; + font-family: 'Arial Narrow', 'Bahnschrift SemiCondensed', 'Microsoft YaHei UI', sans-serif; font-weight: 760; letter-spacing: -0.045em; } @@ -804,7 +807,7 @@ select { .footer-brand, :root[data-theme='dark'] .footer-brand { color: var(--text); - font-family: "Cascadia Code", Consolas, monospace; + font-family: 'Cascadia Code', Consolas, monospace; } .footer-brand img { @@ -820,36 +823,38 @@ select { box-shadow: none; } -:root[data-theme='dark'] :where( - .page-header-card, - .post-card, - .sidebar-card, - .article, - .article-summary-card, - .post-copyright-card, - .twikoo-comments, - .table-scroll, - .stats-chart, - .term-grid a, - .pagination-link, - .pagination-number, - .native-feature-grid section, - .friend-link-card, - .external-redirect-panel, - .post-changelog -) { +:root[data-theme='dark'] + :where( + .page-header-card, + .post-card, + .sidebar-card, + .article, + .article-summary-card, + .post-copyright-card, + .twikoo-comments, + .table-scroll, + .stats-chart, + .term-grid a, + .pagination-link, + .pagination-number, + .native-feature-grid section, + .friend-link-card, + .external-redirect-panel, + .post-changelog + ) { border-color: var(--line); background: var(--surface); box-shadow: none; } -:root[data-theme='dark'] :where( - .page-header-card h1, - .content-wrap .page-header-card h1, - .sidebar-card h2, - .profile-name, - .article-summary-content -) { +:root[data-theme='dark'] + :where( + .page-header-card h1, + .content-wrap .page-header-card h1, + .sidebar-card h2, + .profile-name, + .article-summary-content + ) { color: var(--text); text-shadow: none; }