feat: Make any property of frontmatter a display name (#329)
This commit is contained in:
@@ -221,10 +221,11 @@ export class CacheManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
const displayTitle = metadata?.frontmatter?.[this.plugin.settings.displayTitle] ?? ''
|
||||||
const tags = getTagsFromMetadata(metadata)
|
const tags = getTagsFromMetadata(metadata)
|
||||||
return {
|
return {
|
||||||
basename: file.basename,
|
basename: file.basename,
|
||||||
|
displayTitle,
|
||||||
content,
|
content,
|
||||||
/** Content without diacritics and markdown chars */
|
/** Content without diacritics and markdown chars */
|
||||||
cleanedContent: stripMarkdownCharacters(removeDiacritics(content)),
|
cleanedContent: stripMarkdownCharacters(removeDiacritics(content)),
|
||||||
|
|||||||
@@ -36,7 +36,7 @@
|
|||||||
$: cleanedContent = plugin.textProcessor.makeExcerpt(note.content, note.matches[0]?.offset ?? -1)
|
$: cleanedContent = plugin.textProcessor.makeExcerpt(note.content, note.matches[0]?.offset ?? -1)
|
||||||
$: glyph = false //cacheManager.getLiveDocument(note.path)?.doesNotExist
|
$: glyph = false //cacheManager.getLiveDocument(note.path)?.doesNotExist
|
||||||
$: {
|
$: {
|
||||||
title = note.basename
|
title = note.displayTitle || note.basename
|
||||||
notePath = pathWithoutFilename(note.path)
|
notePath = pathWithoutFilename(note.path)
|
||||||
|
|
||||||
// Icons
|
// Icons
|
||||||
|
|||||||
@@ -46,6 +46,7 @@ export type DocumentRef = { path: string; mtime: number }
|
|||||||
export type IndexedDocument = {
|
export type IndexedDocument = {
|
||||||
path: string
|
path: string
|
||||||
basename: string
|
basename: string
|
||||||
|
displayTitle: string
|
||||||
mtime: number
|
mtime: number
|
||||||
|
|
||||||
content: string
|
content: string
|
||||||
@@ -76,6 +77,7 @@ export type ResultNote = {
|
|||||||
score: number
|
score: number
|
||||||
path: string
|
path: string
|
||||||
basename: string
|
basename: string
|
||||||
|
displayTitle: string
|
||||||
content: string
|
content: string
|
||||||
foundWords: string[]
|
foundWords: string[]
|
||||||
matches: SearchMatch[]
|
matches: SearchMatch[]
|
||||||
|
|||||||
@@ -88,6 +88,7 @@ export class NotesIndexer {
|
|||||||
return {
|
return {
|
||||||
path: filename,
|
path: filename,
|
||||||
basename: name,
|
basename: name,
|
||||||
|
displayTitle: '',
|
||||||
mtime: 0,
|
mtime: 0,
|
||||||
|
|
||||||
content: '',
|
content: '',
|
||||||
|
|||||||
@@ -154,8 +154,9 @@ export class SearchEngine {
|
|||||||
term.length <= 3 ? 0 : term.length <= 5 ? fuzziness / 2 : fuzziness,
|
term.length <= 3 ? 0 : term.length <= 5 ? fuzziness / 2 : fuzziness,
|
||||||
boost: {
|
boost: {
|
||||||
basename: settings.weightBasename,
|
basename: settings.weightBasename,
|
||||||
directory: settings.weightDirectory,
|
|
||||||
aliases: settings.weightBasename,
|
aliases: settings.weightBasename,
|
||||||
|
displayTitle: settings.weightBasename,
|
||||||
|
directory: settings.weightDirectory,
|
||||||
headings1: settings.weightH1,
|
headings1: settings.weightH1,
|
||||||
headings2: settings.weightH2,
|
headings2: settings.weightH2,
|
||||||
headings3: settings.weightH3,
|
headings3: settings.weightH3,
|
||||||
|
|||||||
@@ -37,6 +37,8 @@ export interface OmnisearchSettings extends WeightingSettings {
|
|||||||
|
|
||||||
/** Extensions of plain text files to index, in addition to .md */
|
/** Extensions of plain text files to index, in addition to .md */
|
||||||
indexedFileTypes: string[]
|
indexedFileTypes: string[]
|
||||||
|
/** Custom title field */
|
||||||
|
displayTitle: string
|
||||||
/** Enable PDF indexing */
|
/** Enable PDF indexing */
|
||||||
PDFIndexing: boolean
|
PDFIndexing: boolean
|
||||||
/** Enable Images indexing */
|
/** Enable Images indexing */
|
||||||
@@ -209,6 +211,21 @@ export class SettingsTab extends PluginSettingTab {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// Custom display title
|
||||||
|
new Setting(containerEl)
|
||||||
|
.setName('Set frontmatter property key as title')
|
||||||
|
.setDesc(
|
||||||
|
htmlDescription(`If you have a custom property in your notes that you want to use as the title in search results.<br>
|
||||||
|
Leave empty to disable.`)
|
||||||
|
)
|
||||||
|
.addText(component => {
|
||||||
|
component.setValue(settings.displayTitle).onChange(async v => {
|
||||||
|
await clearCacheDebounced()
|
||||||
|
settings.displayTitle = v
|
||||||
|
await saveSettings(this.plugin)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
// Additional text files to index
|
// Additional text files to index
|
||||||
new Setting(containerEl)
|
new Setting(containerEl)
|
||||||
.setName('Additional TEXT files to index')
|
.setName('Additional TEXT files to index')
|
||||||
@@ -737,6 +754,7 @@ export function getDefaultSettings(app: App): OmnisearchSettings {
|
|||||||
ignoreDiacritics: true,
|
ignoreDiacritics: true,
|
||||||
ignoreArabicDiacritics: false,
|
ignoreArabicDiacritics: false,
|
||||||
indexedFileTypes: [] as string[],
|
indexedFileTypes: [] as string[],
|
||||||
|
displayTitle: '',
|
||||||
PDFIndexing: false,
|
PDFIndexing: false,
|
||||||
officeIndexing: false,
|
officeIndexing: false,
|
||||||
imagesIndexing: false,
|
imagesIndexing: false,
|
||||||
|
|||||||
Reference in New Issue
Block a user