MCPcopy Create free account
hub / github.com/Qinbf/groundmap / asStringArray

Function asStringArray

web/lib/kb-service.ts:104–108  ·  view source on GitHub ↗

YAML 字段可能是 "foo"(字符串)或 ["foo", "bar"](列表);都规范化为字符串数组。 * 如果用户在 YAML 写 `tags: foo`,python-frontmatter / gray-matter 会给出字符串而非数组—— * 下游 .some(...) / 标签匹配会出错。这里强制转为数组兜底。

(v: unknown)

Source from the content-addressed store, hash-verified

102 * 下游 .some(...) / 标签匹配会出错。这里强制转为数组兜底。
103 */
104function asStringArray(v: unknown): string[] {
105 if (Array.isArray(v)) return v.map((x) => String(x));
106 if (typeof v === "string" && v.trim()) return [v];
107 return [];
108}
109
110function metaFromFrontmatter(p: string, fm: PageFrontmatter): PageMeta {
111 return {

Callers 1

metaFromFrontmatterFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected