Fixed #59 - Add a setting to display the short form of links in search results

This commit is contained in:
Simon Cambier
2022-06-03 23:31:55 +02:00
parent d625ae38e1
commit 13ff1e5079
3 changed files with 63 additions and 33 deletions

View File

@@ -1,5 +1,6 @@
<script lang="ts">
import { getNoteFromCache } from "src/notes"
import { settings } from "src/settings"
import type { ResultNote } from "../globals"
import { getMatches } from "../search"
import { highlighter, makeExcerpt, stringsToRegex } from "../utils"
@@ -12,11 +13,12 @@ $: reg = stringsToRegex(note.foundWords)
$: 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
</script>
<ResultItemContainer id={note.path} {selected} on:mousemove on:click {glyph}>
<span class="omnisearch-result__title">
{@html note.basename.replace(reg, highlighter)}
{@html title.replace(reg, highlighter)}
</span>
{#if matches.length > 0}