fix: missing home excerpt

This commit is contained in:
DIYgod 2022-08-17 20:26:47 +01:00
parent c570c6a617
commit 664c2b0121
No known key found for this signature in database
GPG Key ID: D159328F47A80DCA
3 changed files with 7 additions and 32 deletions

View File

@ -8,8 +8,12 @@ export const remarkExcerpt: Plugin<Array<{ env: MarkdownEnv }>, Root> =
(tree) => {
for (const node of tree.children) {
if (node.type === "paragraph") {
env.excerpt = mdAstToString(node)
break
env.excerpt = mdAstToString(node, {
includeImageAlt: false,
}).slice(0, 140)
if (env.excerpt) {
break
}
}
}
}

View File

@ -239,36 +239,6 @@ export async function getPage<TRender extends boolean = false>(input: {
throw notFound(`page ${input.page} not found`)
}
if (pages?.list) {
pages.list = await Promise.all(
pages?.list.map(async (page) => {
if (
page.body?.content &&
page.body?.mime_type === "text/markdown" &&
input.render
) {
const rendered = await renderPageContent(page.body.content)
page.body = {
content: rendered.contentHTML,
mime_type: "text/html",
}
if (!page.summary) {
page.summary = {
content: rendered.excerpt,
mime_type: "text/html",
}
}
}
page.slug =
page.attributes?.find((a) => a.trait_type === "xlog_slug")?.value ||
page.metadata?.raw?._xlog_slug ||
page.metadata?.raw?._crosslog_slug ||
page.id
return page
}),
)
}
if (
page.body?.content &&
page.body?.mime_type === "text/markdown" &&

View File

@ -35,6 +35,7 @@ function SiteIndexPage({ domainOrSubdomain }: { domainOrSubdomain: string }) {
take: 1000,
type: "post",
visibility: PageVisibilityEnum.Published,
render: true,
})
return (