MCPcopy Create free account
hub / github.com/ZenNotes/zennotes / resolveWikilinkTarget

Function resolveWikilinkTarget

packages/app-core/src/lib/wikilinks.ts:132–145  ·  view source on GitHub ↗
(notes: T[], target: string)

Source from the content-addressed store, hash-verified

130}
131
132export 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
147export function backlinksForNote<T extends NoteRef & Pick<NoteMeta, 'wikilinks'>>(
148 notes: T[],

Callers 8

ConnectionsPanelFunction · 0.90
followEditorLinkFunction · 0.90
registerVimCommandsFunction · 0.90
Preview.tsxFile · 0.90
openWikilinkFunction · 0.90
wikilinkHeadingSourceFunction · 0.90
wikilinks.test.tsFile · 0.90
backlinksForNoteFunction · 0.70

Calls 6

stripWikilinkAnchorFunction · 0.85
isPathLikeWikilinkTargetFunction · 0.70
resolveExplicitPathFunction · 0.70
resolvePathSuffixFunction · 0.70
normalizeForCompareFunction · 0.70
stripMdExtensionFunction · 0.70

Tested by

no test coverage detected