(notes: T[], target: string)
| 130 | } |
| 131 | |
| 132 | export function resolveWikilinkTarget<T extends NoteRef>(notes: T[], target: string): T | null { |
| 133 | // `[[Doc#Heading]]` / `[[Doc^block]]` point at a spot inside Doc — resolve the |
| 134 | // document, ignoring the anchor. (#196) |
| 135 | const doc = stripWikilinkAnchor(target) |
| 136 | const visible = notes.filter((note) => note.folder !== 'trash') |
| 137 | if (isPathLikeWikilinkTarget(doc)) { |
| 138 | return (resolveExplicitPath(visible, doc) ?? |
| 139 | resolvePathSuffix(visible, doc)) as T | null |
| 140 | } |
| 141 | |
| 142 | const needle = normalizeForCompare(stripMdExtension(doc)) |
| 143 | if (!needle) return null |
| 144 | return visible.find((note) => normalizeForCompare(note.title) === needle) ?? null |
| 145 | } |
| 146 | |
| 147 | export function backlinksForNote<T extends NoteRef & Pick<NoteMeta, 'wikilinks'>>( |
| 148 | notes: T[], |
no test coverage detected