search by text content functionality

This commit is contained in:
daniel31x13
2023-11-01 06:01:26 -04:00
parent b1c6a3faf1
commit b1b0d98eb2
9 changed files with 37 additions and 0 deletions
+5
View File
@@ -45,6 +45,10 @@ export default async function archive(
const dom = new JSDOM(cleanedUpContent, { url: url });
const article = new Readability(dom.window.document).parse();
const articleText = article?.textContent
.replace(/ +(?= )/g, "") // strip out multiple spaces
.replace(/(\r\n|\n|\r)/gm, " "); // strip out line breaks
await createFile({
data: JSON.stringify(article),
filePath: `archives/${targetLink.collectionId}/${linkId}_readability.json`,
@@ -54,6 +58,7 @@ export default async function archive(
where: { id: linkId },
data: {
readabilityPath: `archives/${targetLink.collectionId}/${linkId}_readability.json`,
textContent: articleText,
},
});
+9
View File
@@ -42,6 +42,15 @@ export default async function getLink(userId: number, query: LinkRequestQuery) {
});
}
if (query.searchByTextContent) {
searchConditions.push({
textContent: {
contains: query.searchQueryString,
mode: POSTGRES_IS_ENABLED ? "insensitive" : undefined,
},
});
}
if (query.searchByTags) {
searchConditions.push({
tags: {