From c7aabd3a8d3f295bf7060cfd21c043766bd475e6 Mon Sep 17 00:00:00 2001 From: EYHN Date: Thu, 8 Aug 2024 08:56:50 +0000 Subject: [PATCH] feat(core): highlight doc title in search result (#7786) --- packages/frontend/core/src/modules/quicksearch/impls/docs.ts | 5 ++++- .../src/modules/quicksearch/services/doc-display-meta.ts | 5 +++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/packages/frontend/core/src/modules/quicksearch/impls/docs.ts b/packages/frontend/core/src/modules/quicksearch/impls/docs.ts index 0c7dd6326f..552b34897b 100644 --- a/packages/frontend/core/src/modules/quicksearch/impls/docs.ts +++ b/packages/frontend/core/src/modules/quicksearch/impls/docs.ts @@ -86,7 +86,10 @@ export class DocsQuickSearchSession ) .map(([doc, docRecord]) => { const { title, icon, updatedDate } = - this.docDisplayMetaService.getDocDisplayMeta(docRecord); + this.docDisplayMetaService.getDocDisplayMeta( + docRecord, + 'title' in doc ? doc.title : undefined + ); return { id: 'doc:' + docRecord.id, source: 'docs', diff --git a/packages/frontend/core/src/modules/quicksearch/services/doc-display-meta.ts b/packages/frontend/core/src/modules/quicksearch/services/doc-display-meta.ts index 1639555163..814d8b3834 100644 --- a/packages/frontend/core/src/modules/quicksearch/services/doc-display-meta.ts +++ b/packages/frontend/core/src/modules/quicksearch/services/doc-display-meta.ts @@ -10,7 +10,7 @@ export class DocDisplayMetaService extends Service { super(); } - getDocDisplayMeta(docRecord: DocRecord) { + getDocDisplayMeta(docRecord: DocRecord, originalTitle?: string) { const journalDateString = this.propertiesAdapter.getJournalPageDateString( docRecord.id ); @@ -22,7 +22,8 @@ export class DocDisplayMetaService extends Service { const title = journalDateString ? i18nTime(journalDateString, { absolute: { accuracy: 'day' } }) - : docRecord.meta$.value.title || + : originalTitle || + docRecord.meta$.value.title || ({ key: 'Untitled', } as const);