|
@@ -8,7 +8,10 @@ import type { CrowiRequest } from '~/interfaces/crowi-request';
|
|
|
import type { PageModel } from '~/server/models/page';
|
|
import type { PageModel } from '~/server/models/page';
|
|
|
import type { IPageRedirect, PageRedirectModel } from '~/server/models/page-redirect';
|
|
import type { IPageRedirect, PageRedirectModel } from '~/server/models/page-redirect';
|
|
|
|
|
|
|
|
-import type { InitialProps, SameRouteEachProps } from '../general-page';
|
|
|
|
|
|
|
+import type { CommonEachProps } from '../common-props';
|
|
|
|
|
+import type { InitialProps } from '../general-page';
|
|
|
|
|
+
|
|
|
|
|
+import type { EachProps } from './types';
|
|
|
|
|
|
|
|
// Utility to resolve path, redirect, and identical path page check
|
|
// Utility to resolve path, redirect, and identical path page check
|
|
|
type PathResolutionResult = {
|
|
type PathResolutionResult = {
|
|
@@ -57,7 +60,8 @@ export async function getPageDataForInitial(
|
|
|
context: GetServerSidePropsContext,
|
|
context: GetServerSidePropsContext,
|
|
|
): Promise<GetServerSidePropsResult<
|
|
): Promise<GetServerSidePropsResult<
|
|
|
Pick<InitialProps, 'pageWithMeta' | 'isNotFound' | 'isNotCreatable' | 'isForbidden' | 'skipSSR'> &
|
|
Pick<InitialProps, 'pageWithMeta' | 'isNotFound' | 'isNotCreatable' | 'isForbidden' | 'skipSSR'> &
|
|
|
- Pick<SameRouteEachProps, 'currentPathname' | 'isIdenticalPathPage'>
|
|
|
|
|
|
|
+ Pick<CommonEachProps, 'currentPathname'> &
|
|
|
|
|
+ EachProps
|
|
|
>> {
|
|
>> {
|
|
|
const req: CrowiRequest = context.req as CrowiRequest;
|
|
const req: CrowiRequest = context.req as CrowiRequest;
|
|
|
const { crowi, user } = req;
|
|
const { crowi, user } = req;
|
|
@@ -74,7 +78,7 @@ export async function getPageDataForInitial(
|
|
|
const pageId = _isPermalink(pathFromUrl) ? removeHeadingSlash(pathFromUrl) : null;
|
|
const pageId = _isPermalink(pathFromUrl) ? removeHeadingSlash(pathFromUrl) : null;
|
|
|
const isPermalink = _isPermalink(pathFromUrl);
|
|
const isPermalink = _isPermalink(pathFromUrl);
|
|
|
|
|
|
|
|
- const { resolvedPathname, isIdenticalPathPage } = await resolvePathAndCheckIdentical(pathFromUrl, user);
|
|
|
|
|
|
|
+ const { resolvedPathname, isIdenticalPathPage, redirectFrom } = await resolvePathAndCheckIdentical(pathFromUrl, user);
|
|
|
|
|
|
|
|
if (isIdenticalPathPage) {
|
|
if (isIdenticalPathPage) {
|
|
|
return {
|
|
return {
|
|
@@ -86,6 +90,7 @@ export async function getPageDataForInitial(
|
|
|
isNotCreatable: true,
|
|
isNotCreatable: true,
|
|
|
isForbidden: false,
|
|
isForbidden: false,
|
|
|
skipSSR: false,
|
|
skipSSR: false,
|
|
|
|
|
+ redirectFrom,
|
|
|
},
|
|
},
|
|
|
};
|
|
};
|
|
|
}
|
|
}
|
|
@@ -133,6 +138,7 @@ export async function getPageDataForInitial(
|
|
|
isNotCreatable: false,
|
|
isNotCreatable: false,
|
|
|
isForbidden: false,
|
|
isForbidden: false,
|
|
|
skipSSR,
|
|
skipSSR,
|
|
|
|
|
+ redirectFrom,
|
|
|
},
|
|
},
|
|
|
};
|
|
};
|
|
|
}
|
|
}
|
|
@@ -151,6 +157,7 @@ export async function getPageDataForInitial(
|
|
|
isNotCreatable: !isCreatablePage(resolvedPathname),
|
|
isNotCreatable: !isCreatablePage(resolvedPathname),
|
|
|
isForbidden: count > 0,
|
|
isForbidden: count > 0,
|
|
|
skipSSR: false,
|
|
skipSSR: false,
|
|
|
|
|
+ redirectFrom,
|
|
|
},
|
|
},
|
|
|
};
|
|
};
|
|
|
}
|
|
}
|
|
@@ -158,7 +165,10 @@ export async function getPageDataForInitial(
|
|
|
// Page data retrieval for same-route navigation
|
|
// Page data retrieval for same-route navigation
|
|
|
export async function getPageDataForSameRoute(
|
|
export async function getPageDataForSameRoute(
|
|
|
context: GetServerSidePropsContext,
|
|
context: GetServerSidePropsContext,
|
|
|
-): Promise<GetServerSidePropsResult<Pick<SameRouteEachProps, 'currentPathname' | 'isIdenticalPathPage' | 'redirectFrom'>>> {
|
|
|
|
|
|
|
+): Promise<GetServerSidePropsResult<
|
|
|
|
|
+ Pick<CommonEachProps, 'currentPathname'> &
|
|
|
|
|
+ EachProps
|
|
|
|
|
+>> {
|
|
|
const req: CrowiRequest = context.req as CrowiRequest;
|
|
const req: CrowiRequest = context.req as CrowiRequest;
|
|
|
const { user } = req;
|
|
const { user } = req;
|
|
|
|
|
|