Browse Source

reorganize modules

Yuki Takei 7 months ago
parent
commit
4883112bab

+ 1 - 0
apps/app/src/pages/[[...path]]/consts/index.ts

@@ -0,0 +1 @@
+export const NEXT_JS_ROUTING_PAGE = '[[...path]]';

+ 0 - 10
apps/app/src/pages/[[...path]]/hooks/index.ts

@@ -1,10 +0,0 @@
-/**
- * Custom hooks and utilities for [[...path]].page.tsx component
- *
- * This module exports navigation and routing hooks that were extracted
- * from the main page component to improve maintainability and testability.
- * Also includes optimized utility functions for common navigation operations.
- */
-
-export { useSameRouteNavigation } from '../use-same-route-navigation';
-export { useShallowRouting } from '../use-shallow-routing';

+ 8 - 7
apps/app/src/pages/[[...path]]/index.page.tsx

@@ -35,17 +35,18 @@ import { useEditingMarkdown } from '~/states/ui/editor';
 import { useSWRMUTxCurrentPageYjsData } from '~/stores/yjs';
 
 import type { NextPageWithLayout } from '../_app.page';
+import { registerPageToShowRevisionWithMeta } from '../general-page/superjson/page-to-show-revision-with-meta';
+import type {
+  Props, InitialProps, SameRouteEachProps,
+} from '../general-page/types';
+import { useInitialCSRFetch } from '../general-page/use-initial-skip-ssr-fetch';
+import { useSameRouteNavigation } from '../general-page/use-same-route-navigation';
 import { NextjsRoutingType, detectNextjsRoutingType } from '../utils/nextjs-routing-utils';
 import { useCustomTitleForPage } from '../utils/page-title-customization';
 
-import { NEXT_JS_ROUTING_PAGE } from './common-helpers';
-import { useSameRouteNavigation, useShallowRouting } from './hooks';
+import { NEXT_JS_ROUTING_PAGE } from './consts';
 import { getServerSidePropsForInitial, getServerSidePropsForSameRoute } from './server-side-props';
-import { registerPageToShowRevisionWithMeta } from './superjson/page-to-show-revision-with-meta';
-import type {
-  Props, InitialProps, SameRouteEachProps,
-} from './types';
-import { useInitialCSRFetch } from './use-initial-skip-ssr-fetch';
+import { useShallowRouting } from './use-shallow-routing';
 
 // call superjson custom register
 registerPageToShowRevisionWithMeta();

+ 1 - 1
apps/app/src/pages/[[...path]]/page-data-props.ts

@@ -8,7 +8,7 @@ import type { CrowiRequest } from '~/interfaces/crowi-request';
 import type { PageModel } from '~/server/models/page';
 import type { IPageRedirect, PageRedirectModel } from '~/server/models/page-redirect';
 
-import type { InitialProps, SameRouteEachProps } from './types';
+import type { InitialProps, SameRouteEachProps } from '../general-page/types';
 
 // Utility to resolve path, redirect, and identical path page check
 type PathResolutionResult = {

+ 6 - 8
apps/app/src/pages/[[...path]]/server-side-props.ts

@@ -6,15 +6,13 @@ import { getServerSideI18nProps } from '~/pages/utils/i18n';
 import { getServerSideCommonInitialProps, getServerSideCommonEachProps } from '../utils/commons';
 import { getServerSideUserUISettingsProps } from '../utils/user-ui-settings';
 
-import {
-  NEXT_JS_ROUTING_PAGE,
-  mergeGetServerSidePropsResults,
-} from './common-helpers';
-import { getServerSideConfigurationProps, getServerSideRendererConfigProps, getServerSideSidebarConfigProps } from './configuration-props';
-import { getActivityAction } from './get-activity-action';
+import { mergeGetServerSidePropsResults } from '../general-page/common-helpers';
+import { getServerSideConfigurationProps, getServerSideRendererConfigProps, getServerSideSidebarConfigProps } from '../general-page/configuration-props';
+import { NEXT_JS_ROUTING_PAGE } from './consts';
+import { getActivityAction } from '../general-page/get-activity-action';
 import { getPageDataForInitial, getPageDataForSameRoute } from './page-data-props';
-import type { InitialProps, SameRouteEachProps } from './types';
-import { isValidInitialAndSameRouteProps, isValidSameRouteProps } from './types';
+import type { InitialProps, SameRouteEachProps } from '../general-page/types';
+import { isValidInitialAndSameRouteProps, isValidSameRouteProps } from '../general-page/types';
 
 const nextjsRoutingProps = {
   props: {

+ 1 - 1
apps/app/src/pages/[[...path]]/use-shallow-routing.ts

@@ -3,7 +3,7 @@ import { useEffect, useRef } from 'react';
 import { isClient } from '@growi/core/dist/utils';
 import { useRouter } from 'next/router';
 
-import type { Props } from './types';
+import type { Props } from '../general-page/types';
 
 /**
  * Custom hook for syncing pathname by Shallow Routing

+ 0 - 2
apps/app/src/pages/[[...path]]/common-helpers.ts → apps/app/src/pages/general-page/common-helpers.ts

@@ -5,8 +5,6 @@ import type { SSRConfig } from 'next-i18next';
 import type { CrowiRequest } from '~/interfaces/crowi-request';
 import { getLangAtServerSide } from '~/pages/utils/locale';
 
-export const NEXT_JS_ROUTING_PAGE = '[[...path]]';
-
 // Shared helper function to create i18n config with proper configuration
 export async function createNextI18NextConfig(
     context: GetServerSidePropsContext,

+ 0 - 0
apps/app/src/pages/[[...path]]/configuration-props.ts → apps/app/src/pages/general-page/configuration-props.ts


+ 0 - 0
apps/app/src/pages/[[...path]]/get-activity-action.ts → apps/app/src/pages/general-page/get-activity-action.ts


+ 0 - 0
apps/app/src/pages/[[...path]]/superjson/page-to-show-revision-with-meta.ts → apps/app/src/pages/general-page/superjson/page-to-show-revision-with-meta.ts


+ 0 - 0
apps/app/src/pages/[[...path]]/types.ts → apps/app/src/pages/general-page/types.ts


+ 0 - 0
apps/app/src/pages/[[...path]]/use-initial-skip-ssr-fetch.ts → apps/app/src/pages/general-page/use-initial-skip-ssr-fetch.ts


+ 0 - 0
apps/app/src/pages/[[...path]]/use-same-route-navigation.spec.tsx → apps/app/src/pages/general-page/use-same-route-navigation.spec.tsx


+ 0 - 0
apps/app/src/pages/[[...path]]/use-same-route-navigation.ts → apps/app/src/pages/general-page/use-same-route-navigation.ts


+ 1 - 1
apps/app/src/pages/utils/i18n.ts

@@ -1,7 +1,7 @@
 import type { GetServerSidePropsContext, GetServerSidePropsResult } from 'next';
 import type { SSRConfig } from 'next-i18next';
 
-import { createNextI18NextConfig } from '../[[...path]]/common-helpers';
+import { createNextI18NextConfig } from '../general-page/common-helpers';
 
 export const getServerSideI18nProps = async(
     context: GetServerSidePropsContext,