mirror of
https://github.com/Ad-closeNN/blog-fuwari.git
synced 2026-05-31 01:40:03 -04:00
feat(viewSource): 新增 CNB 源码链接
- 新增 cnb.cool 镜像源码链接(Gitea 格式 /-/blob/main/) - CNB 置顶排在 Gitea 之后第二位 Co-Authored-By: Claude Code <noreply@anthropic.com>
This commit is contained in:
@@ -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" && (
|
||||
<img aria-hidden="true" class="h-4 w-4" src="https://git.adclosenn.top/assets/img/logo.svg" alt="" />
|
||||
)}
|
||||
{link.icon === "cnb" && (
|
||||
<img aria-hidden="true" class="h-4 w-4" src="https://cnb.cool/images/favicon.svg" alt="" />
|
||||
)}
|
||||
<span>在 {link.label} 中打开</span>
|
||||
</span>
|
||||
<Icon is:inline name="material-symbols:open-in-new-rounded" class="text-[0.95rem] text-[var(--primary)]"></Icon>
|
||||
|
||||
Reference in New Issue
Block a user