fix: editor missing slug
This commit is contained in:
parent
8949f6b284
commit
1a300ca966
|
|
@ -100,6 +100,32 @@ export async function createOrUpdatePage(input: {
|
|||
)
|
||||
}
|
||||
|
||||
const expandPage = async (page: Note, render: boolean) => {
|
||||
if (
|
||||
page.body?.content &&
|
||||
page.body?.mime_type === "text/markdown" &&
|
||||
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
|
||||
}
|
||||
|
||||
export async function getPagesBySite(input: {
|
||||
site?: string
|
||||
type: "post" | "page"
|
||||
|
|
@ -165,28 +191,7 @@ export async function getPagesBySite(input: {
|
|||
|
||||
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
|
||||
expandPage(page, input.render || false)
|
||||
return page
|
||||
}),
|
||||
)
|
||||
|
|
@ -251,23 +256,7 @@ export async function getPage<TRender extends boolean = false>(input: {
|
|||
throw notFound(`page ${input.page} not found`)
|
||||
}
|
||||
|
||||
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",
|
||||
}
|
||||
}
|
||||
}
|
||||
expandPage(page, input.render || false)
|
||||
|
||||
return page
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue