跳到主要内容

Claude Cage · 面向 Claude 的隔离开发环境,支持桌面工作台、多账号、远程部署与移动端连接。上游 Lee-xeo/Claude-Cage 完整源码镜像,非灵栈原创;主许可 MIT,第三方组件遵循各自许可。来源:https://github.com/Lee-xeo/Claude-Cage 。手动同步,不附带 Release 安装包。

浏览文件

guide.ts

19 行 · 1.3 KB历史下载
1import type { MarkdownInstance } from 'astro';
2
3type GuideFrontmatter = { title: string; description: string; group: string; order: number; keywords?: string };
4const modules = import.meta.glob<MarkdownInstance<GuideFrontmatter>>('../../../docs/guide/*.md', { eager: true });
5export const guidePages = Object.entries(modules).map(([path, content]) => ({
6 slug: path.split('/').at(-1)!.replace(/\.md$/, ''),
7 ...content.frontmatter,
8 content,
9})).sort((a, b) => a.order - b.order);
10export const guideGroups = [...new Set(guidePages.map(page => page.group))];
11export const guideURL = (slug: string) => `${import.meta.env.BASE_URL}docs/${slug === 'index' ? '' : `${slug}/`}`;
12export function guideHTML(html: string) {
13 // The same Markdown links work in the repository and under a custom website base.
14 return html.replace(/(src|href)="\.\.\/\.\.\/www\/public\/([^\"]+)"/g, (_, attribute: string, asset: string) => `${attribute}="${import.meta.env.BASE_URL}${asset}"`)
15 .replaceAll('href="https://lee-xeo.github.io/Claude-Cage/', `href="${import.meta.env.BASE_URL}`).replace(/href="([^"#]+)\.md(#[^"]*)?"/g, (original, name: string, hash = '') => {
16 const page = guidePages.find(page => page.slug === name.replace(/^\.\//, ''));
17 return page ? `href="${guideURL(page.slug)}${hash}"` : original;
18 });
19}