chore(server): different handling of buffer vs string

This commit is contained in:
Elian Doran 2025-09-29 09:55:34 +03:00
parent 58a883797d
commit 979ef6287f
No known key found for this signature in database
3 changed files with 5 additions and 7 deletions

View File

@ -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)) {

View File

@ -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) {

View File

@ -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")) {