fix: rendering error caused by async components in the post modal
This commit is contained in:
@@ -6,8 +6,10 @@ import PageContent from "~/components/common/PageContent"
|
||||
import PostModal from "~/components/home/PostModal"
|
||||
import { PostFooter } from "~/components/site/PostFooter"
|
||||
import PostMeta from "~/components/site/PostMeta"
|
||||
import { useTranslation } from "~/lib/i18n"
|
||||
import { toCid } from "~/lib/ipfs-parser"
|
||||
import getQueryClient from "~/lib/query-client"
|
||||
import { fetchGetPage } from "~/queries/page.server"
|
||||
import { fetchGetPage, getSummary } from "~/queries/page.server"
|
||||
import { fetchGetSite } from "~/queries/site.server"
|
||||
|
||||
export default async function SiteModal({
|
||||
@@ -40,6 +42,16 @@ export default async function SiteModal({
|
||||
|
||||
const dehydratedState = dehydrate(queryClient)
|
||||
|
||||
const { i18n } = await useTranslation()
|
||||
const { t } = await useTranslation("common")
|
||||
let summary: string | undefined
|
||||
if (!page.metadata.content.disableAISummary) {
|
||||
summary = await getSummary({
|
||||
cid: toCid(page.metadata?.uri || ""),
|
||||
lang: i18n.resolvedLanguage,
|
||||
})
|
||||
}
|
||||
|
||||
return (
|
||||
<PostModal>
|
||||
<div>
|
||||
@@ -55,7 +67,14 @@ export default async function SiteModal({
|
||||
</h2>
|
||||
)}
|
||||
{page?.metadata?.content?.tags?.includes("post") && (
|
||||
<PostMeta page={page} site={site} />
|
||||
<PostMeta
|
||||
page={page}
|
||||
site={site}
|
||||
summary={summary}
|
||||
translated={{
|
||||
"AI-generated summary": t("AI-generated summary"),
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
<PageContent
|
||||
|
||||
@@ -10,10 +10,12 @@ import { PostFooter } from "~/components/site/PostFooter"
|
||||
import PostMeta from "~/components/site/PostMeta"
|
||||
import { SITE_URL } from "~/lib/env"
|
||||
import { getSiteLink } from "~/lib/helpers"
|
||||
import { useTranslation } from "~/lib/i18n"
|
||||
import { toCid } from "~/lib/ipfs-parser"
|
||||
import { isInRN } from "~/lib/is-in-rn"
|
||||
import getQueryClient from "~/lib/query-client"
|
||||
import { isOnlyContent } from "~/lib/search-parser"
|
||||
import { fetchGetPage } from "~/queries/page.server"
|
||||
import { fetchGetPage, getSummary } from "~/queries/page.server"
|
||||
import { fetchGetSite } from "~/queries/site.server"
|
||||
|
||||
export async function generateMetadata({
|
||||
@@ -127,6 +129,16 @@ export default async function SitePagePage({
|
||||
}
|
||||
}
|
||||
|
||||
const { i18n } = await useTranslation()
|
||||
const { t } = await useTranslation("common")
|
||||
let summary: string | undefined
|
||||
if (!page.metadata.content.disableAISummary) {
|
||||
summary = await getSummary({
|
||||
cid: toCid(page.metadata?.uri || ""),
|
||||
lang: i18n.resolvedLanguage,
|
||||
})
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
<script
|
||||
@@ -146,7 +158,14 @@ export default async function SitePagePage({
|
||||
</h2>
|
||||
)}
|
||||
{page?.metadata?.content?.tags?.includes("post") && (
|
||||
<PostMeta page={page} site={site} />
|
||||
<PostMeta
|
||||
page={page}
|
||||
site={site}
|
||||
summary={summary}
|
||||
translated={{
|
||||
"AI-generated summary": t("AI-generated summary"),
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
|
||||
@@ -4,29 +4,21 @@ import { EditButton } from "~/components/site/EditButton"
|
||||
import PostTag from "~/components/site/PostTag"
|
||||
import { UniLink } from "~/components/ui/UniLink"
|
||||
import { CSB_SCAN } from "~/lib/env"
|
||||
import { useTranslation } from "~/lib/i18n"
|
||||
import { toCid } from "~/lib/ipfs-parser"
|
||||
import { ExpandedCharacter, ExpandedNote } from "~/lib/types"
|
||||
import { getSummary } from "~/queries/page.server"
|
||||
|
||||
export default async function PostMeta({
|
||||
export default function PostMeta({
|
||||
page,
|
||||
site,
|
||||
summary,
|
||||
translated,
|
||||
}: {
|
||||
page: ExpandedNote
|
||||
site?: ExpandedCharacter
|
||||
}) {
|
||||
const { t } = await useTranslation("common")
|
||||
const { i18n } = await useTranslation()
|
||||
|
||||
let summary: string | undefined
|
||||
if (!page.metadata.content.disableAISummary) {
|
||||
summary = await getSummary({
|
||||
cid: toCid(page.metadata?.uri || ""),
|
||||
lang: i18n.resolvedLanguage,
|
||||
})
|
||||
summary?: string
|
||||
translated?: {
|
||||
"AI-generated summary": string
|
||||
}
|
||||
|
||||
}) {
|
||||
return (
|
||||
<div className="xlog-post-meta">
|
||||
<div className="text-zinc-400 mt-4 space-x-5 flex items-center">
|
||||
@@ -64,7 +56,7 @@ export default async function PostMeta({
|
||||
<div className="xlog-post-summary border rounded-xl mt-4 p-4 space-y-2">
|
||||
<div className="font-bold text-zinc-700 flex items-center">
|
||||
<i className="icon-[mingcute--android-2-line] mr-2 text-lg" />
|
||||
{t("AI-generated summary")}
|
||||
{translated?.["AI-generated summary"] || "AI-generated summary"}
|
||||
</div>
|
||||
<div className="text-zinc-500 leading-loose text-sm">{summary}</div>
|
||||
</div>
|
||||
|
||||
@@ -6,7 +6,7 @@ import { getSiteRelativeUrl } from "~/lib/helpers"
|
||||
|
||||
import { UniLink } from "../ui/UniLink"
|
||||
|
||||
export default async function PostTag({ tag }: { tag: string }) {
|
||||
export default function PostTag({ tag }: { tag: string }) {
|
||||
const pathname = usePathname()
|
||||
|
||||
return (
|
||||
|
||||
Reference in New Issue
Block a user