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} 中打开