mirror of
https://github.com/zadam/trilium.git
synced 2025-10-19 22:58:52 +02:00
chore(server): different handling of buffer vs string
This commit is contained in:
parent
58a883797d
commit
979ef6287f
@ -123,7 +123,9 @@ export function buildRewardMap(note: BNote) {
|
||||
|
||||
if (note.type === "text" && note.isDecrypted) {
|
||||
const content = note.getContent();
|
||||
const dom = parse(content.toString());
|
||||
if (typeof content !== "string") return map;
|
||||
|
||||
const dom = parse(content);
|
||||
|
||||
const addHeadingsToRewardMap = (elName: string, rewardFactor: number) => {
|
||||
for (const el of dom.querySelectorAll(elName)) {
|
||||
|
@ -257,11 +257,8 @@ export function findExcerpts(sourceNote: BNote, referencedNoteId: string) {
|
||||
|
||||
const excerpts: string[] = [];
|
||||
|
||||
console.log("Removing images")
|
||||
removeImages(document);
|
||||
|
||||
console.log("Querying links");
|
||||
|
||||
for (const linkEl of document.querySelectorAll("a")) {
|
||||
console.log("Got ", linkEl.innerHTML);
|
||||
const href = linkEl.getAttribute("href");
|
||||
@ -275,7 +272,6 @@ export function findExcerpts(sourceNote: BNote, referencedNoteId: string) {
|
||||
let centerEl: HTMLElement = linkEl;
|
||||
|
||||
while (centerEl.tagName !== "BODY" && centerEl.parentNode && (centerEl.parentNode?.textContent?.length || 0) <= EXCERPT_CHAR_LIMIT) {
|
||||
console.log("Got ", centerEl.tagName, centerEl.parentNode);
|
||||
centerEl = centerEl.parentNode;
|
||||
}
|
||||
|
||||
@ -371,7 +367,6 @@ function getBacklinks(req: Request): BacklinksResponse {
|
||||
let backlinksWithExcerptCount = 0;
|
||||
|
||||
return getFilteredBacklinks(note).map((backlink) => {
|
||||
console.log("Processing ", backlink);
|
||||
const sourceNote = backlink.note;
|
||||
|
||||
if (sourceNote.type !== "text" || backlinksWithExcerptCount > 50) {
|
||||
|
@ -66,7 +66,8 @@ function renderIndex(result: Result) {
|
||||
}
|
||||
|
||||
function renderText(result: Result, note: SNote) {
|
||||
const document = parse(result.content?.toString() || "");
|
||||
if (typeof result.content !== "string") return;
|
||||
const document = parse(result.content || "");
|
||||
|
||||
// Process include notes.
|
||||
for (const includeNoteEl of document.querySelectorAll("section.include-note")) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user