Updated the weighting logic + doing some preparation for #6

Headings now have more weight. Also set TS strict mode
This commit is contained in:
Simon Cambier
2022-04-14 20:41:27 +02:00
parent a57582a389
commit 98c277e541
5 changed files with 117 additions and 48 deletions

View File

@@ -1,3 +1,5 @@
import { match } from 'assert'
// Matches a wikiling that begins a string
export const regexWikilink = /^!?\[\[(?<name>.+?)(\|(?<alias>.+?))?\]\]/
export const regexLineSplit = /\r?\n|\r|((\.|\?|!)( |\r?\n|\r))/g
@@ -13,12 +15,23 @@ export type IndexedNote = {
path: string
basename: string
content: string
headings1: string
headings2: string
headings3: string
}
export type SearchMatch = {
match: string
index: number
}
export const isSearchMatch = (o: { index?: number }): o is SearchMatch => {
return o.index !== undefined
}
export type ResultNote = {
path: string
basename: string
content: string
keyword: string
matches: SearchMatch[]
occurence: number
}