docs: 替换 GitHub 图片资源链接为代理链接
This commit is contained in:
parent
1e0949703f
commit
1015736635
@ -62,6 +62,7 @@ export default async ({ mode }) => {
|
|||||||
targetUrl: '/issues',
|
targetUrl: '/issues',
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
githubProxy: 'https://cloudflare-github-proxy.hanxi-info.workers.dev/proxy',
|
||||||
}),
|
}),
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
|
@ -14,6 +14,7 @@ interface GitHubIssuesPluginOptions {
|
|||||||
repo: string; // GitHub repository info in the format 'owner/repo'
|
repo: string; // GitHub repository info in the format 'owner/repo'
|
||||||
token: string;
|
token: string;
|
||||||
replaceRules: ReplaceRule[];
|
replaceRules: ReplaceRule[];
|
||||||
|
githubProxy: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
async function fetchAllIssues(repo: string, token: string): Promise<any[]> {
|
async function fetchAllIssues(repo: string, token: string): Promise<any[]> {
|
||||||
@ -135,7 +136,7 @@ function copyReadmeFile(source: string, destination: string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export default function GitHubIssuesPlugin(options: GitHubIssuesPluginOptions): Plugin {
|
export default function GitHubIssuesPlugin(options: GitHubIssuesPluginOptions): Plugin {
|
||||||
const { repo, token, replaceRules } = options;
|
const { repo, token, replaceRules, githubProxy } = options;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
name: 'vitepress-plugin-github-issues',
|
name: 'vitepress-plugin-github-issues',
|
||||||
@ -207,6 +208,14 @@ ${comment.body}
|
|||||||
content = content.replace(pattern, `${targetUrl}$1.html`);
|
content = content.replace(pattern, `${targetUrl}$1.html`);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
content = content.replace(
|
||||||
|
/(https:\/\/github\.com\/([^\/]+\/[^\/]+\/assets\/[^\s]+)/g,
|
||||||
|
(match, p1) => {
|
||||||
|
const proxyUrl = `${githubProxy}/${p1}`; // 使用传入的 base URL
|
||||||
|
return proxyUrl;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
content += `[链接到 GitHub Issue](${issue.html_url})\n`
|
content += `[链接到 GitHub Issue](${issue.html_url})\n`
|
||||||
|
|
||||||
const filePath = path.join(docsDir, fileName);
|
const filePath = path.join(docsDir, fileName);
|
||||||
|
Loading…
Reference in New Issue
Block a user