Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 52 additions & 0 deletions docs/.vitepress/markdownAssets.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import { existsSync, readdirSync, readFileSync } from "node:fs";
import { dirname, join, relative, resolve } from "node:path";
import { fileURLToPath } from "node:url";
import { describe, expect, it } from "vitest";

const docsRoot = fileURLToPath(new URL("../", import.meta.url));
const markdownImage = /!\[[^\]]*\]\(([^)]+)\)/g;

const findMarkdownFiles = (directory: string): string[] =>
readdirSync(directory, { withFileTypes: true }).flatMap((entry) => {
const path = join(directory, entry.name);

if (entry.isDirectory()) return findMarkdownFiles(path);
return entry.isFile() && entry.name.endsWith(".md") ? [path] : [];
});

const isExternalAsset = (href: string) =>
href.startsWith("#") ||
href.startsWith("/") ||
href.startsWith("//") ||
/^[a-z][a-z\d+.-]*:/i.test(href);

describe("Markdown image assets", () => {
it("uses valid POSIX paths that resolve to local files", () => {
const invalidAssets: string[] = [];

for (const markdownFile of findMarkdownFiles(docsRoot)) {
const content = readFileSync(markdownFile, "utf8");

for (const match of content.matchAll(markdownImage)) {
const href = match[1].trim();
if (isExternalAsset(href)) continue;

const source = `${relative(docsRoot, markdownFile)} → ${href}`;
if (href.includes("\\")) {
invalidAssets.push(`${source} (use / instead of \\)`);
continue;
}

const assetPath = resolve(
dirname(markdownFile),
decodeURIComponent(href),
);
if (!existsSync(assetPath)) {
invalidAssets.push(`${source} (file not found)`);
}
}
}

expect(invalidAssets).toEqual([]);
});
});
4 changes: 2 additions & 2 deletions docs/cases/submissions/wechat-ima-knowledge/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,13 @@ ima 知识库连接器是 WorkBuddy 与 ima 之间的桥梁——WorkBuddy 可
- **图片/截图**:长按图片 → 用小程序打开 → 选择 ima

日积月累,你的 ima 知识库里就有了原始素材。
![workbuddy添加ima连接器](assets\小程序一键存入ima.jpg)
![将微信收藏保存到 ima](./assets/小程序一键存入ima.jpg)

### 第二步:在 WorkBuddy 中添加 ima 连接器

在 WorkBuddy 中打开连接器管理面板,搜索并添加「ima 知识库」连接器,完成授权。授权完成后,WorkBuddy 就能读取你的 ima 知识库内容了。

![workbuddy添加ima连接器](assets\workbuddy添加ima连接器.png)
![在 WorkBuddy 中添加 ima 知识库连接器](./assets/workbuddy添加ima连接器.png)


### 第三步:用 WorkBuddy 梳理知识体系
Expand Down