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

Function noteTargetFor

packages/app-core/src/lib/cm-wikilinks.ts:118–132  ·  view source on GitHub ↗
(note: NoteMeta, notes: NoteMeta[])

Source from the content-addressed store, hash-verified

116}
117
118function noteTargetFor(note: NoteMeta, notes: NoteMeta[]): string {
119 const titleNeedle = normalize(note.title)
120 const titleMatches = notes.filter(
121 (candidate) =>
122 candidate.folder !== 'trash' && normalize(candidate.title) === titleNeedle
123 )
124 if (titleMatches.length === 1) return note.title
125
126 const rel = stripMdExtension(note.path)
127 if (note.folder === 'inbox' && isPrimaryNotesAtRoot(useStore.getState().vaultSettings)) {
128 return `/${rel}`
129 }
130 if (rel.startsWith('inbox/')) return `/${rel.slice('inbox/'.length)}`
131 return rel
132}
133
134function scoreAsset(asset: AssetMeta, query: string, activePath: string | null): number {
135 const name = normalize(asset.name)

Callers 1

wikilinkSourceFunction · 0.85

Calls 3

isPrimaryNotesAtRootFunction · 0.90
normalizeFunction · 0.70
stripMdExtensionFunction · 0.70

Tested by

no test coverage detected