File tree Expand file tree Collapse file tree 3 files changed +32
-2
lines changed
Expand file tree Collapse file tree 3 files changed +32
-2
lines changed Original file line number Diff line number Diff line change 11export { registerPageToShowRevisionWithMeta } from './page-to-show-revision-with-meta' ;
2+ export { registerShareLinkRelatedPage } from './share-link-related-page' ;
Original file line number Diff line number Diff line change 1+ import type { IPagePopulatedToShowRevision } from '@growi/core/dist/interfaces' ;
2+ import superjson from 'superjson' ;
3+
4+ import type { PageDocument } from '~/server/models/page' ;
5+
6+ type IShareLinkRelatedPage = IPagePopulatedToShowRevision & PageDocument ;
7+
8+ let isRegistered = false ;
9+
10+ export const registerShareLinkRelatedPage = ( ) : void => {
11+ if ( isRegistered ) return ;
12+
13+ superjson . registerCustom < IShareLinkRelatedPage , string > (
14+ {
15+ isApplicable : ( v ) : v is IShareLinkRelatedPage => {
16+ return v != null && ( v as PageDocument ) . toObject != null ;
17+ } ,
18+ serialize : ( v ) => {
19+ return superjson . stringify ( v . toObject ( ) ) ;
20+ } ,
21+ deserialize : ( v ) => {
22+ return superjson . parse ( v ) ;
23+ } ,
24+ } ,
25+ 'IShareLinkRelatedPageTransformer' ,
26+ ) ;
27+
28+ isRegistered = true ;
29+ } ;
Original file line number Diff line number Diff line change @@ -26,13 +26,13 @@ import {
2626import type { NextPageWithLayout } from '../../_app.page' ;
2727import { useInitialCSRFetch } from '../../general-page' ;
2828import { useHydrateGeneralPageConfigurationAtoms } from '../../general-page/hydrate' ;
29- import { registerPageToShowRevisionWithMeta } from '../../general-page/superjson' ;
29+ import { registerShareLinkRelatedPage } from '../../general-page/superjson' ;
3030import { NEXT_JS_ROUTING_PAGE } from './consts' ;
3131import { getServerSidePropsForInitial } from './server-side-props' ;
3232import type { InitialProps } from './types' ;
3333
3434// call superjson custom register
35- registerPageToShowRevisionWithMeta ( ) ;
35+ registerShareLinkRelatedPage ( ) ;
3636
3737const GrowiContextualSubNavigation = dynamic (
3838 // biome-ignore lint/style/noRestrictedImports: no-problem dynamic import
You can’t perform that action at this time.
0 commit comments