From 16195ad1f1ccd3f14968d85394cdf6306defb1d4 Mon Sep 17 00:00:00 2001 From: Ad-closeNN <1709301095@qq.com> Date: Sat, 16 May 2026 22:13:10 +0800 Subject: [PATCH] =?UTF-8?q?feat(viewSource):=20=E6=96=B0=E5=A2=9E=20CNB=20?= =?UTF-8?q?=E6=BA=90=E7=A0=81=E9=93=BE=E6=8E=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 新增 cnb.cool 镜像源码链接(Gitea 格式 /-/blob/main/) - CNB 置顶排在 Gitea 之后第二位 Co-Authored-By: Claude Code --- src/pages/posts/[...slug].astro | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/pages/posts/[...slug].astro b/src/pages/posts/[...slug].astro index 7503a44..844ca56 100644 --- a/src/pages/posts/[...slug].astro +++ b/src/pages/posts/[...slug].astro @@ -99,6 +99,14 @@ function getGiteaRawSourceUrl(repo: string | undefined, sourcePath: string | und return `https://${giteaHost}/${encodeURIComponent(owner)}/${encodeURIComponent(repository)}/src/branch/main/${encodedSourcePath}?display=source`; } +function getCnbsSourceUrl(baseUrl: string, sourcePath: string | undefined) { + if (!sourcePath) return ""; + + const normalizedUrl = baseUrl.replace(/\.git$/, "").replace(/\/+$/, ""); + const encodedSourcePath = sourcePath.split("/").map(encodeURIComponent).join("/"); + return `${normalizedUrl}/-/blob/main/${encodedSourcePath}`; +} + function parseAiSummaryValue(value: string) { const trimmed = value.trim(); if (!trimmed) return ""; @@ -155,6 +163,7 @@ const postSourcePath = getPostSourcePath(postSourceKey); const postSourceUrl = getGitHubPostSourceUrl(siteConfig.githubRepo, postSourcePath); const postRawSourceUrl = getGitHubRawSourceUrl(siteConfig.githubRepo, postSourcePath); const postGiteaRawSourceUrl = getGiteaRawSourceUrl(siteConfig.githubRepo, postSourcePath, "git.adclosenn.top"); +const postCnbsSourceUrl = getCnbsSourceUrl("https://cnb.cool/CLN-Grated/blog-fuwari", postSourcePath); const aiPrompt = `Read from ${postRawSourceUrl} so I can ask questions about it.`; const encodedAiPrompt = encodeURIComponent(aiPrompt); const copyPageAiLinks = [ @@ -163,6 +172,11 @@ const copyPageAiLinks = [ icon: "cln-gitea", href: postGiteaRawSourceUrl, }, + { + label: "CNB", + icon: "cnb", + href: postCnbsSourceUrl, + }, { label: "ChatGPT", icon: "gpt", @@ -298,6 +312,9 @@ const isOutdated = entry.data.outdated; {link.icon === "cln-gitea" && ( )} + {link.icon === "cnb" && ( + + )} 在 {link.label} 中打开