(root: string, rel: string)
| 1179 | /* ---------- Backlinks ------------------------------------------------- */ |
| 1180 | |
| 1181 | export async function backlinks(root: string, rel: string): Promise<NoteMeta[]> { |
| 1182 | const abs = resolveSafe(root, rel) |
| 1183 | const targetTitle = path.basename(abs, path.extname(abs)).toLowerCase() |
| 1184 | const all = await listNotes(root) |
| 1185 | const refs: NoteMeta[] = [] |
| 1186 | for (const meta of all) { |
| 1187 | if (meta.path === toPosix(path.relative(root, abs))) continue |
| 1188 | if (meta.wikilinks.some((w) => w.toLowerCase() === targetTitle)) { |
| 1189 | refs.push(meta) |
| 1190 | } |
| 1191 | } |
| 1192 | return refs |
| 1193 | } |
no test coverage detected