fix: redundant markdown module execution
This commit is contained in:
parent
f737a3b764
commit
062da37bc6
|
|
@ -3,6 +3,7 @@
|
|||
import { useDebounceEffect } from "ahooks"
|
||||
import type { Root } from "mdast"
|
||||
import { nanoid } from "nanoid"
|
||||
import dynamic from "next/dynamic"
|
||||
import { useParams, useRouter, useSearchParams } from "next/navigation"
|
||||
import {
|
||||
ChangeEvent,
|
||||
|
|
@ -20,7 +21,6 @@ import type { EditorView } from "@codemirror/view"
|
|||
import { DateInput } from "@mantine/dates"
|
||||
import { useQueryClient } from "@tanstack/react-query"
|
||||
|
||||
import { PageContent } from "~/components/common/PageContent"
|
||||
import { DashboardMain } from "~/components/dashboard/DashboardMain"
|
||||
import { OptionsButton } from "~/components/dashboard/OptionsButton"
|
||||
import { PublishButton } from "~/components/dashboard/PublishButton"
|
||||
|
|
@ -65,6 +65,13 @@ import {
|
|||
} from "~/queries/page"
|
||||
import { useGetSite } from "~/queries/site"
|
||||
|
||||
const DynamicPageContent = dynamic(
|
||||
() => import("~/components/common/PageContent"),
|
||||
{
|
||||
ssr: false,
|
||||
},
|
||||
)
|
||||
|
||||
export default function SubdomainEditor() {
|
||||
const router = useRouter()
|
||||
const queryClient = useQueryClient()
|
||||
|
|
@ -655,7 +662,7 @@ export default function SubdomainEditor() {
|
|||
</div>
|
||||
)}
|
||||
{isRendering && (
|
||||
<PageContent
|
||||
<DynamicPageContent
|
||||
className="bg-white px-5 overflow-scroll pb-[200px] h-full flex-1"
|
||||
parsedContent={parsedContent}
|
||||
inputRef={previewRef}
|
||||
|
|
|
|||
|
|
@ -1,10 +1,18 @@
|
|||
"use client"
|
||||
|
||||
import { PageContent } from "~/components/common/PageContent"
|
||||
import dynamic from "next/dynamic"
|
||||
|
||||
import { useTranslation } from "~/lib/i18n/client"
|
||||
import { useGetPage } from "~/queries/page"
|
||||
import { useGetSite } from "~/queries/site"
|
||||
|
||||
const DynamicPageContent = dynamic(
|
||||
() => import("~/components/common/PageContent"),
|
||||
{
|
||||
ssr: false,
|
||||
},
|
||||
)
|
||||
|
||||
export default function SitePreviewPage({
|
||||
params,
|
||||
}: {
|
||||
|
|
@ -46,11 +54,11 @@ export default function SitePreviewPage({
|
|||
</h2>
|
||||
)}
|
||||
</div>
|
||||
<PageContent
|
||||
<DynamicPageContent
|
||||
className="mt-10"
|
||||
content={page.data?.metadata?.content?.content}
|
||||
toc={true}
|
||||
></PageContent>
|
||||
></DynamicPageContent>
|
||||
</article>
|
||||
</>
|
||||
)
|
||||
|
|
|
|||
|
|
@ -57,3 +57,5 @@ export const PageContent = ({
|
|||
</PageContentContainer>
|
||||
)
|
||||
}
|
||||
|
||||
export default PageContent
|
||||
|
|
|
|||
|
|
@ -1,10 +1,13 @@
|
|||
import type { NoteMetadata } from "crossbell"
|
||||
import dynamic from "next/dynamic"
|
||||
import { useState } from "react"
|
||||
|
||||
import { useDate } from "~/hooks/useDate"
|
||||
import { useTranslation } from "~/lib/i18n/client"
|
||||
|
||||
import { PageContent } from "../common/PageContent"
|
||||
const DynamicPageContent = dynamic(() => import("../common/PageContent"), {
|
||||
ssr: false,
|
||||
})
|
||||
|
||||
export const ImportPreview = ({ note }: { note: NoteMetadata }) => {
|
||||
const date = useDate()
|
||||
|
|
@ -49,7 +52,10 @@ export const ImportPreview = ({ note }: { note: NoteMetadata }) => {
|
|||
>
|
||||
{t("Show more")}
|
||||
</div>
|
||||
<PageContent className="mt-4" content={note?.content}></PageContent>
|
||||
<DynamicPageContent
|
||||
className="mt-4"
|
||||
content={note?.content}
|
||||
></DynamicPageContent>
|
||||
</div>
|
||||
</article>
|
||||
)
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ const DynamicComment = dynamic(() => import("~/components/common/Comment"), {
|
|||
<p>Loading comments...</p>
|
||||
</div>
|
||||
),
|
||||
ssr: false,
|
||||
})
|
||||
|
||||
export const usePostFooterInView = () => {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
import { getDefaultSlug } from "~/lib/default-slug"
|
||||
import { renderPageContent } from "~/markdown"
|
||||
|
||||
const makeArray = (value: any) => {
|
||||
if (Array.isArray(value)) {
|
||||
|
|
@ -11,8 +10,9 @@ const makeArray = (value: any) => {
|
|||
return [value]
|
||||
}
|
||||
|
||||
export const readFiles = (files: FileList) => {
|
||||
export const readFiles = async (files: FileList) => {
|
||||
const promises = []
|
||||
const { renderPageContent } = await import("~/markdown")
|
||||
for (let i = 0; i < files.length; i++) {
|
||||
const file = files[i]
|
||||
promises.push(
|
||||
|
|
|
|||
Loading…
Reference in New Issue