#70 - Added a "toggle context" setting + settings is now a Svelte store

A bit more verbose, but allows for proper reactivity
This commit is contained in:
Simon Cambier
2022-09-10 21:23:12 +02:00
parent c74ed2892c
commit 66e1d2d334
4 changed files with 97 additions and 31 deletions

View File

@@ -1,6 +1,6 @@
<script lang="ts">
import { getNoteFromCache } from 'src/notes'
import { settings } from 'src/settings'
import { SearchContextType, settings } from 'src/settings'
import type { ResultNote } from '../globals'
import { getMatches } from '../search'
import { highlighter, makeExcerpt, stringsToRegex } from '../utils'
@@ -13,7 +13,7 @@
$: matches = getMatches(note.content, reg)
$: cleanedContent = makeExcerpt(note.content, note.matches[0]?.offset ?? -1)
$: glyph = getNoteFromCache(note.path)?.doesNotExist
$: title = settings.showShortName ? note.basename : note.path
$: title = $settings.showShortName ? note.basename : note.path
</script>
<ResultItemContainer id={note.path} {selected} on:mousemove on:click {glyph}>
@@ -28,7 +28,10 @@
</span>
{/if}
</div>
<div class="omnisearch-result__body">
{@html cleanedContent.replace(reg, highlighter)}
</div>
{#if $settings.showContext !== SearchContextType.None}
<div class="omnisearch-result__body">
{@html cleanedContent.replace(reg, highlighter)}
</div>
{/if}
</ResultItemContainer>