Small rework

This commit is contained in:
Simon Cambier
2022-10-20 17:27:15 +02:00
parent c2535b0ebd
commit 1376cea282
6 changed files with 24 additions and 21 deletions

View File

@@ -2,7 +2,6 @@
import { cacheManager } from 'src/cache-manager'
import { settings, showExcerpt } from 'src/settings'
import type { ResultNote } from '../globals'
import * as Search from '../search'
import { highlighter, makeExcerpt, stringsToRegex } from '../utils'
import ResultItemContainer from './ResultItemContainer.svelte'
@@ -10,7 +9,6 @@
export let note: ResultNote
$: reg = stringsToRegex(note.foundWords)
$: matches = Search.getMatches(note.content, reg)
$: cleanedContent = makeExcerpt(note.content, note.matches[0]?.offset ?? -1)
$: glyph = cacheManager.getNoteFromMemCache(note.path)?.doesNotExist
$: title = settings.showShortName ? note.basename : note.path
@@ -27,9 +25,9 @@
{@html title.replace(reg, highlighter)}
</span>
{#if matches.length > 0}
{#if note.matches.length > 0}
<span class="omnisearch-result__counter">
{matches.length}&nbsp;{matches.length > 1 ? 'matches' : 'match'}
{note.matches.length}&nbsp;{note.matches.length > 1 ? 'matches' : 'match'}
</span>
{/if}
</div>