fix: html content in feed

This commit is contained in:
DIYgod
2023-05-17 00:41:37 +01:00
parent 46969f85cb
commit 22b0d2d5e6
8 changed files with 75 additions and 21 deletions
+33 -11
View File
@@ -27,6 +27,7 @@ export async function getFeed({
searchKeyword,
searchType,
tag,
useHTML,
}: {
type?: FeedType
cursor?: string
@@ -37,6 +38,7 @@ export async function getFeed({
searchKeyword?: string
searchType?: SearchType
tag?: string
useHTML?: boolean
}) {
if (type === "search" && !searchKeyword) {
type = "latest"
@@ -57,7 +59,12 @@ export async function getFeed({
const list = await Promise.all(
result.list.map(async (page: any) => {
const expand = await expandCrossbellNote(page, false, true)
const expand = await expandCrossbellNote({
note: page,
useStat: false,
useScore: true,
useHTML,
})
delete expand.metadata?.content.content
return expand
}),
@@ -87,7 +94,10 @@ export async function getFeed({
const list = await Promise.all(
result.list.map(async (page: any) => {
const expand = await expandCrossbellNote(page)
const expand = await expandCrossbellNote({
note: page,
useHTML,
})
delete expand.metadata?.content.content
return expand
}),
@@ -155,7 +165,10 @@ export async function getFeed({
const list = await Promise.all(
result?.data?.notes.map(async (page: any) => {
const expand = await expandCrossbellNote(page)
const expand = await expandCrossbellNote({
note: page,
useHTML,
})
delete expand.metadata?.content.content
return expand
}),
@@ -221,7 +234,10 @@ export async function getFeed({
page.stat.viewDetailCount / Math.max(Math.log10(secondAgo), 1)
}
const expand = await expandCrossbellNote(page)
const expand = await expandCrossbellNote({
note: page,
useHTML,
})
delete expand.metadata?.content.content
return expand
}),
@@ -255,12 +271,13 @@ export async function getFeed({
const list = await Promise.all(
result.list.map(async (page: any) => {
const expand = await expandCrossbellNote(
page,
false,
false,
searchKeyword,
)
const expand = await expandCrossbellNote({
note: page,
useStat: false,
useScore: false,
keyword: searchKeyword,
useHTML,
})
delete expand.metadata?.content.content
return expand
}),
@@ -295,7 +312,12 @@ export async function getFeed({
const list = await Promise.all(
result.list.map(async (page: any) => {
const expand = await expandCrossbellNote(page, false, true)
const expand = await expandCrossbellNote({
note: page,
useStat: false,
useScore: true,
useHTML,
})
delete expand.metadata?.content.content
return expand
}),
+17 -3
View File
@@ -220,6 +220,7 @@ export async function getPagesBySite(input: {
cursor?: string
tags?: string[]
useStat?: boolean
useHTML?: boolean
keepBody?: boolean
handle?: string // In order to be compatible with old drafts
}) {
@@ -244,7 +245,12 @@ export async function getPagesBySite(input: {
const list = await Promise.all(
notes?.list.map(async (note) => {
const expanded = await expandCrossbellNote(note, input.useStat)
const expanded = await expandCrossbellNote({
note,
useStat: input.useStat,
useHTML: input.useHTML,
useScore: false,
})
if (!input.keepBody) {
delete expanded.metadata?.content?.content
}
@@ -336,7 +342,12 @@ export async function getSearchPagesBySite(input: {
const list: ExpandedNote[] = await Promise.all(
result.list.map(async (page: any) => {
return await expandCrossbellNote(page, true, false, input.keyword)
return await expandCrossbellNote({
note: page,
useStat: true,
useScore: false,
keyword: input.keyword,
})
}),
)
@@ -390,7 +401,10 @@ export async function getPage<TRender extends boolean = false>(input: {
let expandedNote: ExpandedNote | undefined
if (page) {
expandedNote = await expandCrossbellNote(page, input.useStat)
expandedNote = await expandCrossbellNote({
note: page,
useStat: input.useStat,
})
}
if (localPage) {