feat: skip skipExpansion for archives and tags long list

This commit is contained in:
DIYgod 2023-07-28 16:43:22 +01:00
parent 4b9827305b
commit 3fc114bc6b
No known key found for this signature in database
5 changed files with 14 additions and 7 deletions

View File

@ -12,6 +12,7 @@ export async function GET(req: Request) {
limit: query.limit ? parseInt(query.limit as string) : undefined,
cursor: query.cursor as string,
useStat: true,
skipExpansion: query.skipExpansion === "true",
...(query.tags && {
tags: Array.isArray(query.tags)
? (query.tags as string[])

View File

@ -42,6 +42,7 @@ export default async function SiteArchivesPage({
type: "post",
visibility: PageVisibilityEnum.Published,
limit: 100,
skipExpansion: true,
},
queryClient,
)

View File

@ -48,6 +48,7 @@ export default async function SiteTagPage({
type: "post",
visibility: PageVisibilityEnum.Published,
limit: 100,
skipExpansion: true,
tags: [params.tag],
},
queryClient,

View File

@ -29,9 +29,10 @@ export const SiteArchives = () => {
const site = useGetSite(params?.site as string)
const posts = useGetPagesBySiteLite({
characterId: site.data?.characterId,
limit: 100,
type: "post",
visibility: PageVisibilityEnum.Published,
limit: 100,
skipExpansion: true,
...(params?.tag && { tags: [params.tag as string] }),
})

View File

@ -143,6 +143,7 @@ export async function getPagesBySite(input: {
useHTML?: boolean
keepBody?: boolean
handle?: string // In order to be compatible with old drafts
skipExpansion?: boolean
}) {
if (!input.characterId) {
return {
@ -185,12 +186,14 @@ export async function getPagesBySite(input: {
pinnedNoteId: pinnedNote?.noteId,
list: await Promise.all(
list.map(async (note) => {
const expanded = await expandCrossbellNote({
note,
useStat: input.useStat,
useHTML: input.useHTML,
useScore: false,
})
const expanded = input.skipExpansion
? (note as ExpandedNote)
: await expandCrossbellNote({
note,
useStat: input.useStat,
useHTML: input.useHTML,
useScore: false,
})
if (!input.keepBody) {
delete expanded.metadata?.content?.content