diff --git a/src/components/ResultItemVault.svelte b/src/components/ResultItemVault.svelte index e4230c3..5f8f4b4 100644 --- a/src/components/ResultItemVault.svelte +++ b/src/components/ResultItemVault.svelte @@ -2,12 +2,30 @@ import { cacheManager } from 'src/cache-manager' import { settings, showExcerpt } from 'src/settings' import type { ResultNote } from '../globals' - import { highlighter, makeExcerpt, stringsToRegex } from '../tools/utils' + import { + highlighter, + isFileImage, + makeExcerpt, + stringsToRegex, + } from '../tools/utils' import ResultItemContainer from './ResultItemContainer.svelte' export let selected = false export let note: ResultNote + let imagePath: string | null = null + + $: { + imagePath = null + if (isFileImage(note.path)) { + console.log(note.path) + // @ts-ignore + const file = app.vault.getFiles().find(f => f.path === note.path) + if (file) { + imagePath = app.vault.getResourcePath(file) + } + } + } $: reg = stringsToRegex(note.foundWords) $: cleanedContent = makeExcerpt(note.content, note.matches[0]?.offset ?? -1) $: glyph = cacheManager.getDocument(note.path)?.doesNotExist @@ -20,21 +38,31 @@ on:mousemove on:click glyph="{glyph}"> -
- - {@html title.replace(reg, highlighter)} - +
+
+
+ + {@html title.replace(reg, highlighter)} + - {#if note.matches.length > 0} - - {note.matches.length} {note.matches.length > 1 ? 'matches' : 'match'} - + {#if note.matches.length > 0} + + {note.matches.length} {note.matches.length > 1 + ? 'matches' + : 'match'} + + {/if} +
+ + {#if $showExcerpt} +
+ {@html cleanedContent.replace(reg, highlighter)} +
+ {/if} +
+ + {#if imagePath} + {/if}
- - {#if $showExcerpt} -
- {@html cleanedContent.replace(reg, highlighter)} -
- {/if}