MCPcopy
hub / github.com/byoungd/up / summaryTargets

Function summaryTargets

scripts/check-content.mjs:103–117  ·  view source on GitHub ↗

提取一个 SUMMARY 文件里引用的内容文件(.md),归一化为 repo 根相对路径。

(file, prefix)

Source from the content-addressed store, hash-verified

101
102/** 提取一个 SUMMARY 文件里引用的内容文件(.md),归一化为 repo 根相对路径。 */
103function summaryTargets(file, prefix) {
104 const text = readFileSync(file, "utf8");
105 const set = new Set();
106 let m;
107 MD_LINK_RE.lastIndex = 0;
108 while ((m = MD_LINK_RE.exec(text))) {
109 const t = m[1].split("#")[0].split("?")[0].trim();
110 if (!t || isExternal(t) || t.startsWith("#")) continue;
111 if (extname(t) !== ".md") continue;
112 // prefix 用于把 docs/SUMMARY 的相对路径补成 repo 根视角,便于与根 SUMMARY 对比
113 const norm = t.startsWith("docs/") ? t : prefix + t;
114 set.add(norm);
115 }
116 return set;
117}
118
119/** 校验根 SUMMARY 与 docs/SUMMARY 引用的中文内容文件集合一致。 */
120function checkSummaryConsistency() {

Callers 1

checkSummaryConsistencyFunction · 0.85

Calls 1

isExternalFunction · 0.85

Tested by

no test coverage detected