feat(export/share): functional full-text search

This commit is contained in:
Elian Doran
2025-10-29 13:58:37 +02:00
parent f8c61ecde9
commit cf8089b07f
5 changed files with 68 additions and 22 deletions

View File

@@ -9,12 +9,15 @@ import type BNote from "../../../becca/entities/bnote.js";
import type BBranch from "../../../becca/entities/bbranch.js";
import { getShareThemeAssetDir } from "../../../routes/assets";
import { convert as convertToText } from "html-to-text";
import becca from "../../../becca/becca";
const shareThemeAssetDir = getShareThemeAssetDir();
interface SearchIndexEntry {
id: string;
title: string;
content: string;
path: string;
}
export default class ShareThemeExportProvider extends ZipExportProvider {
@@ -72,9 +75,14 @@ export default class ShareThemeExportProvider extends ZipExportProvider {
}
// Prepare search index.
this.searchIndex.set(note?.noteId, {
title: title,
content: searchContent
this.searchIndex.set(note.noteId, {
id: note.noteId,
title,
content: searchContent,
path: note.getBestNotePath()
.map(noteId => noteId !== "root" && becca.getNote(noteId)?.title)
.filter(noteId => noteId)
.join(" / ")
});
}