diff --git a/src/pages/posts/[...slug].astro b/src/pages/posts/[...slug].astro
index 59f2e15..7503a44 100644
--- a/src/pages/posts/[...slug].astro
+++ b/src/pages/posts/[...slug].astro
@@ -71,6 +71,34 @@ function getGitHubPostSourceUrl(repo: string | undefined, sourcePath: string | u
return `${normalizedRepo}/blob/main/${encodedSourcePath}?plain=1`;
}
+function getGitHubRawSourceUrl(repo: string | undefined, sourcePath: string | undefined) {
+ if (!repo || !sourcePath) return "";
+
+ const normalizedRepo = repo.replace(/\.git$/, "").replace(/\/+$/, "");
+ const repoPath = normalizedRepo.includes("://")
+ ? new URL(normalizedRepo).pathname.replace(/^\/+|\/+$/g, "")
+ : normalizedRepo.replace(/^\/+|\/+$/g, "");
+ const [owner, repository] = repoPath.split("/");
+ if (!owner || !repository) return "";
+
+ const encodedSourcePath = sourcePath.split("/").map(encodeURIComponent).join("/");
+ return `https://raw.githubusercontent.com/${encodeURIComponent(owner)}/${encodeURIComponent(repository)}/refs/heads/main/${encodedSourcePath}`;
+}
+
+function getGiteaRawSourceUrl(repo: string | undefined, sourcePath: string | undefined, giteaHost: string) {
+ if (!repo || !sourcePath) return "";
+
+ const normalizedRepo = repo.replace(/\.git$/, "").replace(/\/+$/, "");
+ const repoPath = normalizedRepo.includes("://")
+ ? new URL(normalizedRepo).pathname.replace(/^\/+|\/+$/g, "")
+ : normalizedRepo.replace(/^\/+|\/+$/g, "");
+ const [owner, repository] = repoPath.split("/");
+ if (!owner || !repository) return "";
+
+ const encodedSourcePath = sourcePath.split("/").map(encodeURIComponent).join("/");
+ return `https://${giteaHost}/${encodeURIComponent(owner)}/${encodeURIComponent(repository)}/src/branch/main/${encodedSourcePath}?display=source`;
+}
+
function parseAiSummaryValue(value: string) {
const trimmed = value.trim();
if (!trimmed) return "";
@@ -125,9 +153,16 @@ const aiSummaryMeta = getAiSummaryMeta(entry.id);
const postSourceKey = getPostSourceKey(entry.id);
const postSourcePath = getPostSourcePath(postSourceKey);
const postSourceUrl = getGitHubPostSourceUrl(siteConfig.githubRepo, postSourcePath);
-const aiPrompt = `Read from ${postSourceUrl} so I can ask questions about it.`;
+const postRawSourceUrl = getGitHubRawSourceUrl(siteConfig.githubRepo, postSourcePath);
+const postGiteaRawSourceUrl = getGiteaRawSourceUrl(siteConfig.githubRepo, postSourcePath, "git.adclosenn.top");
+const aiPrompt = `Read from ${postRawSourceUrl} so I can ask questions about it.`;
const encodedAiPrompt = encodeURIComponent(aiPrompt);
const copyPageAiLinks = [
+ {
+ label: "Gitea",
+ icon: "cln-gitea",
+ href: postGiteaRawSourceUrl,
+ },
{
label: "ChatGPT",
icon: "gpt",
@@ -260,6 +295,9 @@ const isOutdated = entry.data.outdated;
)}
+ {link.icon === "cln-gitea" && (
+
+ )}
在 {link.label} 中打开