From a1a72ae1171de73bbc391936bc3282ca558328c9 Mon Sep 17 00:00:00 2001 From: Innei Date: Fri, 28 Jul 2023 15:06:13 +0800 Subject: [PATCH] feat: page route preview support --- src/app/preview/page.tsx | 55 ++++++++++++++++++- .../page/CurrentPageDataProvider.tsx | 2 + 2 files changed, 56 insertions(+), 1 deletion(-) diff --git a/src/app/preview/page.tsx b/src/app/preview/page.tsx index 6155f06e79..c2eccd5fef 100644 --- a/src/app/preview/page.tsx +++ b/src/app/preview/page.tsx @@ -6,6 +6,7 @@ import { atom, useAtomValue } from 'jotai' import type { NoteModel, NoteWrappedPayload, + PageModel, PostModel, } from '@mx-space/api-client' @@ -15,8 +16,10 @@ import { previewDataAtom } from '~/atoms/preview' import { ErrorBoundary } from '~/components/common/ErrorBoundary' import { Paper } from '~/components/layout/container/Paper' import { NoteBanner, NoteMetaBar } from '~/components/widgets/note' +import { PageActionAside } from '~/components/widgets/page/PageActionAside' import { PostActionAside } from '~/components/widgets/post' import { ArticleRightAside } from '~/components/widgets/shared/ArticleRightAside' +import { ReadIndicatorForMobile } from '~/components/widgets/shared/ReadIndicator' import { debounce } from '~/lib/_' import { jotaiStore } from '~/lib/store' import { isNoteModel, isPageModel, isPostModel } from '~/lib/url-builder' @@ -24,6 +27,10 @@ import { CurrentNoteDataAtomProvider, CurrentNoteDataProvider, } from '~/providers/note/CurrentNoteDataProvider' +import { + CurrentPageDataAtomProvider, + CurrentPageDataProvider, +} from '~/providers/page/CurrentPageDataProvider' import { CurrentPostDataAtomProvider, CurrentPostDataProvider, @@ -34,6 +41,12 @@ import { } from '~/providers/shared/LayoutRightSideProvider' import { WrappedElementProvider } from '~/providers/shared/WrappedElementProvider' +import { + MarkdownImageRecordProviderInternal, + PageMarkdown, + PageSubTitle, + PageTitle, +} from '../(page-detail)/[slug]/pageExtra' import { IndentArticleContainer, NoteHeaderDate, @@ -42,6 +55,7 @@ import { NoteTitle, } from '../notes/[id]/pageExtra' import { + HeaderMetaInfoSetting, PostMarkdown, PostMarkdownImageRecordProvider, PostMetaBarInternal, @@ -91,7 +105,7 @@ export default function PreviewPage() { return case isPageModel(previewData): - return
TODO
+ return } return null @@ -187,3 +201,42 @@ const NotePreview = () => { ) } + +const PagePreview = () => { + const data = useAtomValue(previewDataAtom) as PageModel + + const overrideAtom = useMemo(() => atom(null as null | PageModel), []) + + return ( +
+ + +
+ +
+
+ + + +
+ + + + + + + + + + + + + +
+
+ + +
+
+ ) +} diff --git a/src/providers/page/CurrentPageDataProvider.tsx b/src/providers/page/CurrentPageDataProvider.tsx index d2e9157922..cae447498f 100644 --- a/src/providers/page/CurrentPageDataProvider.tsx +++ b/src/providers/page/CurrentPageDataProvider.tsx @@ -11,6 +11,7 @@ const { getGlobalCurrentData: getCurrentData, setGlobalCurrentData: setCurrentData, useCurrentDataSelector, + CurrentDataAtomProvider, } = createDataProvider() declare global { @@ -25,4 +26,5 @@ export { getCurrentData as getCurrentPageData, setCurrentData as setCurrentPageData, useCurrentDataSelector as useCurrentPageDataSelector, + CurrentDataAtomProvider as CurrentPageDataAtomProvider, }