From e290f8fa047244c7113720174d6c4d943535bb27 Mon Sep 17 00:00:00 2001 From: biss Date: Fri, 19 Jun 2026 14:53:59 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=9B=BE=E7=89=87=E4=B8=8D?= =?UTF-8?q?=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../posts/2026/2026.4/install-opengl.md | 1 + src/content/posts/2026/2026.4/msp-1.md | 2 + src/lib/remarkHexoLinkCards.mjs | 73 +++++++++++++++++++ src/pages/posts/[slug].astro | 5 +- src/styles/site.css | 11 ++- 5 files changed, 85 insertions(+), 7 deletions(-) diff --git a/src/content/posts/2026/2026.4/install-opengl.md b/src/content/posts/2026/2026.4/install-opengl.md index ff8df26..ecd8dd4 100644 --- a/src/content/posts/2026/2026.4/install-opengl.md +++ b/src/content/posts/2026/2026.4/install-opengl.md @@ -17,6 +17,7 @@ date: 2026-04-02 04:52:16 # 安装Visual Studio 现在我们先来安装`Visual Studio`:[visual studio](https://visualstudio.microsoft.com/zh-hans/vs/),下载后安装即可|在安装时选择“使用C++的桌面开发”,这样安装时就会安装C++的编译器了。 + ![](https://pic.biss.click/image/2d3be78a-320f-41de-8773-e2fd7a2af66e.webp) # 安装 Cmake diff --git a/src/content/posts/2026/2026.4/msp-1.md b/src/content/posts/2026/2026.4/msp-1.md index b9a937c..4431ae3 100644 --- a/src/content/posts/2026/2026.4/msp-1.md +++ b/src/content/posts/2026/2026.4/msp-1.md @@ -18,6 +18,8 @@ tags: ![日历](https://pic.biss.click/image/124f7862-e8dc-45e8-b9fa-73de58381234.jpg) 当然开源版固件功能有点少,又不想买烧录器自己折腾,所以把自己想要的功能写成网页: 目前写了待办事项和倒计时,生成图片后上传 + {% link 生成图,tu,https://letters.biss.click/gen/ %} + ![待办事项](https://pic.biss.click/image/1b1c3f2c-fe42-4844-b681-f4b463900c1a.jpg) ![倒计时](https://pic.biss.click/image/66ea88ef-15c0-40bd-9f2d-6973266e3a01.webp) \ No newline at end of file diff --git a/src/lib/remarkHexoLinkCards.mjs b/src/lib/remarkHexoLinkCards.mjs index 34e731d..0ecfc9d 100644 --- a/src/lib/remarkHexoLinkCards.mjs +++ b/src/lib/remarkHexoLinkCards.mjs @@ -251,6 +251,60 @@ function transformBlockTags(children) { } } +function splitMixedTagParagraph(node) { + if (node?.type !== 'paragraph' || !Array.isArray(node.children)) return [node]; + if (!node.children.some((child) => child.type === 'image')) return [node]; + + const source = node.children.map(inlineToSource).join(''); + if (!hexoTagPattern.test(source)) return [node]; + hexoTagPattern.lastIndex = 0; + + const result = []; + let currentChildren = []; + + const flushParagraph = () => { + if (currentChildren.length === 0) return; + result.push({ type: 'paragraph', children: currentChildren }); + currentChildren = []; + }; + + for (const child of node.children) { + if (child.type !== 'text' || typeof child.value !== 'string') { + currentChildren.push(child); + continue; + } + + const pattern = new RegExp(hexoTagPattern); + let lastIndex = 0; + let match; + + while ((match = pattern.exec(child.value))) { + const before = child.value.slice(lastIndex, match.index); + if (before) currentChildren.push({ type: 'text', value: before }); + + flushParagraph(); + result.push({ type: 'html', value: renderTag(match[1], match[2]) }); + lastIndex = pattern.lastIndex; + } + + const after = child.value.slice(lastIndex); + if (after) currentChildren.push({ type: 'text', value: after }); + } + + flushParagraph(); + return result.length > 0 ? result : [node]; +} + +function transformMixedTagParagraphs(children) { + for (let index = 0; index < children.length; index += 1) { + const replacement = splitMixedTagParagraph(children[index]); + if (replacement.length === 1 && replacement[0] === children[index]) continue; + + children.splice(index, 1, ...replacement); + index += replacement.length - 1; + } +} + function inlineToSource(node) { if (node.type === 'text' || node.type === 'inlineCode') return node.value ?? ''; @@ -259,6 +313,12 @@ function inlineToSource(node) { return `[${text}](${node.url})`; } + if (node.type === 'image') { + const alt = node.alt ?? ''; + const title = node.title ? ` "${node.title}"` : ''; + return `![${alt}](${node.url}${title})`; + } + if (Array.isArray(node.children)) return node.children.map(inlineToSource).join(''); return ''; } @@ -267,12 +327,25 @@ function visit(node) { if (!node || typeof node !== 'object') return; if (Array.isArray(node.children)) transformBlockTags(node.children); + if (Array.isArray(node.children)) transformMixedTagParagraphs(node.children); if (node.type === 'paragraph' && Array.isArray(node.children)) { const source = node.children.map(inlineToSource).join(''); const transformed = transformText(source); if (transformed !== source) { + if (node.children.some((child) => child.type === 'image')) { + node.children = node.children.map((child) => { + if (child.type !== 'text' || typeof child.value !== 'string') return child; + + const childTransformed = transformText(child.value); + if (childTransformed === child.value) return child; + + return { type: 'html', value: childTransformed }; + }); + return; + } + node.type = 'html'; node.value = transformed; delete node.children; diff --git a/src/pages/posts/[slug].astro b/src/pages/posts/[slug].astro index 1e5ac48..e088bfc 100644 --- a/src/pages/posts/[slug].astro +++ b/src/pages/posts/[slug].astro @@ -18,9 +18,6 @@ const { post } = Astro.props; const { Content } = await render(post.entry); const allPosts = await getAllPosts(); const rawContent = post.body; -const staleThreshold = new Date(); -staleThreshold.setFullYear(staleThreshold.getFullYear() - 1); -const isOutdatedPost = post.date < staleThreshold; const textContent = rawContent .replace(/```[\s\S]*?```/g, '') .replace(/<[^>]+>/g, '') @@ -128,7 +125,7 @@ const relatedPosts = allPosts class="butterfly-note butterfly-note--warning article-outdated-note" aria-label="文章时效性提示" data-published-at={post.date.toISOString()} - hidden={!isOutdatedPost} + hidden >
diff --git a/src/styles/site.css b/src/styles/site.css index 3b21759..cbf4566 100644 --- a/src/styles/site.css +++ b/src/styles/site.css @@ -1,3 +1,5 @@ +@import url("https://fontsapi.zeoseven.com/7/main/result.css"); + :root { color-scheme: light; --bg: #f7f5ef; @@ -34,9 +36,8 @@ body { margin: 0; color: var(--text); - font-family: - Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", - "Microsoft YaHei", sans-serif; + font-family: "Zhuque Fangsong (technical preview)"; + font-weight: normal; line-height: 1.75; background: linear-gradient(rgba(247, 245, 239, 0.86), rgba(247, 245, 239, 0.95)), @@ -1700,6 +1701,10 @@ time { background: rgba(236, 253, 245, 0.58); } +.article-outdated-note[hidden] { + display: none; +} + .butterfly-note > i { margin-top: 0.28em; color: var(--butterfly-note-color, var(--accent));