From 13bee76234b016c875d7e9f41e328efe6c438ac1 Mon Sep 17 00:00:00 2001
From: Vadorequest
Date: Wed, 20 Jan 2021 21:57:51 +0100
Subject: [PATCH] (MAJOR) Massive folder structure refactoring
(`v2-mst-aptd-gcms-lcz-sty`), using modular approach and module path aliases
(#275)
---
.codeclimate.yml | 4 +-
.storybook/jsconfig.json | 28 ++
.storybook/main.js | 18 +
.storybook/preview.js | 34 +-
cypress/README.md | 16 +
cypress/integration/app/_sanity/2-customer.ts | 4 +-
cypress/integration/app/common/footer.ts | 2 +-
cypress/integration/app/common/nav.ts | 2 +-
cypress/jsconfig.json | 28 ++
cypress/support/commands.js | 2 +-
cypress/tsconfig.json | 23 ++
jest.config.js | 19 +
jest.extends.ts | 8 +-
next.config.js | 18 +-
package.json | 8 +-
src/README.md | 213 +++++++++++
src/app/README.md | 10 +
.../components}/BrowserPageBootstrap.tsx | 56 +--
.../components}/MultiversalAppBootstrap.tsx | 66 ++--
.../MultiversalGlobalExternalStyles.tsx | 0
.../components}/MultiversalGlobalStyles.tsx | 4 +-
.../components}/ServerPageBootstrap.tsx | 15 +-
src/{ => app}/constants.ts | 8 +-
src/{utils/nextjs => app}/getComponentName.ts | 8 +
.../types}/CommonServerSideParams.ts | 0
.../MultiversalAppBootstrapPageProps.ts | 2 +-
.../types}/MultiversalAppBootstrapProps.ts | 3 +-
src/{types/nextjs => app/types}/StaticPath.ts | 0
.../nextjs => app/types}/StaticPathsOutput.ts | 0
.../nextjs => app/types}/StaticPropsInput.ts | 2 +-
src/common/README.md | 9 +
.../components/ComponentTemplate.tsx | 0
.../components/animations}/Animated3Dots.tsx | 0
.../components/animations}/AnimatedLoader.tsx | 0
.../animations}/AnimatedTextBubble.tsx | 0
.../components/animations/Loader.tsx | 2 +-
.../countryFlags}/EnglishHybridFlag.tsx | 0
.../countryFlags}/EnglishUkFlag.tsx | 0
.../components/countryFlags}/FrenchFlag.tsx | 4 +-
.../components/dataDisplay}/AllProducts.tsx | 5 +-
.../components/dataDisplay}/Btn.tsx | 12 +-
.../components/dataDisplay}/BubbleTimer.tsx | 5 +-
.../components/dataDisplay}/Cards.tsx | 0
.../components/dataDisplay}/CircleBtn.tsx | 12 +-
.../components/dataDisplay}/Code.tsx | 2 +-
.../dataDisplay}/DocumentButton.tsx | 0
.../components/dataDisplay}/EllipsisText.tsx | 0
.../components/dataDisplay}/ExternalLink.tsx | 2 +-
.../components/dataDisplay}/LegalContent.tsx | 2 +-
.../components/dataDisplay}/LinkButton.tsx | 0
.../components/dataDisplay}/Logo.tsx | 55 +--
.../components/dataDisplay}/Markdown.tsx | 10 +-
.../components/dataDisplay}/ProductRow.tsx | 9 +-
.../components/dataDisplay}/Products.tsx | 3 +-
.../components/dataDisplay}/SimpleTooltip.tsx | 0
.../components/dataDisplay}/SpoilerLink.tsx | 0
.../components/dataDisplay}/Stamp.tsx | 0
.../components/dataDisplay}/Text.tsx | 0
.../components/dataDisplay}/ToggleButton.tsx | 0
.../components/dataDisplay}/Tooltip.tsx | 0
.../rehydration/DisplayOnBrowserMount.tsx | 0
src/{ => common}/hocs/withHOCTemplate.tsx | 0
src/{ => common}/hooks/useHasMounted.tsx | 0
src/{utils/node => common/utils}/fs-utils.ts | 0
src/{ => common}/utils/iframe.ts | 0
.../utils}/ignoreNoisyWarningsHacks.ts | 0
.../assets => common/utils}/logo.test.ts | 0
src/{utils/assets => common/utils}/logo.ts | 5 +-
src/{ => common}/utils/mobile.ts | 0
src/{utils/app => common/utils}/redirect.ts | 0
src/{utils/timers => common/utils}/waitFor.ts | 0
.../native-features/example-with-ssg.ts | 2 +-
.../native-features/example-with-ssr.ts | 0
src/layouts/README.md | 13 +
src/layouts/core/SSG.ts | 146 ++++++++
src/layouts/core/SSR.ts | 135 +++++++
.../core/components}/Footer.tsx | 21 +-
.../core/components}/Head.tsx | 16 +-
src/layouts/core/components/Layout.tsx | 132 +++++++
.../core/components}/Nav.tsx | 28 +-
src/layouts/core/components/PageContainer.tsx | 34 ++
.../core/types}/MultiversalPageProps.ts | 2 +-
.../core/types}/OnlyBrowserPageProps.ts | 4 +-
.../core/types}/OnlyServerPageProps.ts | 4 +-
.../core/types}/PublicHeaders.ts | 0
.../core/types}/SSGPageProps.ts | 4 +-
.../core/types}/SSRPageProps.ts | 2 +-
.../core/types}/SoftPageProps.ts | 0
.../default/components/DefaultFooter.tsx | 3 +
.../default/components/DefaultHead.tsx | 3 +
.../default/components/DefaultLayout.tsx | 3 +
src/layouts/default/components/DefaultNav.tsx | 3 +
.../components/DefaultPageContainer.tsx | 3 +
src/layouts/default/defaultSSG.ts | 4 +
src/layouts/default/defaultSSR.ts | 4 +
.../components}/BuiltInFeaturesSection.tsx | 117 +++---
.../components}/BuiltInFeaturesSidebar.tsx | 41 +-
.../components}/BuiltInUtilitiesSection.tsx | 58 ++-
.../components}/BuiltInUtilitiesSidebar.tsx | 29 +-
src/layouts/demo/components/DemoFooter.tsx | 173 +++++++++
src/layouts/demo/components/DemoHead.tsx | 129 +++++++
.../demo/components/DemoLayout.tsx} | 37 +-
src/layouts/demo/components/DemoNav.tsx | 354 ++++++++++++++++++
.../demo/components/DemoPage.tsx} | 6 +-
.../demo/components/DemoPageContainer.tsx} | 24 +-
.../demo/components/DemoSection.tsx} | 6 +-
.../components}/ExternalFeaturesSection.tsx | 16 +-
.../demo/components}/IntroductionSection.tsx | 10 +-
.../components}/NativeFeaturesSection.tsx | 37 +-
.../components}/NativeFeaturesSidebar.tsx | 21 +-
.../demo/components}/SidebarFooter.tsx | 5 +-
.../demo/components}/SidebarToggle.tsx | 2 +-
src/layouts/demo/demoSSG.ts | 146 ++++++++
.../nextjs/SSR.ts => layouts/demo/demoSSR.ts} | 68 ++--
src/modules/README.md | 13 +
.../core/amplitude}/amplitude.ts | 9 +-
.../amplitude/context}/amplitudeContext.tsx | 0
.../core/amplitude}/hooks/useAmplitude.tsx | 2 +-
.../core/amplitude}/types/Amplitude.ts | 0
.../core}/api/convertRequestBodyToJSObject.ts | 2 +-
.../core}/api/fetchJSON.test.ts | 0
src/{utils => modules/core}/api/fetchJSON.ts | 0
.../UniversalCookiesManager.browser.test.ts | 2 +-
.../UniversalCookiesManager.server.test.ts | 1 -
.../UniversalCookiesManager.ts | 6 +-
.../core/cookiesManager}/cookies.ts | 0
.../core/cookiesManager}/types/Cookies.ts | 0
src/{utils => modules/core/css}/css.test.ts | 0
src/{utils => modules/core/css}/css.ts | 2 +-
src/{ => modules/core/css}/types/CSSStyles.ts | 2 +-
.../core/data/contexts}/customerContext.tsx | 2 +-
.../core/data/contexts}/datasetContext.tsx | 2 +-
.../core/data}/hooks/useCustomer.tsx | 4 +-
.../core/data}/hooks/useDataset.tsx | 2 +-
.../core}/data/record.test.ts | 0
src/{utils => modules/core}/data/record.ts | 5 +-
.../data => modules/core/data/types}/Asset.ts | 0
.../core/data/types}/AssetThumbnail.ts | 0
.../core/data/types}/AssetTransformations.ts | 0
.../core/data/types}/Customer.ts | 2 +-
.../core/data/types}/CustomerTheme.ts | 0
.../core/data}/types/GenericObject.ts | 0
.../core/data/types}/GraphCMSDataset.ts | 4 +-
.../core/data/types}/GraphCMSSystemFields.ts | 0
src/modules/core/data/types/I18nMarkdown.ts | 6 +
.../core/data}/types/I18nRichText.ts | 0
src/modules/core/data/types/I18nString.ts | 4 +
.../data => modules/core/data/types}/Link.ts | 2 +-
.../data => modules/core/data/types}/Logo.ts | 0
src/{ => modules/core/data}/types/Markdown.ts | 0
.../core/data/types}/Product.ts | 0
src/{ => modules/core/data}/types/RichText.ts | 0
.../core/data}/types/SerializedRecord.ts | 0
.../core/data}/types/SidebarLink.ts | 0
.../data => modules/core/data/types}/Theme.ts | 0
.../core/data/types}/VisibilityStatus.ts | 0
src/{utils/js => modules/core/date}/date.ts | 2 +-
.../core/date}/getTimestampsElapsedTime.ts | 0
.../core/date}/timeDifference.ts | 0
src/{ => modules/core/date}/types/DateDay.ts | 0
.../errorHandling}/DefaultErrorLayout.tsx | 3 +-
.../core/errorHandling}/ErrorDebug.tsx | 2 +-
.../core/fontAwesome/fontAwesome.ts} | 0
.../core/githubActions}/dispatchWorkflow.ts | 6 +-
.../githubActions}/dispatchWorkflowByPath.ts | 12 +-
.../core/githubActions/types}/GHAWorkflow.ts | 0
.../types}/WorkflowsAPIResponse.ts | 0
.../gql/components}/GraphCMSAsset.test.tsx | 0
.../core/gql/components}/GraphCMSAsset.tsx | 35 +-
.../__snapshots__/GraphCMSAsset.test.tsx.snap | 0
.../core}/gql/graphcms.test.ts | 0
src/{utils => modules/core}/gql/graphcms.ts | 0
src/{utils => modules/core}/gql/graphql.ts | 0
.../core/gql}/hocs/withApollo.tsx | 20 +-
.../core/gql/types}/ApolloQueryOptions.ts | 0
.../i18n/components}/I18nBtnChangeLocale.tsx | 9 +-
.../core/i18n/components}/I18nLink.test.tsx | 3 +-
.../core/i18n/components}/I18nLink.tsx | 5 +-
.../components}/ToggleLanguagesButton.tsx | 2 +-
.../__snapshots__/I18nLink.test.tsx.snap | 0
.../core/i18n/contexts}/i18nContext.tsx | 0
src/{ => modules/core/i18n}/hooks/useI18n.tsx | 2 +-
src/{utils => modules/core}/i18n/i18n.ts | 4 +-
src/{ => modules/core/i18n}/i18nConfig.js | 0
.../core/i18n/i18nRouter.ts} | 0
.../core}/i18n/i18nextLocize.ts | 1 -
.../i18n}/middlewares/localeMiddleware.ts | 7 +-
.../core/i18n/types}/I18nLocale.ts | 0
src/{utils => modules/core}/js/array.test.ts | 0
src/{utils => modules/core}/js/array.ts | 0
src/{utils/math => modules/core/js}/random.ts | 0
src/{utils => modules/core}/js/string.test.ts | 0
src/{utils => modules/core}/js/string.ts | 15 +-
src/{ => modules/core/js}/types/Float.ts | 0
src/{ => modules/core/js}/types/Integer.ts | 0
src/{utils => modules/core}/js/url.test.ts | 2 +-
src/{utils => modules/core}/js/url.ts | 3 +-
.../core/lightHouse}/lighthouse.ts | 0
.../components}/PreviewModeBanner.tsx | 12 +-
.../contexts}/previewModeContext.tsx | 2 +-
.../previewMode}/hooks/usePreviewMode.tsx | 2 +-
.../core/previewMode}/previewMode.ts | 0
.../core/previewMode/types}/PreviewData.ts | 0
.../components}/QuickPreviewBanner.tsx | 12 +-
.../contexts}/quickPreviewContext.tsx | 0
.../quickPreview}/hooks/useQuickPreview.tsx | 2 +-
.../core}/quickPreview/quickPreview.ts | 0
.../core/react/types}/ReactButtonProps.ts | 0
.../core/react/types}/ReactDivProps.ts | 0
.../core/react/types}/ReactLinkProps.ts | 0
.../core/reactSelect}/reactSelect.ts | 2 +-
.../core/reactSelect}/types/ReactSelect.ts | 0
.../core/sentry}/sentry.ts | 5 +-
.../core/serializeSafe/deserializeSafe.ts | 8 +
.../core/serializeSafe/serializeSafe.ts | 9 +
.../core/serializeSafe}/types/Flatted.ts | 0
.../core/testing/contexts}/cypressContext.tsx | 0
.../core}/testing/cypress.ts | 0
.../core/testing}/hooks/useCypress.tsx | 2 +-
src/{ => modules/core/testing}/mocks/songs.ts | 0
.../core/testing/mocks}/tests-mocks.ts | 0
.../core/testing/tests}/env.test.ts | 0
.../core/testing/toContainObject.ts} | 1 +
src/{utils => modules/core/theming}/colors.ts | 0
.../data => modules/core/theming}/theme.ts | 14 +-
.../core}/theming/themedComponentColors.ts | 2 +-
.../core/theming/types/EmotionTheme.ts} | 3 +-
.../contexts}/userConsentContext.tsx | 0
.../core/userConsent}/cookieConsent.ts | 16 +-
.../userConsent}/hooks/useUserConsent.tsx | 2 +-
.../core/userConsent}/types/UserConsent.ts | 0
.../types/UserSemiPersistentSession.ts | 0
.../core/userSession}/useUserSession.tsx | 2 +-
.../core/userSession}/userSessionContext.tsx | 2 +-
.../core/vercelCache}/diskCacheStorage.ts | 9 +-
.../core/vercelCache}/hybridCache.test.ts | 4 +-
.../core/vercelCache}/hybridCache.ts | 8 +-
.../core/vercelCache}/memoryCacheStorage.ts | 2 +-
.../vercelCache/types}/hybridCacheStorage.ts | 0
src/{utils => modules/core/wdyr}/wdyr.tsx | 0
.../webVitals/types}/NextWebVitalsMetrics.ts | 0
.../types}/NextWebVitalsMetricsReport.ts | 0
src/pages/404.tsx | 30 +-
src/pages/README.md | 8 +-
.../built-in-features/analytics.tsx | 50 +--
.../built-in-features/animations.tsx | 43 ++-
.../built-in-features/cookies-consent.tsx | 51 +--
.../built-in-features/css-in-js.tsx | 41 +-
.../built-in-features/docs-site.tsx | 39 +-
.../built-in-features/graphql.tsx | 39 +-
.../built-in-features/hosting.tsx | 39 +-
.../built-in-features/icons.tsx | 39 +-
.../built-in-features/index.tsx | 5 +-
.../built-in-features/manual-deployments.tsx | 39 +-
.../built-in-features/monitoring.tsx | 39 +-
.../built-in-features/stages-and-secrets.tsx | 39 +-
.../built-in-features/static-i18n.tsx | 47 ++-
.../built-in-features/ui-components.tsx | 43 ++-
.../built-in-utilities/api.tsx | 39 +-
.../built-in-utilities/bundle-analysis.tsx | 39 +-
.../built-in-utilities/errors-handling.tsx | 53 ++-
.../built-in-utilities/hocs.tsx | 39 +-
.../built-in-utilities/hooks.tsx | 41 +-
.../built-in-utilities/i18nLink-component.tsx | 53 ++-
.../built-in-utilities/index.tsx | 5 +-
.../built-in-utilities/interactive-error.tsx | 33 +-
.../built-in-utilities/packages-upgrade.tsx | 41 +-
.../built-in-utilities/security-audit.tsx | 39 +-
.../built-in-utilities/svg-to-react.tsx | 55 ++-
.../top-level-500-error.tsx | 31 +-
.../tracking-useless-re-renders.tsx | 45 ++-
.../[locale]/{examples => demo}/index.tsx | 41 +-
.../[[...slug]].tsx | 41 +-
.../[albumId].tsx | 55 ++-
.../example-with-ssg-and-revalidate.tsx | 66 ++--
.../native-features/example-with-ssg.tsx | 63 ++--
.../native-features/example-with-ssr.tsx | 48 ++-
.../native-features/index.tsx | 5 +-
src/pages/[locale]/index.tsx | 9 +-
src/pages/[locale]/pageTemplateSSG.tsx | 28 +-
src/pages/[locale]/pageTemplateSSR.tsx | 28 +-
src/pages/[locale]/privacy.tsx | 40 +-
src/pages/[locale]/terms.tsx | 46 ++-
src/pages/_app.tsx | 24 +-
src/pages/_document.tsx | 3 +-
src/pages/api/autoRedirectToLocalisedPage.ts | 3 +-
src/pages/api/error.test.ts | 9 +-
src/pages/api/error.ts | 3 +-
src/pages/api/preview.ts | 5 +-
src/pages/api/startVercelDeployment.ts | 13 +-
src/pages/api/status.test.ts | 9 +-
src/pages/api/status.ts | 3 +-
src/pages/api/webhooks/deploymentCompleted.ts | 11 +-
src/propTypes/GraphCMSAssetPropTypes.ts | 16 -
.../GraphCMSAssetTransformationsPropTypes.ts | 6 -
src/propTypes/LogoPropTypes.ts | 31 --
src/propTypes/README.md | 16 -
src/stories/README.md | 8 +
.../nrn/animation/Animated3Dots.stories.tsx | 2 +-
.../animation/AnimatedTextBubble.stories.tsx | 2 +-
.../nrn/animation/BubbleTimer.stories.tsx | 2 +-
src/stories/nrn/animation/Loader.stories.tsx | 2 +-
.../nrn/asset/GraphCMSAsset.stories.tsx | 12 +-
src/stories/nrn/dataDisplay/Btn.stories.tsx | 2 +-
.../nrn/dataDisplay/CircleBtn.stories.tsx | 2 +-
src/stories/nrn/dataDisplay/Code.stories.tsx | 2 +-
.../dataDisplay/DocumentButton.stories.tsx | 2 +-
.../nrn/dataDisplay/ExternalLink.stories.tsx | 2 +-
.../nrn/dataDisplay/LinkButton.stories.tsx | 4 +-
.../nrn/dataDisplay/Markdown.stories.tsx | 2 +-
.../nrn/dataDisplay/SpoilerLink.stories.tsx | 4 +-
src/stories/nrn/dataDisplay/Stamp.stories.tsx | 4 +-
src/stories/nrn/dataDisplay/Text.stories.tsx | 2 +-
.../nrn/dataDisplay/ToggleButton.stories.tsx | 2 +-
.../ToggleLanguagesButton.stories.tsx | 2 +-
.../nrn/i18n/I18nBtnChangeLocale.stories.tsx | 2 +-
src/stories/nrn/i18n/I18nLink.stories.tsx | 2 +-
src/stories/nrn/layout/Cards.stories.tsx | 60 +--
.../nrn/layout/DefaultErrorLayout.stories.tsx | 2 +-
src/stories/nrn/layout/Footer.stories.tsx | 6 +-
.../nrn/layout/LegalContent.stories.tsx | 2 +-
src/stories/nrn/layout/Nav.stories.tsx | 2 +-
.../nrn/layout/PreviewModeBanner.stories.tsx | 2 +-
.../nrn/layout/QuickPreviewBanner.stories.tsx | 2 +-
.../nrn/overlay/SimpleTooltip.stories.tsx | 2 +-
src/stories/nrn/overlay/Tooltip.stories.tsx | 2 +-
.../DisplayOnBrowserMount.stories.tsx | 2 +-
src/stories/nrn/text/EllipsisText.stories.tsx | 2 +-
src/types/I18nMarkdown.ts | 7 -
src/types/I18nString.ts | 5 -
src/utils/graphCMSDataset/deserializeSafe.ts | 19 -
src/utils/graphCMSDataset/serializeSafe.ts | 23 --
src/utils/nextjs/SSG.ts | 196 ----------
svg-to-react/.gitignore | 1 +
{src/svg => svg-to-react}/AnimatedBubble.svg | 0
{src/svg => svg-to-react}/AnimatedLoader.svg | 0
.../AnimatedTextBubble.svg | 0
.../EnglishHybridFlag.svg | 0
{src/svg => svg-to-react}/EnglishUkFlag.svg | 0
{src/svg => svg-to-react}/FrenchFlag.svg | 0
.../utils/svg => svg-to-react}/svgTemplate.ts | 0
tsconfig.json | 24 ++
yarn.lock | 52 ++-
343 files changed, 3200 insertions(+), 1908 deletions(-)
create mode 100644 .storybook/jsconfig.json
create mode 100644 cypress/jsconfig.json
create mode 100644 src/README.md
create mode 100644 src/app/README.md
rename src/{components/appBootstrap => app/components}/BrowserPageBootstrap.tsx (78%)
rename src/{components/appBootstrap => app/components}/MultiversalAppBootstrap.tsx (90%)
rename src/{components/appBootstrap => app/components}/MultiversalGlobalExternalStyles.tsx (100%)
rename src/{components/appBootstrap => app/components}/MultiversalGlobalStyles.tsx (98%)
rename src/{components/appBootstrap => app/components}/ServerPageBootstrap.tsx (70%)
rename src/{ => app}/constants.ts (94%)
rename src/{utils/nextjs => app}/getComponentName.ts (66%)
rename src/{types/nextjs => app/types}/CommonServerSideParams.ts (100%)
rename src/{types/nextjs => app/types}/MultiversalAppBootstrapPageProps.ts (83%)
rename src/{types/nextjs => app/types}/MultiversalAppBootstrapProps.ts (93%)
rename src/{types/nextjs => app/types}/StaticPath.ts (100%)
rename src/{types/nextjs => app/types}/StaticPathsOutput.ts (100%)
rename src/{types/nextjs => app/types}/StaticPropsInput.ts (84%)
create mode 100644 src/common/README.md
rename src/{ => common}/components/ComponentTemplate.tsx (100%)
rename src/{components/svg => common/components/animations}/Animated3Dots.tsx (100%)
rename src/{components/svg => common/components/animations}/AnimatedLoader.tsx (100%)
rename src/{components/svg => common/components/animations}/AnimatedTextBubble.tsx (100%)
rename src/{ => common}/components/animations/Loader.tsx (88%)
rename src/{components/svg => common/components/countryFlags}/EnglishHybridFlag.tsx (100%)
rename src/{components/svg => common/components/countryFlags}/EnglishUkFlag.tsx (100%)
rename src/{components/svg => common/components/countryFlags}/FrenchFlag.tsx (90%)
rename src/{components/data => common/components/dataDisplay}/AllProducts.tsx (90%)
rename src/{components/utils => common/components/dataDisplay}/Btn.tsx (93%)
rename src/{components/utils => common/components/dataDisplay}/BubbleTimer.tsx (87%)
rename src/{components/utils => common/components/dataDisplay}/Cards.tsx (100%)
rename src/{components/utils => common/components/dataDisplay}/CircleBtn.tsx (95%)
rename src/{components/utils => common/components/dataDisplay}/Code.tsx (96%)
rename src/{components/utils => common/components/dataDisplay}/DocumentButton.tsx (100%)
rename src/{components/utils => common/components/dataDisplay}/EllipsisText.tsx (100%)
rename src/{components/utils => common/components/dataDisplay}/ExternalLink.tsx (96%)
rename src/{components/utils => common/components/dataDisplay}/LegalContent.tsx (96%)
rename src/{components/utils => common/components/dataDisplay}/LinkButton.tsx (100%)
rename src/{components/assets => common/components/dataDisplay}/Logo.tsx (72%)
rename src/{components/utils => common/components/dataDisplay}/Markdown.tsx (90%)
rename src/{components/data => common/components/dataDisplay}/ProductRow.tsx (81%)
rename src/{components/data => common/components/dataDisplay}/Products.tsx (93%)
rename src/{components/utils => common/components/dataDisplay}/SimpleTooltip.tsx (100%)
rename src/{components/utils => common/components/dataDisplay}/SpoilerLink.tsx (100%)
rename src/{components/utils => common/components/dataDisplay}/Stamp.tsx (100%)
rename src/{components/utils => common/components/dataDisplay}/Text.tsx (100%)
rename src/{components/utils => common/components/dataDisplay}/ToggleButton.tsx (100%)
rename src/{components/utils => common/components/dataDisplay}/Tooltip.tsx (100%)
rename src/{ => common}/components/rehydration/DisplayOnBrowserMount.tsx (100%)
rename src/{ => common}/hocs/withHOCTemplate.tsx (100%)
rename src/{ => common}/hooks/useHasMounted.tsx (100%)
rename src/{utils/node => common/utils}/fs-utils.ts (100%)
rename src/{ => common}/utils/iframe.ts (100%)
rename src/{utils/app => common/utils}/ignoreNoisyWarningsHacks.ts (100%)
rename src/{utils/assets => common/utils}/logo.test.ts (100%)
rename src/{utils/assets => common/utils}/logo.ts (96%)
rename src/{ => common}/utils/mobile.ts (100%)
rename src/{utils/app => common/utils}/redirect.ts (100%)
rename src/{utils/timers => common/utils}/waitFor.ts (100%)
rename src/gql/pages/{examples => demo}/native-features/example-with-ssg.ts (81%)
rename src/gql/pages/{examples => demo}/native-features/example-with-ssr.ts (100%)
create mode 100644 src/layouts/README.md
create mode 100644 src/layouts/core/SSG.ts
create mode 100644 src/layouts/core/SSR.ts
rename src/{components/pageLayouts => layouts/core/components}/Footer.tsx (86%)
rename src/{components/pageLayouts => layouts/core/components}/Head.tsx (90%)
create mode 100644 src/layouts/core/components/Layout.tsx
rename src/{components/pageLayouts => layouts/core/components}/Nav.tsx (93%)
create mode 100644 src/layouts/core/components/PageContainer.tsx
rename src/{types/pageProps => layouts/core/types}/MultiversalPageProps.ts (93%)
rename src/{types/pageProps => layouts/core/types}/OnlyBrowserPageProps.ts (58%)
rename src/{types/pageProps => layouts/core/types}/OnlyServerPageProps.ts (72%)
rename src/{types/pageProps => layouts/core/types}/PublicHeaders.ts (100%)
rename src/{types/pageProps => layouts/core/types}/SSGPageProps.ts (85%)
rename src/{types/pageProps => layouts/core/types}/SSRPageProps.ts (90%)
rename src/{types/pageProps => layouts/core/types}/SoftPageProps.ts (100%)
create mode 100644 src/layouts/default/components/DefaultFooter.tsx
create mode 100644 src/layouts/default/components/DefaultHead.tsx
create mode 100644 src/layouts/default/components/DefaultLayout.tsx
create mode 100644 src/layouts/default/components/DefaultNav.tsx
create mode 100644 src/layouts/default/components/DefaultPageContainer.tsx
create mode 100644 src/layouts/default/defaultSSG.ts
create mode 100644 src/layouts/default/defaultSSR.ts
rename src/{components/doc => layouts/demo/components}/BuiltInFeaturesSection.tsx (78%)
rename src/{components/doc => layouts/demo/components}/BuiltInFeaturesSidebar.tsx (63%)
rename src/{components/doc => layouts/demo/components}/BuiltInUtilitiesSection.tsx (71%)
rename src/{components/doc => layouts/demo/components}/BuiltInUtilitiesSidebar.tsx (67%)
create mode 100644 src/layouts/demo/components/DemoFooter.tsx
create mode 100644 src/layouts/demo/components/DemoHead.tsx
rename src/{components/pageLayouts/DefaultLayout.tsx => layouts/demo/components/DemoLayout.tsx} (77%)
create mode 100644 src/layouts/demo/components/DemoNav.tsx
rename src/{components/doc/DocPage.tsx => layouts/demo/components/DemoPage.tsx} (70%)
rename src/{components/pageLayouts/DefaultPageContainer.tsx => layouts/demo/components/DemoPageContainer.tsx} (85%)
rename src/{components/doc/DocSection.tsx => layouts/demo/components/DemoSection.tsx} (59%)
rename src/{components/doc => layouts/demo/components}/ExternalFeaturesSection.tsx (87%)
rename src/{components/doc => layouts/demo/components}/IntroductionSection.tsx (88%)
rename src/{components/doc => layouts/demo/components}/NativeFeaturesSection.tsx (90%)
rename src/{components/doc => layouts/demo/components}/NativeFeaturesSidebar.tsx (69%)
rename src/{components/doc => layouts/demo/components}/SidebarFooter.tsx (91%)
rename src/{components/doc => layouts/demo/components}/SidebarToggle.tsx (89%)
create mode 100644 src/layouts/demo/demoSSG.ts
rename src/{utils/nextjs/SSR.ts => layouts/demo/demoSSR.ts} (66%)
create mode 100644 src/modules/README.md
rename src/{utils/analytics => modules/core/amplitude}/amplitude.ts (96%)
rename src/{stores => modules/core/amplitude/context}/amplitudeContext.tsx (100%)
rename src/{ => modules/core/amplitude}/hooks/useAmplitude.tsx (88%)
rename src/{ => modules/core/amplitude}/types/Amplitude.ts (100%)
rename src/{utils => modules/core}/api/convertRequestBodyToJSObject.ts (92%)
rename src/{utils => modules/core}/api/fetchJSON.test.ts (100%)
rename src/{utils => modules/core}/api/fetchJSON.ts (100%)
rename src/{utils/cookies => modules/core/cookiesManager}/UniversalCookiesManager.browser.test.ts (97%)
rename src/{utils/cookies => modules/core/cookiesManager}/UniversalCookiesManager.server.test.ts (99%)
rename src/{utils/cookies => modules/core/cookiesManager}/UniversalCookiesManager.ts (98%)
rename src/{utils/cookies => modules/core/cookiesManager}/cookies.ts (100%)
rename src/{ => modules/core/cookiesManager}/types/Cookies.ts (100%)
rename src/{utils => modules/core/css}/css.test.ts (100%)
rename src/{utils => modules/core/css}/css.ts (97%)
rename src/{ => modules/core/css}/types/CSSStyles.ts (58%)
rename src/{stores => modules/core/data/contexts}/customerContext.tsx (91%)
rename src/{stores => modules/core/data/contexts}/datasetContext.tsx (88%)
rename src/{ => modules/core/data}/hooks/useCustomer.tsx (92%)
rename src/{ => modules/core/data}/hooks/useDataset.tsx (94%)
rename src/{utils => modules/core}/data/record.test.ts (100%)
rename src/{utils => modules/core}/data/record.ts (98%)
rename src/{types/data => modules/core/data/types}/Asset.ts (100%)
rename src/{types/data => modules/core/data/types}/AssetThumbnail.ts (100%)
rename src/{types/data => modules/core/data/types}/AssetTransformations.ts (100%)
rename src/{types/data => modules/core/data/types}/Customer.ts (89%)
rename src/{types/data => modules/core/data/types}/CustomerTheme.ts (100%)
rename src/{ => modules/core/data}/types/GenericObject.ts (100%)
rename src/{utils/graphCMSDataset => modules/core/data/types}/GraphCMSDataset.ts (58%)
rename src/{types/data => modules/core/data/types}/GraphCMSSystemFields.ts (100%)
create mode 100644 src/modules/core/data/types/I18nMarkdown.ts
rename src/{ => modules/core/data}/types/I18nRichText.ts (100%)
create mode 100644 src/modules/core/data/types/I18nString.ts
rename src/{types/data => modules/core/data/types}/Link.ts (69%)
rename src/{types/data => modules/core/data/types}/Logo.ts (100%)
rename src/{ => modules/core/data}/types/Markdown.ts (100%)
rename src/{types/data => modules/core/data/types}/Product.ts (100%)
rename src/{ => modules/core/data}/types/RichText.ts (100%)
rename src/{ => modules/core/data}/types/SerializedRecord.ts (100%)
rename src/{ => modules/core/data}/types/SidebarLink.ts (100%)
rename src/{types/data => modules/core/data/types}/Theme.ts (100%)
rename src/{types/data => modules/core/data/types}/VisibilityStatus.ts (100%)
rename src/{utils/js => modules/core/date}/date.ts (97%)
rename src/{utils/time => modules/core/date}/getTimestampsElapsedTime.ts (100%)
rename src/{utils/time => modules/core/date}/timeDifference.ts (100%)
rename src/{ => modules/core/date}/types/DateDay.ts (100%)
rename src/{components/errors => modules/core/errorHandling}/DefaultErrorLayout.tsx (96%)
rename src/{components/errors => modules/core/errorHandling}/ErrorDebug.tsx (96%)
rename src/{utils/icons/font-awesome.ts => modules/core/fontAwesome/fontAwesome.ts} (100%)
rename src/{utils/gitHubActions => modules/core/githubActions}/dispatchWorkflow.ts (95%)
rename src/{utils/gitHubActions => modules/core/githubActions}/dispatchWorkflowByPath.ts (88%)
rename src/{types/githubActions => modules/core/githubActions/types}/GHAWorkflow.ts (100%)
rename src/{types/githubActions => modules/core/githubActions/types}/WorkflowsAPIResponse.ts (100%)
rename src/{components/assets => modules/core/gql/components}/GraphCMSAsset.test.tsx (100%)
rename src/{components/assets => modules/core/gql/components}/GraphCMSAsset.tsx (80%)
rename src/{components/assets => modules/core/gql/components}/__snapshots__/GraphCMSAsset.test.tsx.snap (100%)
rename src/{utils => modules/core}/gql/graphcms.test.ts (100%)
rename src/{utils => modules/core}/gql/graphcms.ts (100%)
rename src/{utils => modules/core}/gql/graphql.ts (100%)
rename src/{ => modules/core/gql}/hocs/withApollo.tsx (94%)
rename src/{types/gql => modules/core/gql/types}/ApolloQueryOptions.ts (100%)
rename src/{components/i18n => modules/core/i18n/components}/I18nBtnChangeLocale.tsx (88%)
rename src/{components/i18n => modules/core/i18n/components}/I18nLink.test.tsx (98%)
rename src/{components/i18n => modules/core/i18n/components}/I18nLink.tsx (98%)
rename src/{components/utils => modules/core/i18n/components}/ToggleLanguagesButton.tsx (99%)
rename src/{components/i18n => modules/core/i18n/components}/__snapshots__/I18nLink.test.tsx.snap (100%)
rename src/{stores => modules/core/i18n/contexts}/i18nContext.tsx (100%)
rename src/{ => modules/core/i18n}/hooks/useI18n.tsx (89%)
rename src/{utils => modules/core}/i18n/i18n.ts (97%)
rename src/{ => modules/core/i18n}/i18nConfig.js (100%)
rename src/{utils/app/router.ts => modules/core/i18n/i18nRouter.ts} (100%)
rename src/{utils => modules/core}/i18n/i18nextLocize.ts (99%)
rename src/{ => modules/core/i18n}/middlewares/localeMiddleware.ts (95%)
rename src/{types/i18n => modules/core/i18n/types}/I18nLocale.ts (100%)
rename src/{utils => modules/core}/js/array.test.ts (100%)
rename src/{utils => modules/core}/js/array.ts (100%)
rename src/{utils/math => modules/core/js}/random.ts (100%)
rename src/{utils => modules/core}/js/string.test.ts (100%)
rename src/{utils => modules/core}/js/string.ts (80%)
rename src/{ => modules/core/js}/types/Float.ts (100%)
rename src/{ => modules/core/js}/types/Integer.ts (100%)
rename src/{utils => modules/core}/js/url.test.ts (98%)
rename src/{utils => modules/core}/js/url.ts (98%)
rename src/{utils/quality => modules/core/lightHouse}/lighthouse.ts (100%)
rename src/{components/pageLayouts => modules/core/previewMode/components}/PreviewModeBanner.tsx (94%)
rename src/{stores => modules/core/previewMode/contexts}/previewModeContext.tsx (91%)
rename src/{ => modules/core/previewMode}/hooks/usePreviewMode.tsx (87%)
rename src/{utils/nextjs => modules/core/previewMode}/previewMode.ts (100%)
rename src/{types/nextjs => modules/core/previewMode/types}/PreviewData.ts (100%)
rename src/{components/pageLayouts => modules/core/quickPreview/components}/QuickPreviewBanner.tsx (91%)
rename src/{stores => modules/core/quickPreview/contexts}/quickPreviewContext.tsx (100%)
rename src/{ => modules/core/quickPreview}/hooks/useQuickPreview.tsx (87%)
rename src/{utils => modules/core}/quickPreview/quickPreview.ts (100%)
rename src/{types/react => modules/core/react/types}/ReactButtonProps.ts (100%)
rename src/{types/react => modules/core/react/types}/ReactDivProps.ts (100%)
rename src/{types/react => modules/core/react/types}/ReactLinkProps.ts (100%)
rename src/{utils => modules/core/reactSelect}/reactSelect.ts (96%)
rename src/{ => modules/core/reactSelect}/types/ReactSelect.ts (100%)
rename src/{utils/monitoring => modules/core/sentry}/sentry.ts (97%)
create mode 100644 src/modules/core/serializeSafe/deserializeSafe.ts
create mode 100644 src/modules/core/serializeSafe/serializeSafe.ts
rename src/{ => modules/core/serializeSafe}/types/Flatted.ts (100%)
rename src/{stores => modules/core/testing/contexts}/cypressContext.tsx (100%)
rename src/{utils => modules/core}/testing/cypress.ts (100%)
rename src/{ => modules/core/testing}/hooks/useCypress.tsx (70%)
rename src/{ => modules/core/testing}/mocks/songs.ts (100%)
rename src/{utils/testing => modules/core/testing/mocks}/tests-mocks.ts (100%)
rename src/{utils/env => modules/core/testing/tests}/env.test.ts (100%)
rename src/{utils/extend-jest/toContainObject.js => modules/core/testing/toContainObject.ts} (97%)
rename src/{utils => modules/core/theming}/colors.ts (100%)
rename src/{utils/data => modules/core/theming}/theme.ts (82%)
rename src/{utils => modules/core}/theming/themedComponentColors.ts (98%)
rename src/{types/emotion-theme.ts => modules/core/theming/types/EmotionTheme.ts} (59%)
rename src/{stores => modules/core/userConsent/contexts}/userConsentContext.tsx (100%)
rename src/{utils/cookies => modules/core/userConsent}/cookieConsent.ts (97%)
rename src/{ => modules/core/userConsent}/hooks/useUserConsent.tsx (90%)
rename src/{ => modules/core/userConsent}/types/UserConsent.ts (100%)
rename src/{ => modules/core/userSession}/types/UserSemiPersistentSession.ts (100%)
rename src/{hooks => modules/core/userSession}/useUserSession.tsx (88%)
rename src/{stores => modules/core/userSession}/userSessionContext.tsx (94%)
rename src/{utils/caching => modules/core/vercelCache}/diskCacheStorage.ts (95%)
rename src/{utils/caching => modules/core/vercelCache}/hybridCache.test.ts (98%)
rename src/{utils/caching => modules/core/vercelCache}/hybridCache.ts (96%)
rename src/{utils/caching => modules/core/vercelCache}/memoryCacheStorage.ts (96%)
rename src/{utils/caching => modules/core/vercelCache/types}/hybridCacheStorage.ts (100%)
rename src/{utils => modules/core/wdyr}/wdyr.tsx (100%)
rename src/{types/nextjs => modules/core/webVitals/types}/NextWebVitalsMetrics.ts (100%)
rename src/{types/nextjs => modules/core/webVitals/types}/NextWebVitalsMetricsReport.ts (100%)
rename src/pages/[locale]/{examples => demo}/built-in-features/analytics.tsx (91%)
rename src/pages/[locale]/{examples => demo}/built-in-features/animations.tsx (75%)
rename src/pages/[locale]/{examples => demo}/built-in-features/cookies-consent.tsx (81%)
rename src/pages/[locale]/{examples => demo}/built-in-features/css-in-js.tsx (82%)
rename src/pages/[locale]/{examples => demo}/built-in-features/docs-site.tsx (76%)
rename src/pages/[locale]/{examples => demo}/built-in-features/graphql.tsx (85%)
rename src/pages/[locale]/{examples => demo}/built-in-features/hosting.tsx (78%)
rename src/pages/[locale]/{examples => demo}/built-in-features/icons.tsx (81%)
rename src/pages/[locale]/{examples => demo}/built-in-features/index.tsx (73%)
rename src/pages/[locale]/{examples => demo}/built-in-features/manual-deployments.tsx (83%)
rename src/pages/[locale]/{examples => demo}/built-in-features/monitoring.tsx (77%)
rename src/pages/[locale]/{examples => demo}/built-in-features/stages-and-secrets.tsx (83%)
rename src/pages/[locale]/{examples => demo}/built-in-features/static-i18n.tsx (90%)
rename src/pages/[locale]/{examples => demo}/built-in-features/ui-components.tsx (81%)
rename src/pages/[locale]/{examples => demo}/built-in-utilities/api.tsx (78%)
rename src/pages/[locale]/{examples => demo}/built-in-utilities/bundle-analysis.tsx (71%)
rename src/pages/[locale]/{examples => demo}/built-in-utilities/errors-handling.tsx (76%)
rename src/pages/[locale]/{examples => demo}/built-in-utilities/hocs.tsx (79%)
rename src/pages/[locale]/{examples => demo}/built-in-utilities/hooks.tsx (85%)
rename src/pages/[locale]/{examples => demo}/built-in-utilities/i18nLink-component.tsx (68%)
rename src/pages/[locale]/{examples => demo}/built-in-utilities/index.tsx (75%)
rename src/pages/[locale]/{examples => demo}/built-in-utilities/interactive-error.tsx (78%)
rename src/pages/[locale]/{examples => demo}/built-in-utilities/packages-upgrade.tsx (89%)
rename src/pages/[locale]/{examples => demo}/built-in-utilities/security-audit.tsx (87%)
rename src/pages/[locale]/{examples => demo}/built-in-utilities/svg-to-react.tsx (72%)
rename src/pages/[locale]/{examples => demo}/built-in-utilities/top-level-500-error.tsx (72%)
rename src/pages/[locale]/{examples => demo}/built-in-utilities/tracking-useless-re-renders.tsx (80%)
rename src/pages/[locale]/{examples => demo}/index.tsx (67%)
rename src/pages/[locale]/{examples => demo}/native-features/example-optional-catch-all-routes/[[...slug]].tsx (73%)
rename src/pages/[locale]/{examples => demo}/native-features/example-with-ssg-and-fallback/[albumId].tsx (81%)
rename src/pages/[locale]/{examples => demo}/native-features/example-with-ssg-and-revalidate.tsx (79%)
rename src/pages/[locale]/{examples => demo}/native-features/example-with-ssg.tsx (77%)
rename src/pages/[locale]/{examples => demo}/native-features/example-with-ssr.tsx (85%)
rename src/pages/[locale]/{examples => demo}/native-features/index.tsx (74%)
delete mode 100644 src/propTypes/GraphCMSAssetPropTypes.ts
delete mode 100644 src/propTypes/GraphCMSAssetTransformationsPropTypes.ts
delete mode 100644 src/propTypes/LogoPropTypes.ts
delete mode 100644 src/propTypes/README.md
create mode 100644 src/stories/README.md
delete mode 100644 src/types/I18nMarkdown.ts
delete mode 100644 src/types/I18nString.ts
delete mode 100644 src/utils/graphCMSDataset/deserializeSafe.ts
delete mode 100644 src/utils/graphCMSDataset/serializeSafe.ts
delete mode 100644 src/utils/nextjs/SSG.ts
create mode 100644 svg-to-react/.gitignore
rename {src/svg => svg-to-react}/AnimatedBubble.svg (100%)
rename {src/svg => svg-to-react}/AnimatedLoader.svg (100%)
rename {src/svg => svg-to-react}/AnimatedTextBubble.svg (100%)
rename {src/svg => svg-to-react}/EnglishHybridFlag.svg (100%)
rename {src/svg => svg-to-react}/EnglishUkFlag.svg (100%)
rename {src/svg => svg-to-react}/FrenchFlag.svg (100%)
rename {src/utils/svg => svg-to-react}/svgTemplate.ts (100%)
diff --git a/.codeclimate.yml b/.codeclimate.yml
index 5e1451c88..a24798cb2 100644
--- a/.codeclimate.yml
+++ b/.codeclimate.yml
@@ -16,7 +16,7 @@ checks:
method-complexity:
enabled: true
config:
- threshold: 10
+ threshold: 25 # 10 by default
method-count:
enabled: true
config:
@@ -24,7 +24,7 @@ checks:
method-lines:
enabled: true
config:
- threshold: 200 # 25 by default
+ threshold: 300 # 25 by default
nested-control-flow:
enabled: true
config:
diff --git a/.storybook/jsconfig.json b/.storybook/jsconfig.json
new file mode 100644
index 000000000..84c874b98
--- /dev/null
+++ b/.storybook/jsconfig.json
@@ -0,0 +1,28 @@
+{
+ "compilerOptions": {
+ "baseUrl": ".",
+ "paths": {
+ "@/app/*": [
+ "../src/app/*"
+ ],
+ "@/common/*": [
+ "../src/common/*"
+ ],
+ "@/components/*": [
+ "../src/common/components/*"
+ ],
+ "@/utils/*": [
+ "../src/common/utils/*"
+ ],
+ "@/layouts/*": [
+ "../src/layouts/*"
+ ],
+ "@/modules/*": [
+ "../src/modules/*"
+ ],
+ "@/pages/*": [
+ "../src/pages/*"
+ ]
+ }
+ }
+}
diff --git a/.storybook/main.js b/.storybook/main.js
index 523614f0c..c6d9efe68 100644
--- a/.storybook/main.js
+++ b/.storybook/main.js
@@ -230,6 +230,24 @@ module.exports = {
'@emotion/core': toPath('node_modules/@emotion/react'),
'@emotion/styled': toPath('node_modules/@emotion/styled'),
'emotion-theming': toPath('node_modules/@emotion/react'),
+
+ /**
+ * Map our module path aliases, so that Storybook can understand modules loaded using "@/common" and load the proper file.
+ * Required, or Storybook will fail to import dependencies from Stories.
+ *
+ * XXX The below list must match `tsconfig.json:compilerOptions.paths`, so the Next.js app and Storybook resolve all aliases the same way.
+ * The paths mapping must also match the `jsconfig.json:compilerOptions.paths` file, which is necessary for WebStorm to understand them for .js files.
+ *
+ * @see https://nextjs.org/docs/advanced-features/module-path-aliases
+ * @see https://intellij-support.jetbrains.com/hc/en-us/community/posts/360003361399/comments/360002636080
+ */
+ "@/app": path.resolve(__dirname, "../src/app"),
+ "@/common": path.resolve(__dirname, "../src/common"),
+ "@/components": path.resolve(__dirname, "../src/common/components"),
+ "@/utils": path.resolve(__dirname, "../src/common/utils"),
+ "@/layouts": path.resolve(__dirname, "../src/layouts"),
+ "@/modules": path.resolve(__dirname, "../src/modules"),
+ "@/pages": path.resolve(__dirname, "../src/pages"),
},
},
};
diff --git a/.storybook/preview.js b/.storybook/preview.js
index 4c84e0392..7ac86f816 100644
--- a/.storybook/preview.js
+++ b/.storybook/preview.js
@@ -8,23 +8,23 @@ import find from 'lodash.find';
import React from 'react';
import { withNextRouter } from 'storybook-addon-next-router';
import { withPerformance } from 'storybook-addon-performance';
-import '../src/components/appBootstrap/MultiversalGlobalExternalStyles'; // Import the same 3rd party libraries global styles as the pages/_app.tsx (for UI consistency)
-import MultiversalGlobalStyles from '../src/components/appBootstrap/MultiversalGlobalStyles';
-import { defaultLocale, getLangFromLocale, supportedLocales } from '../src/i18nConfig';
-import amplitudeContext from '../src/stores/amplitudeContext';
-import customerContext from '../src/stores/customerContext';
-import { cypressContext } from '../src/stores/cypressContext';
-import datasetContext from '../src/stores/datasetContext';
-import i18nContext from '../src/stores/i18nContext';
-import previewModeContext from '../src/stores/previewModeContext';
-import quickPreviewContext from '../src/stores/quickPreviewContext';
-import userConsentContext from '../src/stores/userConsentContext';
-import { userSessionContext } from '../src/stores/userSessionContext';
-import { getAmplitudeInstance } from '../src/utils/analytics/amplitude';
-import '../src/utils/app/ignoreNoisyWarningsHacks';
-import { initCustomerTheme } from '../src/utils/data/theme';
-import i18nextLocize from '../src/utils/i18n/i18nextLocize';
-import '../src/utils/icons/font-awesome';
+import '@/app/components/MultiversalGlobalExternalStyles'; // Import the same 3rd party libraries global styles as the pages/_app.tsx (for UI consistency)
+import MultiversalGlobalStyles from '@/app/components/MultiversalGlobalStyles';
+import { defaultLocale, getLangFromLocale, supportedLocales } from '@/modules/core/i18n/i18nConfig';
+import amplitudeContext from '@/modules/core/amplitude/context/amplitudeContext';
+import customerContext from '@/modules/core/data/contexts/customerContext';
+import { cypressContext } from '@/modules/core/testing/contexts/cypressContext';
+import datasetContext from '@/modules/core/data/contexts/datasetContext';
+import i18nContext from '@/modules/core/i18n/contexts/i18nContext';
+import previewModeContext from '@/modules/core/previewMode/contexts/previewModeContext';
+import quickPreviewContext from '@/modules/core/quickPreview/contexts/quickPreviewContext';
+import userConsentContext from '@/modules/core/userConsent/contexts/userConsentContext';
+import { userSessionContext } from '@/modules/core/userSession/userSessionContext';
+import { getAmplitudeInstance } from '@/modules/core/amplitude/amplitude';
+import '@/common/utils/ignoreNoisyWarningsHacks';
+import { initCustomerTheme } from '@/modules/core/theming/theme';
+import i18nextLocize from '@/modules/core/i18n/i18nextLocize';
+import '@/modules/core/fontAwesome/fontAwesome';
import dataset from './mock/sb-dataset';
// Loads translations from local file cache (Locize)
diff --git a/cypress/README.md b/cypress/README.md
index 8b402e33b..693d8bf0c 100644
--- a/cypress/README.md
+++ b/cypress/README.md
@@ -51,3 +51,19 @@ The files `cypress/config-*` are used for different purposes.
_[Source](https://docs.cypress.io/faq/questions/using-cypress-faq.html#What-are-your-best-practices-for-organizing-tests)_
[Cypress releases "Real World App" (RWA) - Blog post](https://www.cypress.io/blog/2020/06/11/introducing-the-cypress-real-world-app/)
+
+## Module path alias mapping
+
+We use module alias path mappings, to avoid using relative paths (e.g: `../../src/common`) but absolute paths (AKA "module paths") instead (e.g: `@/common`).
+
+Although it's simpler to use, it's harder to configure because it affects several configuration files:
+- The paths mapping in `tsconfig.json:compilerOptions.paths` must match those in `../tsconfig.json:compilerOptions.paths`
+- They must also match those in `jsconfig.json` file, which is necessary for WebStorm to understand them for .js files.
+
+If the module path mappings aren't properly set everywhere, it won't work.
+
+> You can still use relative paths.
+
+Reference:
+- See [Next.js "Module path aliases" documentation](https://nextjs.org/docs/advanced-features/module-path-aliases)
+- See [WebStorm issue](https://intellij-support.jetbrains.com/hc/en-us/community/posts/360003361399/comments/360002636080)
diff --git a/cypress/integration/app/_sanity/2-customer.ts b/cypress/integration/app/_sanity/2-customer.ts
index 3f13f9ab2..5cfb7022f 100644
--- a/cypress/integration/app/_sanity/2-customer.ts
+++ b/cypress/integration/app/_sanity/2-customer.ts
@@ -1,5 +1,5 @@
-import { Customer } from '../../../../src/types/data/Customer';
-import { CYPRESS_WINDOW_NS } from '../../../../src/utils/testing/cypress';
+import { Customer } from '@/modules/core/data/types/Customer';
+import { CYPRESS_WINDOW_NS } from '@/modules/core/testing/cypress';
describe('Sanity checks > Browser data', () => {
/**
diff --git a/cypress/integration/app/common/footer.ts b/cypress/integration/app/common/footer.ts
index 3e55dcb52..2d04ff9b4 100644
--- a/cypress/integration/app/common/footer.ts
+++ b/cypress/integration/app/common/footer.ts
@@ -1,4 +1,4 @@
-import { Customer } from '../../../../src/types/data/Customer';
+import { Customer } from '@/modules/core/data/types/Customer';
const baseUrl = Cypress.config().baseUrl;
diff --git a/cypress/integration/app/common/nav.ts b/cypress/integration/app/common/nav.ts
index 878d2e965..abe668b61 100644
--- a/cypress/integration/app/common/nav.ts
+++ b/cypress/integration/app/common/nav.ts
@@ -1,4 +1,4 @@
-import { Customer } from '../../../../src/types/data/Customer';
+import { Customer } from '@/modules/core/data/types/Customer';
const baseUrl = Cypress.config().baseUrl;
diff --git a/cypress/jsconfig.json b/cypress/jsconfig.json
new file mode 100644
index 000000000..84c874b98
--- /dev/null
+++ b/cypress/jsconfig.json
@@ -0,0 +1,28 @@
+{
+ "compilerOptions": {
+ "baseUrl": ".",
+ "paths": {
+ "@/app/*": [
+ "../src/app/*"
+ ],
+ "@/common/*": [
+ "../src/common/*"
+ ],
+ "@/components/*": [
+ "../src/common/components/*"
+ ],
+ "@/utils/*": [
+ "../src/common/utils/*"
+ ],
+ "@/layouts/*": [
+ "../src/layouts/*"
+ ],
+ "@/modules/*": [
+ "../src/modules/*"
+ ],
+ "@/pages/*": [
+ "../src/pages/*"
+ ]
+ }
+ }
+}
diff --git a/cypress/support/commands.js b/cypress/support/commands.js
index 08637a81a..ba42fe337 100644
--- a/cypress/support/commands.js
+++ b/cypress/support/commands.js
@@ -8,7 +8,7 @@
// https://on.cypress.io/custom-commands
// ***********************************************
-import { CYPRESS_WINDOW_NS } from '../../src/utils/testing/cypress';
+import { CYPRESS_WINDOW_NS } from '@/modules/core/testing/cypress';
/**
* Prepare DOM aliases by fetching the customer data from the browser window and aliasing them for later use.
diff --git a/cypress/tsconfig.json b/cypress/tsconfig.json
index b0ba89e10..509f3f67a 100644
--- a/cypress/tsconfig.json
+++ b/cypress/tsconfig.json
@@ -6,6 +6,29 @@
"exclude": [],
"compilerOptions": {
"baseUrl": ".",
+ "paths": {
+ "@/app/*": [
+ "../src/app/*"
+ ],
+ "@/common/*": [
+ "../src/common/*"
+ ],
+ "@/components/*": [
+ "../src/common/components/*"
+ ],
+ "@/utils/*": [
+ "../src/common/utils/*"
+ ],
+ "@/layouts/*": [
+ "../src/layouts/*"
+ ],
+ "@/modules/*": [
+ "../src/modules/*"
+ ],
+ "@/pages/*": [
+ "../src/pages/*"
+ ]
+ },
"types": [
"cypress"
],
diff --git a/jest.config.js b/jest.config.js
index 9e5720676..d7901f880 100644
--- a/jest.config.js
+++ b/jest.config.js
@@ -11,6 +11,25 @@ module.exports = {
tsconfig: 'tsconfig.jest.json',
},
},
+
+ /**
+ * Map our module path aliases, so that Jest can understand modules loaded using "@/common" and load the proper file.
+ * Required, or Jest will fail to import dependencies from tests.
+ *
+ * XXX The below list must match `tsconfig.json:compilerOptions.paths`, so the Next.js app and Jest resolve all aliases the same way.
+ *
+ * @see https://nextjs.org/docs/advanced-features/module-path-aliases
+ * @see https://github.com/ilearnio/module-alias/issues/46#issuecomment-546154015
+ */
+ moduleNameMapper: {
+ '^@/app/(.*)$': '/src/app/$1',
+ '^@/common/(.*)$': '/src/common/$1',
+ '^@/components/(.*)$': '/src/common/components/$1',
+ '^@/utils/(.*)$': '/src/common/utils/$1',
+ '^@/layouts/(.*)$': '/src/layouts/$1',
+ '^@/modules/(.*)$': '/src/modules/$1',
+ '^@/pages/(.*)$': '/src/pages/$1',
+ },
modulePathIgnorePatterns: [
'.next/',
'cypress',
diff --git a/jest.extends.ts b/jest.extends.ts
index c3536931c..96c6f1afe 100644
--- a/jest.extends.ts
+++ b/jest.extends.ts
@@ -1,4 +1,10 @@
-import { toMatchOneOf, toMatchShapeOf } from 'jest-to-match-shape-of'; // See https://www.npmjs.com/package/jest-to-match-shape-of
+// XXX All expect.extend() utilities loaded here will be available for all tests, they also might need to be declared in jest.d.ts
+import {
+ toMatchOneOf,
+ toMatchShapeOf,
+} from 'jest-to-match-shape-of'; // See https://www.npmjs.com/package/jest-to-match-shape-of
+// Import utilities that extend Jest "expect" function by themselves
+import '@/modules/core/testing/toContainObject';
// Extend Jest "expect" function
expect.extend({
diff --git a/next.config.js b/next.config.js
index 9f35c82ab..3352584c9 100644
--- a/next.config.js
+++ b/next.config.js
@@ -1,7 +1,7 @@
const bundleAnalyzer = require('@next/bundle-analyzer');
const nextSourceMaps = require('@zeit/next-source-maps');
const packageJson = require('./package');
-const i18nConfig = require('./src/i18nConfig');
+const i18nConfig = require('./src/modules/core/i18n/i18nConfig');
const withSourceMaps = nextSourceMaps();
const withBundleAnalyzer = bundleAnalyzer({ // Run with "yarn analyse:bundle" - See https://www.npmjs.com/package/@next/bundle-analyzer
@@ -102,22 +102,6 @@ module.exports = withBundleAnalyzer(withSourceMaps({
async headers() {
const headers = [];
- // XXX Forbid usage in iframes from external 3rd parties, for non-production site
- // This is meant to avoid customers using the preview in their production website, which would incur uncontrolled costs on our end
- // Also, our preview env cannot scale considering each request send many airtable API calls and those are rate limited and out of our control
- if (process.env.NEXT_PUBLIC_APP_STAGE !== 'production') {
- headers.push({
- source: '/(.*?)', // Match all paths, including "/" - See https://github.com/vercel/next.js/discussions/17991#discussioncomment-112028
- // source: '/:path*', // Match all paths, excluding "/"
- headers: [
- {
- key: 'Content-Security-Policy',
- value: 'frame-ancestors *.stacker.app',
- },
- ],
- });
- }
-
console.info('Using headers:', JSON.stringify(headers, null, 2));
return headers;
diff --git a/package.json b/package.json
index 7bb7a50fd..a90272907 100644
--- a/package.json
+++ b/package.json
@@ -10,7 +10,7 @@
"analyse:bundle:development": "ANALYZE_BUNDLE=true yarn start",
"analyse:bundle:production": ". ./scripts/populate-git-env.sh && ANALYZE_BUNDLE=true next build",
"analyse:unused": "next-unused",
- "svg": "npx svgr -d src/svg src/svg --ext tsx --template src/utils/svg/svgTemplate.ts",
+ "svg": "npx svgr -d svg-to-react svg-to-react --ext tsx --template svg-to-react/svgTemplate.ts",
"deploy": "yarn deploy:customer1",
"deploy:all": "yarn deploy:customer1 && yarn deploy:customer2",
"deploy:all:production": "yarn deploy:customer1:production && yarn deploy:customer2:production",
@@ -81,6 +81,10 @@
"codemod:update-react-imports": "npx react-codemod update-react-imports src/",
"codemod:name-default-component": "npx @next/codemod name-default-component src/",
"codemod:withamp-to-config": "npx @next/codemod withamp-to-config src/",
+ "codemod:module-path-aliases": "yarn codemod:module-path-aliases:src && yarn codemod:module-path-aliases:cypress && yarn codemod:module-path-aliases:sb",
+ "codemod:module-path-aliases:src": "npx relative-to-alias --src 'src' --alias '@/app' --alias-path './src/app' --extensions 'js,ts,tsx' --language 'typescript' && npx relative-to-alias --src 'src' --alias '@/common' --alias-path './src/common' --extensions 'js,ts,tsx' --language 'typescript' && npx relative-to-alias --src 'src' --alias '@/components' --alias-path './src/common/components' --extensions 'js,ts,tsx' --language 'typescript' && npx relative-to-alias --src 'src' --alias '@/utils' --alias-path './src/common/utils' --extensions 'js,ts,tsx' --language 'typescript' && npx relative-to-alias --src 'src' --alias '@/layouts' --alias-path './src/layouts' --extensions 'js,ts,tsx' --language 'typescript' && npx relative-to-alias --src 'src' --alias '@/modules' --alias-path './src/modules' --extensions 'js,ts,tsx' --language 'typescript' && npx relative-to-alias --src 'src' --alias '@/pages' --alias-path './src/pages' --extensions 'js,ts,tsx' --language 'typescript'",
+ "codemod:module-path-aliases:cypress": "npx relative-to-alias --src 'cypress' --alias '@/app' --alias-path './src/app' --extensions 'js,ts,tsx' --language 'typescript' && npx relative-to-alias --src 'cypress' --alias '@/common' --alias-path './src/common' --extensions 'js,ts,tsx' --language 'typescript' && npx relative-to-alias --src 'cypress' --alias '@/components' --alias-path './src/common/components' --extensions 'js,ts,tsx' --language 'typescript' && npx relative-to-alias --src 'cypress' --alias '@/utils' --alias-path './src/common/utils' --extensions 'js,ts,tsx' --language 'typescript' && npx relative-to-alias --src 'cypress' --alias '@/layouts' --alias-path './src/layouts' --extensions 'js,ts,tsx' --language 'typescript' && npx relative-to-alias --src 'cypress' --alias '@/modules' --alias-path './src/modules' --extensions 'js,ts,tsx' --language 'typescript' && npx relative-to-alias --src 'cypress' --alias '@/pages' --alias-path './src/pages' --extensions 'js,ts,tsx' --language 'typescript'",
+ "codemod:module-path-aliases:sb": "npx relative-to-alias --src '.storybook' --alias '@/app' --alias-path './src/app' --extensions 'js,ts,tsx' --language 'typescript' && npx relative-to-alias --src '.storybook' --alias '@/common' --alias-path './src/common' --extensions 'js,ts,tsx' --language 'typescript' && npx relative-to-alias --src '.storybook' --alias '@/components' --alias-path './src/common/components' --extensions 'js,ts,tsx' --language 'typescript' && npx relative-to-alias --src '.storybook' --alias '@/utils' --alias-path './src/common/utils' --extensions 'js,ts,tsx' --language 'typescript' && npx relative-to-alias --src '.storybook' --alias '@/layouts' --alias-path './src/layouts' --extensions 'js,ts,tsx' --language 'typescript' && npx relative-to-alias --src '.storybook' --alias '@/modules' --alias-path './src/modules' --extensions 'js,ts,tsx' --language 'typescript' && npx relative-to-alias --src '.storybook' --alias '@/pages' --alias-path './src/pages' --extensions 'js,ts,tsx' --language 'typescript'",
"security:audit": "yarn audit",
"packages:upgrade": "yarn upgrade-interactive --latest"
},
@@ -216,6 +220,7 @@
"@types/lodash.xorby": "4.7.6",
"@types/popper.js": "1.11.0",
"@types/react": "17.0.0",
+ "@types/react-dom": "17.0.0",
"@types/react-test-renderer": "17.0.0",
"@types/reactstrap": "8.7.2",
"@types/uuid": "8.3.0",
@@ -248,6 +253,7 @@
"node-mocks-http": "1.10.0",
"open-cli": "6.0.1",
"react-test-renderer": "17.0.1",
+ "relative-to-alias": "2.0.1",
"storybook-addon-designs": "5.4.3",
"storybook-addon-next-router": "2.0.3",
"storybook-addon-performance": "0.14.0",
diff --git a/src/README.md b/src/README.md
new file mode 100644
index 000000000..cc325bbb7
--- /dev/null
+++ b/src/README.md
@@ -0,0 +1,213 @@
+Sources folder
+===
+
+## What is `src`?
+
+This folder contains all the source files for your Next.js app.
+
+This is where you should write most of your code.
+
+> It also contains the `stories` folder, which isn't used by the Next.js framework, but by Storybook.
+
+## Folder structure
+
+Overview of what each folder is about:
+
+- `app`: Contains code _(components, business logic, types)_ that is being used by the special `pages/_app.tsx` Next.js file.
+- `common`: Contains everything that cannot be categorized as a `module`. _See documentation below._
+- `layouts`: Contains the layouts used by pages. _See documentation below._
+ - `core`: Contains reusable/extendable code _(components, business logic, data fetching)_ used by other layouts.
+ - `default`: Default layout that comes built-in with the strict minimum components (Nav, Footer).
+ _If you use NRN as a boilerplate, that's the layout you should get started with!_
+ - `demo`: Layout used by the [Next Right Now demo](https://nrn-v2-mst-aptd-gcms-lcz-sty-c1.vercel.app) pages.
+ All those pages under `/demo` use the `demo` layout, which contains a custom Nav showing links to each example, and a left menu for easier navigation through the demo.
+- `modules`: Contains related pieces of code (components, types, utils) grouped together. _See documentation below._
+- `pages`: Contains Next.js pages and `api` folder.
+- `stories`: Contains Storybook stories.
+
+### `app` folder
+
+This folder contains the code used to start a Next.js page.
+
+> As a Next.js app grows, it contains more and more code within `pages/_app`, to such a point where it's difficult to understand all that is happening there.
+>
+> The goal of this folder is to centralize all the business logic executed by `pages/_app`, while keeping it organized and maintenable.
+
+This folder contains global styles and "page bootstraps" that are used to initialize the client and server, distinctively.
+It also contains constants used thorough the app.
+
+Read more about "[Application Bootstrap](https://unlyed.github.io/next-right-now/concepts/app-bootstrap)".
+
+### `common` folder
+
+The common folder is meant to be a simple and quick way for developers to write code, without having to think about to modularize it.
+
+Basically, **you should write your code in `common` if**:
+- You're building a very simple app.
+- You're not familiar with modules or not familiar with the existing code.
+- You're in a hurry and just want to do something quickly.
+- You don't know if what you're working on is a module, or might become one in the future.
+- You don't care about using a modular design approach.
+- You don't want to think about building a module yet.
+- You're unsure about whether using a module or using the `common` folder.
+- Etc.
+
+Whether you use `common` or `modules` folder **does not matter**. Not really.
+Don't stress yourself about "doing it the right way", there is no "right way".
+
+Modules are meant to group related code together so that it's easier to reason about.
+It won't change anything if all your code is in `common`, you can always split it into `modules` once you feel it's useful.
+
+> In the end of the day, it doesn't matter if you're using a module or `common`,
+> what matters is you find your code quickly, and the organization makes sense to you (and your team).
+>
+> Don't fight with yourself about it, don't waste time, just do what feels right.
+> Worst case scenario, you'll change it later.
+
+### `layouts` folder
+
+Next.js doesn't come with a built-in "layout" system.
+
+Next Right Now doesn't enforce any layout organization, but we do provide guidance for it.
+
+> Remember, if the layout organization doesn't fit your needs, you're free to do it completely differently!
+
+A layout is composed of elements (Components, utils, etc.) that are used in several pages through your app.
+Layouts change the meta components that are used by several pages.
+
+For instance, Next Right Now comes built-in with the following layouts:
+- `core`
+- `default`
+- `demo`
+
+#### `core` layout
+
+The `core` is a bit particular. It's meant to contain code shared between several layouts.
+
+For instance, you might have a `Nav` component that displays some links in the home page, and other links once connected.
+If the business logic behind the `Nav` component is very different, you might prefer to use 2 different components.
+
+But, if the business logic is similar and only the links themselves are different,
+you might prefer to avoid code duplication and have one `core/components/Nav` component that is being configured differently by the other layouts.
+
+That's the purpose of the `core` folder, to contain such components that are used by other layouts.
+
+> Although components are the most common way to share code between layouts, you might also need to share ways to fetch data or share page properties.
+>
+> Those are also good and valid use-cases for using the `core` folder.
+
+#### `default` layout
+
+The `default` layout is not actively used by Next Right Now, only the page template files use it.
+
+It's an easy-to-get-started layout containing only the minimal stuff, and it's meant to be customized to fit your needs.
+
+> You might also want to rename it to something that makes more sense to you, don't hesitate to do so!
+
+#### `demo` layout
+
+The `demo` layout is used by the NRN demo pages.
+
+> Most people who use Next Right Now as a boilerplate eventually get rid of it, we did (on our private fork).
+
+It's great to show how to build various pages, and can be used as an inspiration.
+It'll be most useful at the beginning, when you learn how to build your own pages.
+
+It's also a good example on how to use layouts, and why they're interesting!
+
+For instance, the `demo` layout customises the `Nav`, but uses the same `Footer` as those in the `core` layout.
+
+#### Adding more layouts?
+
+You can definitely add more layouts!
+
+Keep in mind a layout's purpose is to:
+- Show different pages similarly (same navigation menu, footer, etc.)
+- Prepare `pageProps` similarly for different pages (fetching content from a data source, etc.)
+
+Their goal is to reduce code duplication and increase maintainability of your app.
+Use them as you see fit!
+
+> Usually, a website with an admin section (behind authentication) would use a different layout for the admin part of the site.
+
+### `modules` folder
+
+Modules are and advanced way of organizing your code base.
+
+> Modules within `src/modules/core` are modules built-in with Next Right Now.
+>
+> You should create your own modules in `src/` or `src/modules`. Either is fine, it's a matter of taste/opinion.
+
+They don't change how code is compiled or anything like that,
+they're purely a way to organize your code, so it's easier to reason/maintain.
+
+You should group code together into a module if:
+- You feel like it'll improve the understanding or maintainability of the code.
+- You now understand (from experience) what is that feature you built a few weeks ago and why it would be beneficial to have a dedicated module for it now.
+- You have related code splattered all over `common` (components, utils, hooks, etc.), and it feels like all those pieces should be grouped together.
+
+Modules are the natural evolution of "big" apps.
+Actually, your app doesn't need to be "big" (what's "big" anyway?).
+
+> Do you remember those days where we had our code splitted between `js` and `css` folders?
+>
+> When React/Angular/Vue came out, they changed the way we build UI by introducing the concept of "Components",
+where JS and CSS code lives together, as a unified Component with all related code within the component folder.
+>
+> Modules are very similar.
+
+Here is how we decide (at Unly) if we should use a module:
+- It should be composed of, at least, 2 different entities.
+ - Entities are: Types, Components, Utilities, Hooks, Contexts, etc.
+- We know it's small now, but it's going to grow soon.
+- Exceptionally, if it's related to a 3rd party (e.g: `modules/sentry`), it can be a module.
+- Exceptionally, if we feel like it should be a module, then we go for it (it doesn't really matter anyway!).
+
+#### Why using a modular design pattern?
+
+Modules are a different way of organizing your source code, in a very different way compared to the well-known MVC design pattern.
+
+While MVC (and many other) design pattern groups code together based on "role" of each file,
+our approach is different and groups **related** code together.
+
+MVC is very simple to understand because you don't have to think about it, it's very intuitive, at first.
+Therefore, it's beginner-friendly.
+
+But, **it doesn't scale**.
+
+When you reach a dozen different features, all that code is grouped together (e.g: "Components") even though it's not related to each other.
+On the other hand, when a developer wants to do something, it's often related to a "feature".
+But, the code related to the feature is splattered in many folders and sub-folders because of the MVC pattern.
+
+This makes it much harder to locate the code, and doesn't give an overview of all the related pieces.
+
+That's why we provide a modular design pattern, for those who wishes to use it.
+Although, **the `commons` folder uses a MVC-ish** design pattern: You split your files based on their utility (components, etc.).
+And, that's because it's just simpler to comprehend and reason about, at the beginning.
+
+> In the end, Next Right Now doesn't enforce anything.
+>
+> You're free to use what we recommend (`common` and `modules`) or do everything in `common`, or everything in `modules`, or something entirely different if you wish to!
+>
+> Eventually, you do what feels right for you, and that's what really matters.
+
+### `pages` folder
+
+The `pages` folder is handled by Next.js [as explained in their documentation](https://nextjs.org/docs/basic-features/pages).
+
+> Next Right Now doesn't change how `pages` work in any way.
+
+Because Next Right Now provides localized support, most pages are under the `pages/[locale]` folder.
+
+#### NRN Demo
+
+Also, the `/pages/[locale]/demo` folder contains all pages related to the Next Right Now demo.
+You may wish to delete it, or keep it around for documentation purpose.
+
+### `stories` folder
+
+Contains [Storybook stories](https://storybook.js.org/docs/react/get-started/whats-a-story).
+
+---
+
+> The current folder structure is the result of a community discussion (RFC), [check it out](https://github.com/UnlyEd/next-right-now/discussions/183) to share your feedback!
diff --git a/src/app/README.md b/src/app/README.md
new file mode 100644
index 000000000..45aba2a2a
--- /dev/null
+++ b/src/app/README.md
@@ -0,0 +1,10 @@
+App
+===
+
+> Check out the [documentation about the folder structure](../README.md#app-folder)
+
+Summary:
+- This folder is a way to organize what happens in `pages/_app`.
+- It also contains app-wide configuration (constants).
+- `Multiversal` means code executed "no matter what".
+- Next Right Now `pages/_app` split the server and the browser code into 2 different files, to make it easier to understand.
diff --git a/src/components/appBootstrap/BrowserPageBootstrap.tsx b/src/app/components/BrowserPageBootstrap.tsx
similarity index 78%
rename from src/components/appBootstrap/BrowserPageBootstrap.tsx
rename to src/app/components/BrowserPageBootstrap.tsx
index a5246467e..1ee9dfa0d 100644
--- a/src/components/appBootstrap/BrowserPageBootstrap.tsx
+++ b/src/app/components/BrowserPageBootstrap.tsx
@@ -1,3 +1,27 @@
+import { MultiversalPageProps } from '@/layouts/core/types/MultiversalPageProps';
+import { OnlyBrowserPageProps } from '@/layouts/core/types/OnlyBrowserPageProps';
+import { getAmplitudeInstance } from '@/modules/core/amplitude/amplitude';
+import amplitudeContext from '@/modules/core/amplitude/context/amplitudeContext';
+import UniversalCookiesManager from '@/modules/core/cookiesManager/UniversalCookiesManager';
+import useCustomer from '@/modules/core/data/hooks/useCustomer';
+import useDataset from '@/modules/core/data/hooks/useDataset';
+import { Customer } from '@/modules/core/data/types/Customer';
+import { detectLightHouse } from '@/modules/core/lightHouse/lighthouse';
+import { configureSentryUser } from '@/modules/core/sentry/sentry';
+import { cypressContext } from '@/modules/core/testing/contexts/cypressContext';
+import {
+ CYPRESS_WINDOW_NS,
+ detectCypress,
+} from '@/modules/core/testing/cypress';
+import userConsentContext from '@/modules/core/userConsent/contexts/userConsentContext';
+import initCookieConsent, { getUserConsent } from '@/modules/core/userConsent/cookieConsent';
+import { UserConsent } from '@/modules/core/userConsent/types/UserConsent';
+import { UserSemiPersistentSession } from '@/modules/core/userSession/types/UserSemiPersistentSession';
+import { userSessionContext } from '@/modules/core/userSession/userSessionContext';
+import {
+ getIframeReferrer,
+ isRunningInIframe,
+} from '@/utils/iframe';
import {
Amplitude,
AmplitudeProvider,
@@ -8,34 +32,10 @@ import { createLogger } from '@unly/utils-simple-logger';
import { AmplitudeClient } from 'amplitude-js';
import React from 'react';
import { useTranslation } from 'react-i18next';
-import useCustomer from '../../hooks/useCustomer';
-import useDataset from '../../hooks/useDataset';
-import amplitudeContext from '../../stores/amplitudeContext';
-import { cypressContext } from '../../stores/cypressContext';
-import userConsentContext from '../../stores/userConsentContext';
-import { userSessionContext } from '../../stores/userSessionContext';
-import { Customer } from '../../types/data/Customer';
-import { MultiversalAppBootstrapPageProps } from '../../types/nextjs/MultiversalAppBootstrapPageProps';
-import { MultiversalAppBootstrapProps } from '../../types/nextjs/MultiversalAppBootstrapProps';
-import { MultiversalPageProps } from '../../types/pageProps/MultiversalPageProps';
-import { OnlyBrowserPageProps } from '../../types/pageProps/OnlyBrowserPageProps';
-import { UserConsent } from '../../types/UserConsent';
-import { UserSemiPersistentSession } from '../../types/UserSemiPersistentSession';
-import { getAmplitudeInstance } from '../../utils/analytics/amplitude';
-import initCookieConsent, { getUserConsent } from '../../utils/cookies/cookieConsent';
-import UniversalCookiesManager from '../../utils/cookies/UniversalCookiesManager';
-import {
- getIframeReferrer,
- isRunningInIframe,
-} from '../../utils/iframe';
-import { configureSentryUser } from '../../utils/monitoring/sentry';
-import { detectLightHouse } from '../../utils/quality/lighthouse';
-import {
- CYPRESS_WINDOW_NS,
- detectCypress,
-} from '../../utils/testing/cypress';
+import { MultiversalAppBootstrapPageProps } from '../types/MultiversalAppBootstrapPageProps';
+import { MultiversalAppBootstrapProps } from '../types/MultiversalAppBootstrapProps';
-const fileLabel = 'components/appBootstrap/BrowserPageBootstrap';
+const fileLabel = 'app/components/BrowserPageBootstrap';
const logger = createLogger({
label: fileLabel,
});
@@ -110,7 +110,7 @@ const BrowserPageBootstrap = (props: BrowserPageBootstrapProps): JSX.Element =>
allowedPages: [ // We only allow it on those pages to avoid display that boring popup on every page
`${window.location.origin}/${locale}/terms`,
`${window.location.origin}/${locale}/privacy`,
- `${window.location.origin}/${locale}/examples/built-in-features/cookies-consent`,
+ `${window.location.origin}/${locale}/demo/built-in-features/cookies-consent`,
],
amplitudeInstance,
locale,
diff --git a/src/components/appBootstrap/MultiversalAppBootstrap.tsx b/src/app/components/MultiversalAppBootstrap.tsx
similarity index 90%
rename from src/components/appBootstrap/MultiversalAppBootstrap.tsx
rename to src/app/components/MultiversalAppBootstrap.tsx
index cbc914a6a..32b2bbbf5 100644
--- a/src/components/appBootstrap/MultiversalAppBootstrap.tsx
+++ b/src/app/components/MultiversalAppBootstrap.tsx
@@ -1,3 +1,32 @@
+import Loader from '@/components/animations/Loader';
+import { SSGPageProps } from '@/layouts/core/types/SSGPageProps';
+import { SSRPageProps } from '@/layouts/core/types/SSRPageProps';
+import customerContext from '@/modules/core/data/contexts/customerContext';
+import datasetContext from '@/modules/core/data/contexts/datasetContext';
+import { Customer } from '@/modules/core/data/types/Customer';
+import { CustomerTheme } from '@/modules/core/data/types/CustomerTheme';
+import { GraphCMSDataset } from '@/modules/core/data/types/GraphCMSDataset';
+import DefaultErrorLayout from '@/modules/core/errorHandling/DefaultErrorLayout';
+import i18nContext from '@/modules/core/i18n/contexts/i18nContext';
+import { DEFAULT_LOCALE } from '@/modules/core/i18n/i18n';
+import i18nextLocize from '@/modules/core/i18n/i18nextLocize';
+import {
+ i18nRedirect,
+ stringifyQueryParameters,
+} from '@/modules/core/i18n/i18nRouter';
+import { detectLightHouse } from '@/modules/core/lightHouse/lighthouse';
+import previewModeContext from '@/modules/core/previewMode/contexts/previewModeContext';
+import {
+ startPreviewMode,
+ stopPreviewMode,
+} from '@/modules/core/previewMode/previewMode';
+import quickPreviewContext from '@/modules/core/quickPreview/contexts/quickPreviewContext';
+import { configureSentryI18n } from '@/modules/core/sentry/sentry';
+import deserializeSafe from '@/modules/core/serializeSafe/deserializeSafe';
+import { detectCypress } from '@/modules/core/testing/cypress';
+import { initCustomerTheme } from '@/modules/core/theming/theme';
+import ErrorPage from '@/pages/_error';
+import { NO_AUTO_PREVIEW_MODE_KEY } from '@/pages/api/preview';
import { ThemeProvider } from '@emotion/react';
import * as Sentry from '@sentry/node';
import { isBrowser } from '@unly/utils';
@@ -8,42 +37,13 @@ import includes from 'lodash.includes';
import isEmpty from 'lodash.isempty';
import size from 'lodash.size';
import React, { useState } from 'react';
-import ErrorPage from '../../pages/_error';
-import { NO_AUTO_PREVIEW_MODE_KEY } from '../../pages/api/preview';
-import customerContext from '../../stores/customerContext';
-import datasetContext from '../../stores/datasetContext';
-import i18nContext from '../../stores/i18nContext';
-import previewModeContext from '../../stores/previewModeContext';
-import quickPreviewContext from '../../stores/quickPreviewContext';
-import { Customer } from '../../types/data/Customer';
-import { CustomerTheme } from '../../types/data/CustomerTheme';
-import { MultiversalAppBootstrapProps } from '../../types/nextjs/MultiversalAppBootstrapProps';
-import { SSGPageProps } from '../../types/pageProps/SSGPageProps';
-import { SSRPageProps } from '../../types/pageProps/SSRPageProps';
-import {
- i18nRedirect,
- stringifyQueryParameters,
-} from '../../utils/app/router';
-import { initCustomerTheme } from '../../utils/data/theme';
-import deserializeSafe from '../../utils/graphCMSDataset/deserializeSafe';
-import { GraphCMSDataset } from '../../utils/graphCMSDataset/GraphCMSDataset';
-import { DEFAULT_LOCALE } from '../../utils/i18n/i18n';
-import i18nextLocize from '../../utils/i18n/i18nextLocize';
-import { configureSentryI18n } from '../../utils/monitoring/sentry';
-import getComponentName from '../../utils/nextjs/getComponentName';
-import {
- startPreviewMode,
- stopPreviewMode,
-} from '../../utils/nextjs/previewMode';
-import { detectLightHouse } from '../../utils/quality/lighthouse';
-import { detectCypress } from '../../utils/testing/cypress';
-import Loader from '../animations/Loader';
-import DefaultErrorLayout from '../errors/DefaultErrorLayout';
+import getComponentName from '../getComponentName';
+import { MultiversalAppBootstrapProps } from '../types/MultiversalAppBootstrapProps';
import BrowserPageBootstrap, { BrowserPageBootstrapProps } from './BrowserPageBootstrap';
import MultiversalGlobalStyles from './MultiversalGlobalStyles';
import ServerPageBootstrap, { ServerPageBootstrapProps } from './ServerPageBootstrap';
-const fileLabel = 'components/appBootstrap/MultiversalAppBootstrap';
+const fileLabel = 'app/components/MultiversalAppBootstrap';
const logger = createLogger({
label: fileLabel,
});
@@ -211,7 +211,7 @@ const MultiversalAppBootstrap: React.FunctionComponent = (props): JSX.Ele
}
const dataset: GraphCMSDataset = deserializeSafe(serializedDataset);
- const customer: Customer = find(dataset, { __typename: 'Customer' }) as Customer;
+ const customer: Customer = dataset?.customer;
let availableLanguages: string[] = customer?.availableLanguages;
if (isEmpty(availableLanguages)) {
diff --git a/src/components/appBootstrap/MultiversalGlobalExternalStyles.tsx b/src/app/components/MultiversalGlobalExternalStyles.tsx
similarity index 100%
rename from src/components/appBootstrap/MultiversalGlobalExternalStyles.tsx
rename to src/app/components/MultiversalGlobalExternalStyles.tsx
diff --git a/src/components/appBootstrap/MultiversalGlobalStyles.tsx b/src/app/components/MultiversalGlobalStyles.tsx
similarity index 98%
rename from src/components/appBootstrap/MultiversalGlobalStyles.tsx
rename to src/app/components/MultiversalGlobalStyles.tsx
index 929dc9842..9a77d6307 100644
--- a/src/components/appBootstrap/MultiversalGlobalStyles.tsx
+++ b/src/app/components/MultiversalGlobalStyles.tsx
@@ -1,10 +1,10 @@
+import { CustomerTheme } from '@/modules/core/data/types/CustomerTheme';
import {
css,
Global,
} from '@emotion/react';
import React from 'react';
-import { NRN_DEFAULT_FALLBACK_FONTS } from '../../constants';
-import { CustomerTheme } from '../../types/data/CustomerTheme';
+import { NRN_DEFAULT_FALLBACK_FONTS } from '../constants';
type Props = {
customerTheme: CustomerTheme;
diff --git a/src/components/appBootstrap/ServerPageBootstrap.tsx b/src/app/components/ServerPageBootstrap.tsx
similarity index 70%
rename from src/components/appBootstrap/ServerPageBootstrap.tsx
rename to src/app/components/ServerPageBootstrap.tsx
index 21ff21dc4..f00e23d82 100644
--- a/src/components/appBootstrap/ServerPageBootstrap.tsx
+++ b/src/app/components/ServerPageBootstrap.tsx
@@ -1,15 +1,14 @@
+import { MultiversalPageProps } from '@/layouts/core/types/MultiversalPageProps';
+import { OnlyServerPageProps } from '@/layouts/core/types/OnlyServerPageProps';
+import { configureSentryUser } from '@/modules/core/sentry/sentry';
+import { userSessionContext } from '@/modules/core/userSession/userSessionContext';
import * as Sentry from '@sentry/node';
import { createLogger } from '@unly/utils-simple-logger';
import React from 'react';
+import { MultiversalAppBootstrapPageProps } from '../types/MultiversalAppBootstrapPageProps';
+import { MultiversalAppBootstrapProps } from '../types/MultiversalAppBootstrapProps';
-import { userSessionContext } from '../../stores/userSessionContext';
-import { MultiversalAppBootstrapPageProps } from '../../types/nextjs/MultiversalAppBootstrapPageProps';
-import { MultiversalAppBootstrapProps } from '../../types/nextjs/MultiversalAppBootstrapProps';
-import { MultiversalPageProps } from '../../types/pageProps/MultiversalPageProps';
-import { OnlyServerPageProps } from '../../types/pageProps/OnlyServerPageProps';
-import { configureSentryUser } from '../../utils/monitoring/sentry';
-
-const fileLabel = 'components/appBootstrap/ServerPageBootstrap';
+const fileLabel = 'app/components/ServerPageBootstrap';
const logger = createLogger({
label: fileLabel,
});
diff --git a/src/constants.ts b/src/app/constants.ts
similarity index 94%
rename from src/constants.ts
rename to src/app/constants.ts
index 020a7fd83..f9090614c 100644
--- a/src/constants.ts
+++ b/src/app/constants.ts
@@ -1,5 +1,5 @@
-import { CustomerTheme } from './types/data/CustomerTheme';
-import { resolveVariantColor } from './utils/colors';
+import { CustomerTheme } from '@/modules/core/data/types/CustomerTheme';
+import { resolveVariantColor } from '@/modules/core/theming/colors';
export const NRN_DEFAULT_SERVICE_LABEL = process.env.NEXT_PUBLIC_APP_STAGE === 'production' ? 'Next Right Now' : `[${process.env.NEXT_PUBLIC_APP_STAGE === 'staging' ? 'Preview' : 'Dev'}] Next Right Now`;
@@ -25,9 +25,9 @@ export const NRN_DEFAULT_FONT = 'neuzeit-grotesk';
* Theme applied by default when no theme is defined.
* Will be used on a variable-by-variable basis based on what's configured on the CMS for the customer.
*
- * Applied through "src/utils/airtableSchema/airtableSchema.ts" default value transformations.
- *
+ * Applied through "src/modules/core/theming/theme.ts" default value transformations.
* Strongly inspired from Material Design Color System.
+ *
* @see The below documentation comes from https://material.io/design/color/the-color-system.html
*/
export const NRN_DEFAULT_THEME: Omit & {
diff --git a/src/utils/nextjs/getComponentName.ts b/src/app/getComponentName.ts
similarity index 66%
rename from src/utils/nextjs/getComponentName.ts
rename to src/app/getComponentName.ts
index 6fe4552a5..cde9d37b7 100644
--- a/src/utils/nextjs/getComponentName.ts
+++ b/src/app/getComponentName.ts
@@ -3,6 +3,14 @@ import {
NextPageContext,
} from 'next';
+/**
+ * Resolves the name of a Next.js "pageProps.Component".
+ * A "Component" is a "Page".
+ *
+ * Extract the name from the component function source code.
+ *
+ * @param Component
+ */
export const getComponentName = (Component: NextComponentType): string | null => {
try {
const componentAsString = Component.toString();
diff --git a/src/types/nextjs/CommonServerSideParams.ts b/src/app/types/CommonServerSideParams.ts
similarity index 100%
rename from src/types/nextjs/CommonServerSideParams.ts
rename to src/app/types/CommonServerSideParams.ts
diff --git a/src/types/nextjs/MultiversalAppBootstrapPageProps.ts b/src/app/types/MultiversalAppBootstrapPageProps.ts
similarity index 83%
rename from src/types/nextjs/MultiversalAppBootstrapPageProps.ts
rename to src/app/types/MultiversalAppBootstrapPageProps.ts
index 4e955c571..16a431136 100644
--- a/src/types/nextjs/MultiversalAppBootstrapPageProps.ts
+++ b/src/app/types/MultiversalAppBootstrapPageProps.ts
@@ -1,5 +1,5 @@
+import { CustomerTheme } from '@/modules/core/data/types/CustomerTheme';
import { i18n } from 'i18next';
-import { CustomerTheme } from '../data/CustomerTheme';
/**
* Additional props that are injected by MultiversalAppBootstrap to all pages
diff --git a/src/types/nextjs/MultiversalAppBootstrapProps.ts b/src/app/types/MultiversalAppBootstrapProps.ts
similarity index 93%
rename from src/types/nextjs/MultiversalAppBootstrapProps.ts
rename to src/app/types/MultiversalAppBootstrapProps.ts
index fb5925a60..ab7a57a9a 100644
--- a/src/types/nextjs/MultiversalAppBootstrapProps.ts
+++ b/src/app/types/MultiversalAppBootstrapProps.ts
@@ -1,11 +1,10 @@
+import { MultiversalPageProps } from '@/layouts/core/types/MultiversalPageProps';
import {
NextComponentType,
NextPageContext,
} from 'next';
import { Router } from 'next/router';
-import { MultiversalPageProps } from '../pageProps/MultiversalPageProps';
-
/**
* Props that are provided to the render function of the application (in _app)
* Those props can be consolidated by either getInitialProps, getServerProps or getStaticProps, depending on the page and its configuration
diff --git a/src/types/nextjs/StaticPath.ts b/src/app/types/StaticPath.ts
similarity index 100%
rename from src/types/nextjs/StaticPath.ts
rename to src/app/types/StaticPath.ts
diff --git a/src/types/nextjs/StaticPathsOutput.ts b/src/app/types/StaticPathsOutput.ts
similarity index 100%
rename from src/types/nextjs/StaticPathsOutput.ts
rename to src/app/types/StaticPathsOutput.ts
diff --git a/src/types/nextjs/StaticPropsInput.ts b/src/app/types/StaticPropsInput.ts
similarity index 84%
rename from src/types/nextjs/StaticPropsInput.ts
rename to src/app/types/StaticPropsInput.ts
index 8191cc6ca..6efacba4c 100644
--- a/src/types/nextjs/StaticPropsInput.ts
+++ b/src/app/types/StaticPropsInput.ts
@@ -1,5 +1,5 @@
+import { PreviewData } from '@/modules/core/previewMode/types/PreviewData';
import { CommonServerSideParams } from './CommonServerSideParams';
-import { PreviewData } from './PreviewData';
/**
* Static props given as inputs for getStaticProps
diff --git a/src/common/README.md b/src/common/README.md
new file mode 100644
index 000000000..05cd378d7
--- /dev/null
+++ b/src/common/README.md
@@ -0,0 +1,9 @@
+Common
+===
+
+> Check out the [documentation about the folder structure](../README.md#common-folder)
+
+Summary:
+- This folder uses an MVC-ish design pattern, where you split your files in separated folders, depending on their kind.
+- This folder is great to quickly write some piece of code, you don't need to think a lot about how organized your code should be, and can get started quickly.
+- If you don't know or are unsure whether to go for `common` or `modules`, pick `common`. You can always change your mind later.
diff --git a/src/components/ComponentTemplate.tsx b/src/common/components/ComponentTemplate.tsx
similarity index 100%
rename from src/components/ComponentTemplate.tsx
rename to src/common/components/ComponentTemplate.tsx
diff --git a/src/components/svg/Animated3Dots.tsx b/src/common/components/animations/Animated3Dots.tsx
similarity index 100%
rename from src/components/svg/Animated3Dots.tsx
rename to src/common/components/animations/Animated3Dots.tsx
diff --git a/src/components/svg/AnimatedLoader.tsx b/src/common/components/animations/AnimatedLoader.tsx
similarity index 100%
rename from src/components/svg/AnimatedLoader.tsx
rename to src/common/components/animations/AnimatedLoader.tsx
diff --git a/src/components/svg/AnimatedTextBubble.tsx b/src/common/components/animations/AnimatedTextBubble.tsx
similarity index 100%
rename from src/components/svg/AnimatedTextBubble.tsx
rename to src/common/components/animations/AnimatedTextBubble.tsx
diff --git a/src/components/animations/Loader.tsx b/src/common/components/animations/Loader.tsx
similarity index 88%
rename from src/components/animations/Loader.tsx
rename to src/common/components/animations/Loader.tsx
index b83356855..54c47abe5 100644
--- a/src/components/animations/Loader.tsx
+++ b/src/common/components/animations/Loader.tsx
@@ -1,6 +1,6 @@
import { css } from '@emotion/react';
import React from 'react';
-import AnimatedLoader from '../svg/AnimatedLoader';
+import AnimatedLoader from './AnimatedLoader';
export type Props = {}
diff --git a/src/components/svg/EnglishHybridFlag.tsx b/src/common/components/countryFlags/EnglishHybridFlag.tsx
similarity index 100%
rename from src/components/svg/EnglishHybridFlag.tsx
rename to src/common/components/countryFlags/EnglishHybridFlag.tsx
diff --git a/src/components/svg/EnglishUkFlag.tsx b/src/common/components/countryFlags/EnglishUkFlag.tsx
similarity index 100%
rename from src/components/svg/EnglishUkFlag.tsx
rename to src/common/components/countryFlags/EnglishUkFlag.tsx
diff --git a/src/components/svg/FrenchFlag.tsx b/src/common/components/countryFlags/FrenchFlag.tsx
similarity index 90%
rename from src/components/svg/FrenchFlag.tsx
rename to src/common/components/countryFlags/FrenchFlag.tsx
index 4cf1d8bf9..db593e56b 100644
--- a/src/components/svg/FrenchFlag.tsx
+++ b/src/common/components/countryFlags/FrenchFlag.tsx
@@ -1,8 +1,10 @@
-import React from "react";
+import React from 'react';
+
type Props = {} & React.SVGProps;
const SvgFrenchFlag = (props: Props): JSX.Element => {
return (
+ // @ts-ignore
-
-
+
+
);
};
diff --git a/src/pages/[locale]/examples/built-in-features/hosting.tsx b/src/pages/[locale]/demo/built-in-features/hosting.tsx
similarity index 78%
rename from src/pages/[locale]/examples/built-in-features/hosting.tsx
rename to src/pages/[locale]/demo/built-in-features/hosting.tsx
index 1bc2577a3..7c2d049c0 100644
--- a/src/pages/[locale]/examples/built-in-features/hosting.tsx
+++ b/src/pages/[locale]/demo/built-in-features/hosting.tsx
@@ -1,3 +1,15 @@
+import { CommonServerSideParams } from '@/app/types/CommonServerSideParams';
+import ExternalLink from '@/common/components/dataDisplay/ExternalLink';
+import { OnlyBrowserPageProps } from '@/layouts/core/types/OnlyBrowserPageProps';
+import { SSGPageProps } from '@/layouts/core/types/SSGPageProps';
+import BuiltInFeaturesSidebar from '@/layouts/demo/components/BuiltInFeaturesSidebar';
+import DemoLayout from '@/layouts/demo/components/DemoLayout';
+import DemoPage from '@/layouts/demo/components/DemoPage';
+import {
+ getDemoStaticPaths,
+ getDemoStaticProps,
+} from '@/layouts/demo/demoSSG';
+import withApollo from '@/modules/core/gql/hocs/withApollo';
import { createLogger } from '@unly/utils-simple-logger';
import {
GetStaticPaths,
@@ -8,20 +20,7 @@ import {
import React from 'react';
import { Alert } from 'reactstrap';
-import BuiltInFeaturesSidebar from '../../../../components/doc/BuiltInFeaturesSidebar';
-import DocPage from '../../../../components/doc/DocPage';
-import DefaultLayout from '../../../../components/pageLayouts/DefaultLayout';
-import ExternalLink from '../../../../components/utils/ExternalLink';
-import withApollo from '../../../../hocs/withApollo';
-import { CommonServerSideParams } from '../../../../types/nextjs/CommonServerSideParams';
-import { OnlyBrowserPageProps } from '../../../../types/pageProps/OnlyBrowserPageProps';
-import { SSGPageProps } from '../../../../types/pageProps/SSGPageProps';
-import {
- getExamplesCommonStaticPaths,
- getExamplesCommonStaticProps,
-} from '../../../../utils/nextjs/SSG';
-
-const fileLabel = 'pages/[locale]/examples/built-in-features/hosting';
+const fileLabel = 'pages/[locale]/demo/built-in-features/hosting';
const logger = createLogger({ // eslint-disable-line no-unused-vars,@typescript-eslint/no-unused-vars
label: fileLabel,
});
@@ -30,7 +29,7 @@ const logger = createLogger({ // eslint-disable-line no-unused-vars,@typescript-
* Only executed on the server side at build time
* Necessary when a page has dynamic routes and uses "getStaticProps"
*/
-export const getStaticPaths: GetStaticPaths = getExamplesCommonStaticPaths;
+export const getStaticPaths: GetStaticPaths = getDemoStaticPaths;
/**
* Only executed on the server side at build time.
@@ -40,7 +39,7 @@ export const getStaticPaths: GetStaticPaths = getExample
* @see https://github.com/vercel/next.js/discussions/10949#discussioncomment-6884
* @see https://nextjs.org/docs/basic-features/data-fetching#getstaticprops-static-generation
*/
-export const getStaticProps: GetStaticProps = getExamplesCommonStaticProps;
+export const getStaticProps: GetStaticProps = getDemoStaticProps;
/**
* SSG pages are first rendered by the server (during static bundling)
@@ -54,7 +53,7 @@ type Props = {} & SSGPageProps>;
const HostingPage: NextPage = (props): JSX.Element => {
return (
- = (props): JSX.Element => {
}}
Sidebar={BuiltInFeaturesSidebar}
>
-
+
Hosting, using Vercel vendor
@@ -89,8 +88,8 @@ const HostingPage: NextPage = (props): JSX.Element => {
if you're considering Vercel.
-
-
+
+
);
};
diff --git a/src/pages/[locale]/examples/built-in-features/icons.tsx b/src/pages/[locale]/demo/built-in-features/icons.tsx
similarity index 81%
rename from src/pages/[locale]/examples/built-in-features/icons.tsx
rename to src/pages/[locale]/demo/built-in-features/icons.tsx
index 8f8843eca..2fa5940b4 100644
--- a/src/pages/[locale]/examples/built-in-features/icons.tsx
+++ b/src/pages/[locale]/demo/built-in-features/icons.tsx
@@ -1,3 +1,15 @@
+import { CommonServerSideParams } from '@/app/types/CommonServerSideParams';
+import Code from '@/common/components/dataDisplay/Code';
+import { OnlyBrowserPageProps } from '@/layouts/core/types/OnlyBrowserPageProps';
+import { SSGPageProps } from '@/layouts/core/types/SSGPageProps';
+import BuiltInFeaturesSidebar from '@/layouts/demo/components/BuiltInFeaturesSidebar';
+import DemoLayout from '@/layouts/demo/components/DemoLayout';
+import DemoPage from '@/layouts/demo/components/DemoPage';
+import {
+ getDemoStaticPaths,
+ getDemoStaticProps,
+} from '@/layouts/demo/demoSSG';
+import withApollo from '@/modules/core/gql/hocs/withApollo';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import { createLogger } from '@unly/utils-simple-logger';
import {
@@ -9,20 +21,7 @@ import {
import React from 'react';
import { Alert } from 'reactstrap';
-import BuiltInFeaturesSidebar from '../../../../components/doc/BuiltInFeaturesSidebar';
-import DocPage from '../../../../components/doc/DocPage';
-import DefaultLayout from '../../../../components/pageLayouts/DefaultLayout';
-import Code from '../../../../components/utils/Code';
-import withApollo from '../../../../hocs/withApollo';
-import { CommonServerSideParams } from '../../../../types/nextjs/CommonServerSideParams';
-import { OnlyBrowserPageProps } from '../../../../types/pageProps/OnlyBrowserPageProps';
-import { SSGPageProps } from '../../../../types/pageProps/SSGPageProps';
-import {
- getExamplesCommonStaticPaths,
- getExamplesCommonStaticProps,
-} from '../../../../utils/nextjs/SSG';
-
-const fileLabel = 'pages/[locale]/examples/built-in-features/icons';
+const fileLabel = 'pages/[locale]/demo/built-in-features/icons';
const logger = createLogger({ // eslint-disable-line no-unused-vars,@typescript-eslint/no-unused-vars
label: fileLabel,
});
@@ -31,7 +30,7 @@ const logger = createLogger({ // eslint-disable-line no-unused-vars,@typescript-
* Only executed on the server side at build time
* Necessary when a page has dynamic routes and uses "getStaticProps"
*/
-export const getStaticPaths: GetStaticPaths = getExamplesCommonStaticPaths;
+export const getStaticPaths: GetStaticPaths = getDemoStaticPaths;
/**
* Only executed on the server side at build time.
@@ -41,7 +40,7 @@ export const getStaticPaths: GetStaticPaths = getExample
* @see https://github.com/vercel/next.js/discussions/10949#discussioncomment-6884
* @see https://nextjs.org/docs/basic-features/data-fetching#getstaticprops-static-generation
*/
-export const getStaticProps: GetStaticProps = getExamplesCommonStaticProps;
+export const getStaticProps: GetStaticProps = getDemoStaticProps;
/**
* SSG pages are first rendered by the server (during static bundling)
@@ -55,7 +54,7 @@ type Props = {} & SSGPageProps>;
const ExampleIconsPage: NextPage = (props): JSX.Element => {
return (
- = (props): JSX.Element => {
}}
Sidebar={BuiltInFeaturesSidebar}
>
-
+
Icons examples, using Font-Awesome
@@ -125,8 +124,8 @@ const ExampleIconsPage: NextPage = (props): JSX.Element => {
, by telling you if the icon is valid.
-
-
+
+
);
};
diff --git a/src/pages/[locale]/examples/built-in-features/index.tsx b/src/pages/[locale]/demo/built-in-features/index.tsx
similarity index 73%
rename from src/pages/[locale]/examples/built-in-features/index.tsx
rename to src/pages/[locale]/demo/built-in-features/index.tsx
index 0d2dee8f8..509c75a2e 100644
--- a/src/pages/[locale]/examples/built-in-features/index.tsx
+++ b/src/pages/[locale]/demo/built-in-features/index.tsx
@@ -1,10 +1,9 @@
+import { CommonServerSideParams } from '@/app/types/CommonServerSideParams';
+import { SSGPageProps } from '@/layouts/core/types/SSGPageProps';
import {
GetStaticPaths,
GetStaticProps,
} from 'next';
-
-import { CommonServerSideParams } from '../../../../types/nextjs/CommonServerSideParams';
-import { SSGPageProps } from '../../../../types/pageProps/SSGPageProps';
import HostingPage, {
getStaticPaths as getStaticPathsHomePage,
getStaticProps as getStaticPropsHomePage,
diff --git a/src/pages/[locale]/examples/built-in-features/manual-deployments.tsx b/src/pages/[locale]/demo/built-in-features/manual-deployments.tsx
similarity index 83%
rename from src/pages/[locale]/examples/built-in-features/manual-deployments.tsx
rename to src/pages/[locale]/demo/built-in-features/manual-deployments.tsx
index 9ef97e9ba..5780c2cd3 100644
--- a/src/pages/[locale]/examples/built-in-features/manual-deployments.tsx
+++ b/src/pages/[locale]/demo/built-in-features/manual-deployments.tsx
@@ -1,3 +1,15 @@
+import { CommonServerSideParams } from '@/app/types/CommonServerSideParams';
+import Code from '@/common/components/dataDisplay/Code';
+import { OnlyBrowserPageProps } from '@/layouts/core/types/OnlyBrowserPageProps';
+import { SSGPageProps } from '@/layouts/core/types/SSGPageProps';
+import BuiltInFeaturesSidebar from '@/layouts/demo/components/BuiltInFeaturesSidebar';
+import DemoLayout from '@/layouts/demo/components/DemoLayout';
+import DemoPage from '@/layouts/demo/components/DemoPage';
+import {
+ getDemoStaticPaths,
+ getDemoStaticProps,
+} from '@/layouts/demo/demoSSG';
+import withApollo from '@/modules/core/gql/hocs/withApollo';
import { createLogger } from '@unly/utils-simple-logger';
import {
GetStaticPaths,
@@ -8,20 +20,7 @@ import {
import React from 'react';
import { Alert } from 'reactstrap';
-import BuiltInFeaturesSidebar from '../../../../components/doc/BuiltInFeaturesSidebar';
-import DocPage from '../../../../components/doc/DocPage';
-import DefaultLayout from '../../../../components/pageLayouts/DefaultLayout';
-import Code from '../../../../components/utils/Code';
-import withApollo from '../../../../hocs/withApollo';
-import { CommonServerSideParams } from '../../../../types/nextjs/CommonServerSideParams';
-import { OnlyBrowserPageProps } from '../../../../types/pageProps/OnlyBrowserPageProps';
-import { SSGPageProps } from '../../../../types/pageProps/SSGPageProps';
-import {
- getExamplesCommonStaticPaths,
- getExamplesCommonStaticProps,
-} from '../../../../utils/nextjs/SSG';
-
-const fileLabel = 'pages/[locale]/examples/built-in-features/manual-deployments';
+const fileLabel = 'pages/[locale]/demo/built-in-features/manual-deployments';
const logger = createLogger({ // eslint-disable-line no-unused-vars,@typescript-eslint/no-unused-vars
label: fileLabel,
});
@@ -30,7 +29,7 @@ const logger = createLogger({ // eslint-disable-line no-unused-vars,@typescript-
* Only executed on the server side at build time
* Necessary when a page has dynamic routes and uses "getStaticProps"
*/
-export const getStaticPaths: GetStaticPaths = getExamplesCommonStaticPaths;
+export const getStaticPaths: GetStaticPaths = getDemoStaticPaths;
/**
* Only executed on the server side at build time.
@@ -40,7 +39,7 @@ export const getStaticPaths: GetStaticPaths = getExample
* @see https://github.com/vercel/next.js/discussions/10949#discussioncomment-6884
* @see https://nextjs.org/docs/basic-features/data-fetching#getstaticprops-static-generation
*/
-export const getStaticProps: GetStaticProps = getExamplesCommonStaticProps;
+export const getStaticProps: GetStaticProps = getDemoStaticProps;
/**
* SSG pages are first rendered by the server (during static bundling)
@@ -54,7 +53,7 @@ type Props = {} & SSGPageProps>;
const ManualDeploymentsPage: NextPage = (props): JSX.Element => {
return (
- = (props): JSX.Element => {
}}
Sidebar={BuiltInFeaturesSidebar}
>
-
+
Manual-deployments examples, using the CLI
@@ -108,8 +107,8 @@ const ManualDeploymentsPage: NextPage = (props): JSX.Element => {
Changing the symbolic link, or "hardcoding" the file will change which customer gets deployed by default.
You can also change the way CI/CD works and deploy all your customers at once every time, but we preferred to deploy one customer in particular (our own internal demo) by default, as we judged it was less risky in case anything goes wrong.
-
-
+
+
);
};
diff --git a/src/pages/[locale]/examples/built-in-features/monitoring.tsx b/src/pages/[locale]/demo/built-in-features/monitoring.tsx
similarity index 77%
rename from src/pages/[locale]/examples/built-in-features/monitoring.tsx
rename to src/pages/[locale]/demo/built-in-features/monitoring.tsx
index a7eb9171d..7f8422b14 100644
--- a/src/pages/[locale]/examples/built-in-features/monitoring.tsx
+++ b/src/pages/[locale]/demo/built-in-features/monitoring.tsx
@@ -1,3 +1,15 @@
+import { CommonServerSideParams } from '@/app/types/CommonServerSideParams';
+import ExternalLink from '@/common/components/dataDisplay/ExternalLink';
+import { OnlyBrowserPageProps } from '@/layouts/core/types/OnlyBrowserPageProps';
+import { SSGPageProps } from '@/layouts/core/types/SSGPageProps';
+import BuiltInFeaturesSidebar from '@/layouts/demo/components/BuiltInFeaturesSidebar';
+import DemoLayout from '@/layouts/demo/components/DemoLayout';
+import DemoPage from '@/layouts/demo/components/DemoPage';
+import {
+ getDemoStaticPaths,
+ getDemoStaticProps,
+} from '@/layouts/demo/demoSSG';
+import withApollo from '@/modules/core/gql/hocs/withApollo';
import { createLogger } from '@unly/utils-simple-logger';
import {
GetStaticPaths,
@@ -8,20 +20,7 @@ import {
import React from 'react';
import { Alert } from 'reactstrap';
-import BuiltInFeaturesSidebar from '../../../../components/doc/BuiltInFeaturesSidebar';
-import DocPage from '../../../../components/doc/DocPage';
-import DefaultLayout from '../../../../components/pageLayouts/DefaultLayout';
-import ExternalLink from '../../../../components/utils/ExternalLink';
-import withApollo from '../../../../hocs/withApollo';
-import { CommonServerSideParams } from '../../../../types/nextjs/CommonServerSideParams';
-import { OnlyBrowserPageProps } from '../../../../types/pageProps/OnlyBrowserPageProps';
-import { SSGPageProps } from '../../../../types/pageProps/SSGPageProps';
-import {
- getExamplesCommonStaticPaths,
- getExamplesCommonStaticProps,
-} from '../../../../utils/nextjs/SSG';
-
-const fileLabel = 'pages/[locale]/examples/built-in-features/monitoring';
+const fileLabel = 'pages/[locale]/demo/built-in-features/monitoring';
const logger = createLogger({ // eslint-disable-line no-unused-vars,@typescript-eslint/no-unused-vars
label: fileLabel,
});
@@ -30,7 +29,7 @@ const logger = createLogger({ // eslint-disable-line no-unused-vars,@typescript-
* Only executed on the server side at build time
* Necessary when a page has dynamic routes and uses "getStaticProps"
*/
-export const getStaticPaths: GetStaticPaths = getExamplesCommonStaticPaths;
+export const getStaticPaths: GetStaticPaths = getDemoStaticPaths;
/**
* Only executed on the server side at build time.
@@ -40,7 +39,7 @@ export const getStaticPaths: GetStaticPaths = getExample
* @see https://github.com/vercel/next.js/discussions/10949#discussioncomment-6884
* @see https://nextjs.org/docs/basic-features/data-fetching#getstaticprops-static-generation
*/
-export const getStaticProps: GetStaticProps = getExamplesCommonStaticProps;
+export const getStaticProps: GetStaticProps = getDemoStaticProps;
/**
* SSG pages are first rendered by the server (during static bundling)
@@ -54,7 +53,7 @@ type Props = {} & SSGPageProps>;
const ExampleMonitoringPage: NextPage = (props): JSX.Element => {
return (
- = (props): JSX.Element => {
}}
Sidebar={BuiltInFeaturesSidebar}
>
-
+
Monitoring examples, using Sentry
@@ -105,8 +104,8 @@ const ExampleMonitoringPage: NextPage = (props): JSX.Element => {
-
-
+
+
);
};
diff --git a/src/pages/[locale]/examples/built-in-features/stages-and-secrets.tsx b/src/pages/[locale]/demo/built-in-features/stages-and-secrets.tsx
similarity index 83%
rename from src/pages/[locale]/examples/built-in-features/stages-and-secrets.tsx
rename to src/pages/[locale]/demo/built-in-features/stages-and-secrets.tsx
index 6753894c8..a2c9ec6d7 100644
--- a/src/pages/[locale]/examples/built-in-features/stages-and-secrets.tsx
+++ b/src/pages/[locale]/demo/built-in-features/stages-and-secrets.tsx
@@ -1,3 +1,15 @@
+import { CommonServerSideParams } from '@/app/types/CommonServerSideParams';
+import ExternalLink from '@/common/components/dataDisplay/ExternalLink';
+import { OnlyBrowserPageProps } from '@/layouts/core/types/OnlyBrowserPageProps';
+import { SSGPageProps } from '@/layouts/core/types/SSGPageProps';
+import BuiltInFeaturesSidebar from '@/layouts/demo/components/BuiltInFeaturesSidebar';
+import DemoLayout from '@/layouts/demo/components/DemoLayout';
+import DemoPage from '@/layouts/demo/components/DemoPage';
+import {
+ getDemoStaticPaths,
+ getDemoStaticProps,
+} from '@/layouts/demo/demoSSG';
+import withApollo from '@/modules/core/gql/hocs/withApollo';
import { createLogger } from '@unly/utils-simple-logger';
import {
GetStaticPaths,
@@ -8,20 +20,7 @@ import {
import React from 'react';
import { Alert } from 'reactstrap';
-import BuiltInFeaturesSidebar from '../../../../components/doc/BuiltInFeaturesSidebar';
-import DocPage from '../../../../components/doc/DocPage';
-import DefaultLayout from '../../../../components/pageLayouts/DefaultLayout';
-import ExternalLink from '../../../../components/utils/ExternalLink';
-import withApollo from '../../../../hocs/withApollo';
-import { CommonServerSideParams } from '../../../../types/nextjs/CommonServerSideParams';
-import { OnlyBrowserPageProps } from '../../../../types/pageProps/OnlyBrowserPageProps';
-import { SSGPageProps } from '../../../../types/pageProps/SSGPageProps';
-import {
- getExamplesCommonStaticPaths,
- getExamplesCommonStaticProps,
-} from '../../../../utils/nextjs/SSG';
-
-const fileLabel = 'pages/[locale]/examples/built-in-features/stages-and-secrets';
+const fileLabel = 'pages/[locale]/demo/built-in-features/stages-and-secrets';
const logger = createLogger({ // eslint-disable-line no-unused-vars,@typescript-eslint/no-unused-vars
label: fileLabel,
});
@@ -30,7 +29,7 @@ const logger = createLogger({ // eslint-disable-line no-unused-vars,@typescript-
* Only executed on the server side at build time
* Necessary when a page has dynamic routes and uses "getStaticProps"
*/
-export const getStaticPaths: GetStaticPaths = getExamplesCommonStaticPaths;
+export const getStaticPaths: GetStaticPaths = getDemoStaticPaths;
/**
* Only executed on the server side at build time.
@@ -40,7 +39,7 @@ export const getStaticPaths: GetStaticPaths = getExample
* @see https://github.com/vercel/next.js/discussions/10949#discussioncomment-6884
* @see https://nextjs.org/docs/basic-features/data-fetching#getstaticprops-static-generation
*/
-export const getStaticProps: GetStaticProps = getExamplesCommonStaticProps;
+export const getStaticProps: GetStaticProps = getDemoStaticProps;
/**
* SSG pages are first rendered by the server (during static bundling)
@@ -54,7 +53,7 @@ type Props = {} & SSGPageProps>;
const StagesAndSecretsPage: NextPage = (props): JSX.Element => {
return (
- = (props): JSX.Element => {
}}
Sidebar={BuiltInFeaturesSidebar}
>
-
+
Stages & secrets, using the best of both Next.js and Vercel vendor
@@ -109,8 +108,8 @@ const StagesAndSecretsPage: NextPage = (props): JSX.Element => {
Therefore, we recommend to use the term secrets for everything that's securely stored on Vercel, and the term environment variables for everything that's not securely stored (git tracked, readable from code files).
-
-
+
+
);
};
diff --git a/src/pages/[locale]/examples/built-in-features/static-i18n.tsx b/src/pages/[locale]/demo/built-in-features/static-i18n.tsx
similarity index 90%
rename from src/pages/[locale]/examples/built-in-features/static-i18n.tsx
rename to src/pages/[locale]/demo/built-in-features/static-i18n.tsx
index f2bfa1bd5..dd82f480c 100644
--- a/src/pages/[locale]/examples/built-in-features/static-i18n.tsx
+++ b/src/pages/[locale]/demo/built-in-features/static-i18n.tsx
@@ -1,3 +1,19 @@
+import { CommonServerSideParams } from '@/app/types/CommonServerSideParams';
+import Code from '@/common/components/dataDisplay/Code';
+import ExternalLink from '@/common/components/dataDisplay/ExternalLink';
+import DisplayOnBrowserMount from '@/common/components/rehydration/DisplayOnBrowserMount';
+import { OnlyBrowserPageProps } from '@/layouts/core/types/OnlyBrowserPageProps';
+import { SSGPageProps } from '@/layouts/core/types/SSGPageProps';
+import BuiltInFeaturesSidebar from '@/layouts/demo/components/BuiltInFeaturesSidebar';
+import DemoLayout from '@/layouts/demo/components/DemoLayout';
+import DemoPage from '@/layouts/demo/components/DemoPage';
+import {
+ getDemoStaticPaths,
+ getDemoStaticProps,
+} from '@/layouts/demo/demoSSG';
+import withApollo from '@/modules/core/gql/hocs/withApollo';
+import useI18n, { I18n } from '@/modules/core/i18n/hooks/useI18n';
+import { resolveCustomerVariationLang } from '@/modules/core/i18n/i18n';
import { css } from '@emotion/react';
import { createLogger } from '@unly/utils-simple-logger';
import {
@@ -17,24 +33,7 @@ import {
} from 'reactstrap';
import { v1 as uuid } from 'uuid';
-import BuiltInFeaturesSidebar from '../../../../components/doc/BuiltInFeaturesSidebar';
-import DocPage from '../../../../components/doc/DocPage';
-import DefaultLayout from '../../../../components/pageLayouts/DefaultLayout';
-import DisplayOnBrowserMount from '../../../../components/rehydration/DisplayOnBrowserMount';
-import Code from '../../../../components/utils/Code';
-import ExternalLink from '../../../../components/utils/ExternalLink';
-import withApollo from '../../../../hocs/withApollo';
-import useI18n, { I18n } from '../../../../hooks/useI18n';
-import { CommonServerSideParams } from '../../../../types/nextjs/CommonServerSideParams';
-import { OnlyBrowserPageProps } from '../../../../types/pageProps/OnlyBrowserPageProps';
-import { SSGPageProps } from '../../../../types/pageProps/SSGPageProps';
-import { resolveCustomerVariationLang } from '../../../../utils/i18n/i18n';
-import {
- getExamplesCommonStaticPaths,
- getExamplesCommonStaticProps,
-} from '../../../../utils/nextjs/SSG';
-
-const fileLabel = 'pages/[locale]/examples/built-in-features/static-i18n';
+const fileLabel = 'pages/[locale]/demo/built-in-features/static-i18n';
const logger = createLogger({ // eslint-disable-line no-unused-vars,@typescript-eslint/no-unused-vars
label: fileLabel,
});
@@ -43,7 +42,7 @@ const logger = createLogger({ // eslint-disable-line no-unused-vars,@typescript-
* Only executed on the server side at build time
* Necessary when a page has dynamic routes and uses "getStaticProps"
*/
-export const getStaticPaths: GetStaticPaths = getExamplesCommonStaticPaths;
+export const getStaticPaths: GetStaticPaths = getDemoStaticPaths;
/**
* Only executed on the server side at build time.
@@ -53,7 +52,7 @@ export const getStaticPaths: GetStaticPaths = getExample
* @see https://github.com/vercel/next.js/discussions/10949#discussioncomment-6884
* @see https://nextjs.org/docs/basic-features/data-fetching#getstaticprops-static-generation
*/
-export const getStaticProps: GetStaticProps = getExamplesCommonStaticProps;
+export const getStaticProps: GetStaticProps = getDemoStaticProps;
/**
* SSG pages are first rendered by the server (during static bundling)
@@ -70,7 +69,7 @@ const ExampleStaticI18nPage: NextPage = (props): JSX.Element => {
const { lang }: I18n = useI18n();
return (
- = (props): JSX.Element => {
}}
Sidebar={BuiltInFeaturesSidebar}
>
-
+
Static i18n examples, using i18next and Locize vendor
@@ -302,8 +301,8 @@ const ExampleStaticI18nPage: NextPage = (props): JSX.Element => {
-
-
+
+
);
};
diff --git a/src/pages/[locale]/examples/built-in-features/ui-components.tsx b/src/pages/[locale]/demo/built-in-features/ui-components.tsx
similarity index 81%
rename from src/pages/[locale]/examples/built-in-features/ui-components.tsx
rename to src/pages/[locale]/demo/built-in-features/ui-components.tsx
index 4c62feba1..e39387ace 100644
--- a/src/pages/[locale]/examples/built-in-features/ui-components.tsx
+++ b/src/pages/[locale]/demo/built-in-features/ui-components.tsx
@@ -1,3 +1,17 @@
+import { CommonServerSideParams } from '@/app/types/CommonServerSideParams';
+import Code from '@/common/components/dataDisplay/Code';
+import ExternalLink from '@/common/components/dataDisplay/ExternalLink';
+import Tooltip from '@/common/components/dataDisplay/Tooltip';
+import { OnlyBrowserPageProps } from '@/layouts/core/types/OnlyBrowserPageProps';
+import { SSGPageProps } from '@/layouts/core/types/SSGPageProps';
+import BuiltInFeaturesSidebar from '@/layouts/demo/components/BuiltInFeaturesSidebar';
+import DemoLayout from '@/layouts/demo/components/DemoLayout';
+import DemoPage from '@/layouts/demo/components/DemoPage';
+import {
+ getDemoStaticPaths,
+ getDemoStaticProps,
+} from '@/layouts/demo/demoSSG';
+import withApollo from '@/modules/core/gql/hocs/withApollo';
import { createLogger } from '@unly/utils-simple-logger';
import {
GetStaticPaths,
@@ -11,22 +25,7 @@ import {
Button,
} from 'reactstrap';
-import BuiltInFeaturesSidebar from '../../../../components/doc/BuiltInFeaturesSidebar';
-import DocPage from '../../../../components/doc/DocPage';
-import DefaultLayout from '../../../../components/pageLayouts/DefaultLayout';
-import Code from '../../../../components/utils/Code';
-import ExternalLink from '../../../../components/utils/ExternalLink';
-import Tooltip from '../../../../components/utils/Tooltip';
-import withApollo from '../../../../hocs/withApollo';
-import { CommonServerSideParams } from '../../../../types/nextjs/CommonServerSideParams';
-import { OnlyBrowserPageProps } from '../../../../types/pageProps/OnlyBrowserPageProps';
-import { SSGPageProps } from '../../../../types/pageProps/SSGPageProps';
-import {
- getExamplesCommonStaticPaths,
- getExamplesCommonStaticProps,
-} from '../../../../utils/nextjs/SSG';
-
-const fileLabel = 'pages/[locale]/examples/built-in-features/ui-components';
+const fileLabel = 'pages/[locale]/demo/built-in-features/ui-components';
const logger = createLogger({ // eslint-disable-line no-unused-vars,@typescript-eslint/no-unused-vars
label: fileLabel,
});
@@ -35,7 +34,7 @@ const logger = createLogger({ // eslint-disable-line no-unused-vars,@typescript-
* Only executed on the server side at build time
* Necessary when a page has dynamic routes and uses "getStaticProps"
*/
-export const getStaticPaths: GetStaticPaths = getExamplesCommonStaticPaths;
+export const getStaticPaths: GetStaticPaths = getDemoStaticPaths;
/**
* Only executed on the server side at build time.
@@ -45,7 +44,7 @@ export const getStaticPaths: GetStaticPaths = getExample
* @see https://github.com/vercel/next.js/discussions/10949#discussioncomment-6884
* @see https://nextjs.org/docs/basic-features/data-fetching#getstaticprops-static-generation
*/
-export const getStaticProps: GetStaticProps = getExamplesCommonStaticProps;
+export const getStaticProps: GetStaticProps = getDemoStaticProps;
/**
* SSG pages are first rendered by the server (during static bundling)
@@ -59,7 +58,7 @@ type Props = {} & SSGPageProps>;
const ExampleUIComponentsPage: NextPage = (props): JSX.Element => {
return (
- = (props): JSX.Element => {
}}
Sidebar={BuiltInFeaturesSidebar}
>
-
+
UI components examples, using Reactstrap and Bootstrap
@@ -141,8 +140,8 @@ const ExampleUIComponentsPage: NextPage = (props): JSX.Element => {
`}
/>
-
-
+
+
);
};
diff --git a/src/pages/[locale]/examples/built-in-utilities/api.tsx b/src/pages/[locale]/demo/built-in-utilities/api.tsx
similarity index 78%
rename from src/pages/[locale]/examples/built-in-utilities/api.tsx
rename to src/pages/[locale]/demo/built-in-utilities/api.tsx
index 4e7fc67ac..f5ca692ee 100644
--- a/src/pages/[locale]/examples/built-in-utilities/api.tsx
+++ b/src/pages/[locale]/demo/built-in-utilities/api.tsx
@@ -1,3 +1,15 @@
+import { CommonServerSideParams } from '@/app/types/CommonServerSideParams';
+import ExternalLink from '@/common/components/dataDisplay/ExternalLink';
+import { OnlyBrowserPageProps } from '@/layouts/core/types/OnlyBrowserPageProps';
+import { SSGPageProps } from '@/layouts/core/types/SSGPageProps';
+import BuiltInUtilitiesSidebar from '@/layouts/demo/components/BuiltInUtilitiesSidebar';
+import DemoLayout from '@/layouts/demo/components/DemoLayout';
+import DemoPage from '@/layouts/demo/components/DemoPage';
+import {
+ getDemoStaticPaths,
+ getDemoStaticProps,
+} from '@/layouts/demo/demoSSG';
+import withApollo from '@/modules/core/gql/hocs/withApollo';
import { css } from '@emotion/react';
import { createLogger } from '@unly/utils-simple-logger';
import {
@@ -8,20 +20,7 @@ import {
// eslint-disable-next-line @typescript-eslint/no-unused-vars,no-unused-vars
import React from 'react';
-import BuiltInUtilitiesSidebar from '../../../../components/doc/BuiltInUtilitiesSidebar';
-import DocPage from '../../../../components/doc/DocPage';
-import DefaultLayout from '../../../../components/pageLayouts/DefaultLayout';
-import ExternalLink from '../../../../components/utils/ExternalLink';
-import withApollo from '../../../../hocs/withApollo';
-import { CommonServerSideParams } from '../../../../types/nextjs/CommonServerSideParams';
-import { OnlyBrowserPageProps } from '../../../../types/pageProps/OnlyBrowserPageProps';
-import { SSGPageProps } from '../../../../types/pageProps/SSGPageProps';
-import {
- getExamplesCommonStaticPaths,
- getExamplesCommonStaticProps,
-} from '../../../../utils/nextjs/SSG';
-
-const fileLabel = 'pages/[locale]/examples/built-in-utilities/api';
+const fileLabel = 'pages/[locale]/demo/built-in-utilities/api';
const logger = createLogger({ // eslint-disable-line no-unused-vars,@typescript-eslint/no-unused-vars
label: fileLabel,
});
@@ -30,7 +29,7 @@ const logger = createLogger({ // eslint-disable-line no-unused-vars,@typescript-
* Only executed on the server side at build time
* Necessary when a page has dynamic routes and uses "getStaticProps"
*/
-export const getStaticPaths: GetStaticPaths = getExamplesCommonStaticPaths;
+export const getStaticPaths: GetStaticPaths = getDemoStaticPaths;
/**
* Only executed on the server side at build time.
@@ -40,7 +39,7 @@ export const getStaticPaths: GetStaticPaths = getExample
* @see https://github.com/vercel/next.js/discussions/10949#discussioncomment-6884
* @see https://nextjs.org/docs/basic-features/data-fetching#getstaticprops-static-generation
*/
-export const getStaticProps: GetStaticProps = getExamplesCommonStaticProps;
+export const getStaticProps: GetStaticProps = getDemoStaticProps;
/**
* SSG pages are first rendered by the server (during static bundling)
@@ -54,7 +53,7 @@ type Props = {} & SSGPageProps>;
const ApiPage: NextPage = (props): JSX.Element => {
return (
- = (props): JSX.Element => {
}}
Sidebar={BuiltInUtilitiesSidebar}
>
-
+
-
+
This is a link going to the same page (keeps the current locale)
-
+
This is a link going to the same page (forces to switch to fr-FR locale)
-
+
This is a link going to the same page (forces to switch to en-US locale)
+
This is a link going to the same page (keeps the current locale)
-
+
This is a link going to the same page (forces to switch to fr-FR locale)
-
+
This is a link going to the same page (forces to switch to en-US locale)
`}
/>
-
-
+
+
);
};
diff --git a/src/pages/[locale]/examples/built-in-utilities/index.tsx b/src/pages/[locale]/demo/built-in-utilities/index.tsx
similarity index 75%
rename from src/pages/[locale]/examples/built-in-utilities/index.tsx
rename to src/pages/[locale]/demo/built-in-utilities/index.tsx
index 74841331f..9ec3fc0b9 100644
--- a/src/pages/[locale]/examples/built-in-utilities/index.tsx
+++ b/src/pages/[locale]/demo/built-in-utilities/index.tsx
@@ -1,10 +1,9 @@
+import { CommonServerSideParams } from '@/app/types/CommonServerSideParams';
+import { SSGPageProps } from '@/layouts/core/types/SSGPageProps';
import {
GetStaticPaths,
GetStaticProps,
} from 'next';
-
-import { CommonServerSideParams } from '../../../../types/nextjs/CommonServerSideParams';
-import { SSGPageProps } from '../../../../types/pageProps/SSGPageProps';
import ExampleI18nLinkComponentPage, {
getStaticPaths as getStaticPathsHomePage,
getStaticProps as getStaticPropsHomePage,
diff --git a/src/pages/[locale]/examples/built-in-utilities/interactive-error.tsx b/src/pages/[locale]/demo/built-in-utilities/interactive-error.tsx
similarity index 78%
rename from src/pages/[locale]/examples/built-in-utilities/interactive-error.tsx
rename to src/pages/[locale]/demo/built-in-utilities/interactive-error.tsx
index fefe9efc4..0eabf556a 100644
--- a/src/pages/[locale]/examples/built-in-utilities/interactive-error.tsx
+++ b/src/pages/[locale]/demo/built-in-utilities/interactive-error.tsx
@@ -1,3 +1,14 @@
+import { CommonServerSideParams } from '@/app/types/CommonServerSideParams';
+import Code from '@/common/components/dataDisplay/Code';
+import { OnlyBrowserPageProps } from '@/layouts/core/types/OnlyBrowserPageProps';
+import { SSGPageProps } from '@/layouts/core/types/SSGPageProps';
+import BuiltInUtilitiesSidebar from '@/layouts/demo/components/BuiltInUtilitiesSidebar';
+import DemoLayout from '@/layouts/demo/components/DemoLayout';
+import {
+ getDemoStaticPaths,
+ getDemoStaticProps,
+} from '@/layouts/demo/demoSSG';
+import withApollo from '@/modules/core/gql/hocs/withApollo';
import { createLogger } from '@unly/utils-simple-logger';
import {
GetStaticPaths,
@@ -11,19 +22,7 @@ import {
Button,
} from 'reactstrap';
-import BuiltInUtilitiesSidebar from '../../../../components/doc/BuiltInUtilitiesSidebar';
-import DefaultLayout from '../../../../components/pageLayouts/DefaultLayout';
-import Code from '../../../../components/utils/Code';
-import withApollo from '../../../../hocs/withApollo';
-import { CommonServerSideParams } from '../../../../types/nextjs/CommonServerSideParams';
-import { OnlyBrowserPageProps } from '../../../../types/pageProps/OnlyBrowserPageProps';
-import { SSGPageProps } from '../../../../types/pageProps/SSGPageProps';
-import {
- getExamplesCommonStaticPaths,
- getExamplesCommonStaticProps,
-} from '../../../../utils/nextjs/SSG';
-
-const fileLabel = 'pages/[locale]/examples/built-in-utilities/interactive-error';
+const fileLabel = 'pages/[locale]/demo/built-in-utilities/interactive-error';
const logger = createLogger({ // eslint-disable-line no-unused-vars,@typescript-eslint/no-unused-vars
label: fileLabel,
});
@@ -32,7 +31,7 @@ const logger = createLogger({ // eslint-disable-line no-unused-vars,@typescript-
* Only executed on the server side at build time
* Necessary when a page has dynamic routes and uses "getStaticProps"
*/
-export const getStaticPaths: GetStaticPaths = getExamplesCommonStaticPaths;
+export const getStaticPaths: GetStaticPaths = getDemoStaticPaths;
/**
* Only executed on the server side at build time.
@@ -42,7 +41,7 @@ export const getStaticPaths: GetStaticPaths = getExample
* @see https://github.com/vercel/next.js/discussions/10949#discussioncomment-6884
* @see https://nextjs.org/docs/basic-features/data-fetching#getstaticprops-static-generation
*/
-export const getStaticProps: GetStaticProps = getExamplesCommonStaticProps;
+export const getStaticProps: GetStaticProps = getDemoStaticProps;
/**
* SSG pages are first rendered by the server (during static bundling)
@@ -58,7 +57,7 @@ const InteractiveErrorPage: NextPage = (props): JSX.Element => {
const [isClicked, setIsClicked] = useState(false);
return (
- = (props): JSX.Element => {
`}
/>
-
+
);
};
diff --git a/src/pages/[locale]/examples/built-in-utilities/packages-upgrade.tsx b/src/pages/[locale]/demo/built-in-utilities/packages-upgrade.tsx
similarity index 89%
rename from src/pages/[locale]/examples/built-in-utilities/packages-upgrade.tsx
rename to src/pages/[locale]/demo/built-in-utilities/packages-upgrade.tsx
index cdf8cdf80..06b9f52ba 100644
--- a/src/pages/[locale]/examples/built-in-utilities/packages-upgrade.tsx
+++ b/src/pages/[locale]/demo/built-in-utilities/packages-upgrade.tsx
@@ -1,3 +1,16 @@
+import { CommonServerSideParams } from '@/app/types/CommonServerSideParams';
+import Code from '@/common/components/dataDisplay/Code';
+import ExternalLink from '@/common/components/dataDisplay/ExternalLink';
+import { OnlyBrowserPageProps } from '@/layouts/core/types/OnlyBrowserPageProps';
+import { SSGPageProps } from '@/layouts/core/types/SSGPageProps';
+import BuiltInUtilitiesSidebar from '@/layouts/demo/components/BuiltInUtilitiesSidebar';
+import DemoLayout from '@/layouts/demo/components/DemoLayout';
+import DemoPage from '@/layouts/demo/components/DemoPage';
+import {
+ getDemoStaticPaths,
+ getDemoStaticProps,
+} from '@/layouts/demo/demoSSG';
+import withApollo from '@/modules/core/gql/hocs/withApollo';
import { createLogger } from '@unly/utils-simple-logger';
import {
GetStaticPaths,
@@ -8,21 +21,7 @@ import {
import React from 'react';
import { Alert } from 'reactstrap';
-import BuiltInUtilitiesSidebar from '../../../../components/doc/BuiltInUtilitiesSidebar';
-import DocPage from '../../../../components/doc/DocPage';
-import DefaultLayout from '../../../../components/pageLayouts/DefaultLayout';
-import Code from '../../../../components/utils/Code';
-import ExternalLink from '../../../../components/utils/ExternalLink';
-import withApollo from '../../../../hocs/withApollo';
-import { CommonServerSideParams } from '../../../../types/nextjs/CommonServerSideParams';
-import { OnlyBrowserPageProps } from '../../../../types/pageProps/OnlyBrowserPageProps';
-import { SSGPageProps } from '../../../../types/pageProps/SSGPageProps';
-import {
- getExamplesCommonStaticPaths,
- getExamplesCommonStaticProps,
-} from '../../../../utils/nextjs/SSG';
-
-const fileLabel = 'pages/[locale]/examples/built-in-utilities/packages-upgrade';
+const fileLabel = 'pages/[locale]/demo/built-in-utilities/packages-upgrade';
const logger = createLogger({ // eslint-disable-line no-unused-vars,@typescript-eslint/no-unused-vars
label: fileLabel,
});
@@ -31,7 +30,7 @@ const logger = createLogger({ // eslint-disable-line no-unused-vars,@typescript-
* Only executed on the server side at build time
* Necessary when a page has dynamic routes and uses "getStaticProps"
*/
-export const getStaticPaths: GetStaticPaths = getExamplesCommonStaticPaths;
+export const getStaticPaths: GetStaticPaths = getDemoStaticPaths;
/**
* Only executed on the server side at build time.
@@ -41,7 +40,7 @@ export const getStaticPaths: GetStaticPaths = getExample
* @see https://github.com/vercel/next.js/discussions/10949#discussioncomment-6884
* @see https://nextjs.org/docs/basic-features/data-fetching#getstaticprops-static-generation
*/
-export const getStaticProps: GetStaticProps = getExamplesCommonStaticProps;
+export const getStaticProps: GetStaticProps = getDemoStaticProps;
/**
* SSG pages are first rendered by the server (during static bundling)
@@ -55,7 +54,7 @@ type Props = {} & SSGPageProps>;
const PackagesUpgradePage: NextPage = (props): JSX.Element => {
return (
- = (props): JSX.Element => {
}}
Sidebar={BuiltInUtilitiesSidebar}
>
-
+
Packages upgrade examples
@@ -154,8 +153,8 @@ const PackagesUpgradePage: NextPage = (props): JSX.Element => {
and it would have been very hard (not to say impossible) to figure out the root cause if we had upgraded everything at once.
-
-
+
+
);
};
diff --git a/src/pages/[locale]/examples/built-in-utilities/security-audit.tsx b/src/pages/[locale]/demo/built-in-utilities/security-audit.tsx
similarity index 87%
rename from src/pages/[locale]/examples/built-in-utilities/security-audit.tsx
rename to src/pages/[locale]/demo/built-in-utilities/security-audit.tsx
index 6ff2677c4..396657ee2 100644
--- a/src/pages/[locale]/examples/built-in-utilities/security-audit.tsx
+++ b/src/pages/[locale]/demo/built-in-utilities/security-audit.tsx
@@ -1,3 +1,15 @@
+import { CommonServerSideParams } from '@/app/types/CommonServerSideParams';
+import Code from '@/common/components/dataDisplay/Code';
+import { OnlyBrowserPageProps } from '@/layouts/core/types/OnlyBrowserPageProps';
+import { SSGPageProps } from '@/layouts/core/types/SSGPageProps';
+import BuiltInUtilitiesSidebar from '@/layouts/demo/components/BuiltInUtilitiesSidebar';
+import DemoLayout from '@/layouts/demo/components/DemoLayout';
+import DemoPage from '@/layouts/demo/components/DemoPage';
+import {
+ getDemoStaticPaths,
+ getDemoStaticProps,
+} from '@/layouts/demo/demoSSG';
+import withApollo from '@/modules/core/gql/hocs/withApollo';
import { createLogger } from '@unly/utils-simple-logger';
import {
GetStaticPaths,
@@ -8,20 +20,7 @@ import {
import React from 'react';
import { Alert } from 'reactstrap';
-import BuiltInUtilitiesSidebar from '../../../../components/doc/BuiltInUtilitiesSidebar';
-import DocPage from '../../../../components/doc/DocPage';
-import DefaultLayout from '../../../../components/pageLayouts/DefaultLayout';
-import Code from '../../../../components/utils/Code';
-import withApollo from '../../../../hocs/withApollo';
-import { CommonServerSideParams } from '../../../../types/nextjs/CommonServerSideParams';
-import { OnlyBrowserPageProps } from '../../../../types/pageProps/OnlyBrowserPageProps';
-import { SSGPageProps } from '../../../../types/pageProps/SSGPageProps';
-import {
- getExamplesCommonStaticPaths,
- getExamplesCommonStaticProps,
-} from '../../../../utils/nextjs/SSG';
-
-const fileLabel = 'pages/[locale]/examples/built-in-utilities/security-audit';
+const fileLabel = 'pages/[locale]/demo/built-in-utilities/security-audit';
const logger = createLogger({ // eslint-disable-line no-unused-vars,@typescript-eslint/no-unused-vars
label: fileLabel,
});
@@ -30,7 +29,7 @@ const logger = createLogger({ // eslint-disable-line no-unused-vars,@typescript-
* Only executed on the server side at build time
* Necessary when a page has dynamic routes and uses "getStaticProps"
*/
-export const getStaticPaths: GetStaticPaths = getExamplesCommonStaticPaths;
+export const getStaticPaths: GetStaticPaths = getDemoStaticPaths;
/**
* Only executed on the server side at build time.
@@ -40,7 +39,7 @@ export const getStaticPaths: GetStaticPaths = getExample
* @see https://github.com/vercel/next.js/discussions/10949#discussioncomment-6884
* @see https://nextjs.org/docs/basic-features/data-fetching#getstaticprops-static-generation
*/
-export const getStaticProps: GetStaticProps = getExamplesCommonStaticProps;
+export const getStaticProps: GetStaticProps = getDemoStaticProps;
/**
* SSG pages are first rendered by the server (during static bundling)
@@ -54,7 +53,7 @@ type Props = {} & SSGPageProps>;
const SecurityAuditPage: NextPage = (props): JSX.Element => {
return (
- = (props): JSX.Element => {
}}
Sidebar={BuiltInUtilitiesSidebar}
>
-
+
Security audit examples
@@ -114,8 +113,8 @@ const SecurityAuditPage: NextPage = (props): JSX.Element => {
If you know of a better way to manage security in your app, don't hesitate to open a Github issue/discussion about it!
-
-
+
+
);
};
diff --git a/src/pages/[locale]/examples/built-in-utilities/svg-to-react.tsx b/src/pages/[locale]/demo/built-in-utilities/svg-to-react.tsx
similarity index 72%
rename from src/pages/[locale]/examples/built-in-utilities/svg-to-react.tsx
rename to src/pages/[locale]/demo/built-in-utilities/svg-to-react.tsx
index c2d470c8e..dda24de20 100644
--- a/src/pages/[locale]/examples/built-in-utilities/svg-to-react.tsx
+++ b/src/pages/[locale]/demo/built-in-utilities/svg-to-react.tsx
@@ -1,3 +1,19 @@
+import { CommonServerSideParams } from '@/app/types/CommonServerSideParams';
+import EnglishHybridFlag from '@/common/components/countryFlags/EnglishHybridFlag';
+import EnglishUkFlag from '@/common/components/countryFlags/EnglishUkFlag';
+import FrenchFlag from '@/common/components/countryFlags/FrenchFlag';
+import Code from '@/common/components/dataDisplay/Code';
+import ExternalLink from '@/common/components/dataDisplay/ExternalLink';
+import { OnlyBrowserPageProps } from '@/layouts/core/types/OnlyBrowserPageProps';
+import { SSGPageProps } from '@/layouts/core/types/SSGPageProps';
+import BuiltInUtilitiesSidebar from '@/layouts/demo/components/BuiltInUtilitiesSidebar';
+import DemoLayout from '@/layouts/demo/components/DemoLayout';
+import DemoPage from '@/layouts/demo/components/DemoPage';
+import {
+ getDemoStaticPaths,
+ getDemoStaticProps,
+} from '@/layouts/demo/demoSSG';
+import withApollo from '@/modules/core/gql/hocs/withApollo';
import { css } from '@emotion/react';
import { createLogger } from '@unly/utils-simple-logger';
import {
@@ -9,24 +25,7 @@ import {
import React from 'react';
import { Alert } from 'reactstrap';
-import BuiltInUtilitiesSidebar from '../../../../components/doc/BuiltInUtilitiesSidebar';
-import DocPage from '../../../../components/doc/DocPage';
-import DefaultLayout from '../../../../components/pageLayouts/DefaultLayout';
-import EnglishHybridFlag from '../../../../components/svg/EnglishHybridFlag';
-import EnglishUkFlag from '../../../../components/svg/EnglishUkFlag';
-import FrenchFlag from '../../../../components/svg/FrenchFlag';
-import Code from '../../../../components/utils/Code';
-import ExternalLink from '../../../../components/utils/ExternalLink';
-import withApollo from '../../../../hocs/withApollo';
-import { CommonServerSideParams } from '../../../../types/nextjs/CommonServerSideParams';
-import { OnlyBrowserPageProps } from '../../../../types/pageProps/OnlyBrowserPageProps';
-import { SSGPageProps } from '../../../../types/pageProps/SSGPageProps';
-import {
- getExamplesCommonStaticPaths,
- getExamplesCommonStaticProps,
-} from '../../../../utils/nextjs/SSG';
-
-const fileLabel = 'pages/[locale]/examples/built-in-utilities/svg-to-react';
+const fileLabel = 'pages/[locale]/demo/built-in-utilities/svg-to-react';
const logger = createLogger({ // eslint-disable-line no-unused-vars,@typescript-eslint/no-unused-vars
label: fileLabel,
});
@@ -35,7 +34,7 @@ const logger = createLogger({ // eslint-disable-line no-unused-vars,@typescript-
* Only executed on the server side at build time
* Necessary when a page has dynamic routes and uses "getStaticProps"
*/
-export const getStaticPaths: GetStaticPaths = getExamplesCommonStaticPaths;
+export const getStaticPaths: GetStaticPaths = getDemoStaticPaths;
/**
* Only executed on the server side at build time.
@@ -45,7 +44,7 @@ export const getStaticPaths: GetStaticPaths = getExample
* @see https://github.com/vercel/next.js/discussions/10949#discussioncomment-6884
* @see https://nextjs.org/docs/basic-features/data-fetching#getstaticprops-static-generation
*/
-export const getStaticProps: GetStaticProps = getExamplesCommonStaticProps;
+export const getStaticProps: GetStaticProps = getDemoStaticProps;
/**
* SSG pages are first rendered by the server (during static bundling)
@@ -59,7 +58,7 @@ type Props = {} & SSGPageProps>;
const SvgToReactPage: NextPage = (props): JSX.Element => {
return (
- = (props): JSX.Element => {
}}
Sidebar={BuiltInUtilitiesSidebar}
>
-
+
SVG to react component examples
If you use SVGs, you may want to easily convert those as React components so that they're easier to work with (custom props, dynamic colors/size, etc.).
That's what we did with the country flags:
-
-
-
+
+
+
It'd be very easy to update those components to add some additional capabilities, such as resizing them through props, because they're React components.
@@ -104,8 +103,8 @@ const SvgToReactPage: NextPage = (props): JSX.Element => {
Personally, we like to move them to src/components/svg, but feel free to do as you like.
-
-
+
+
);
};
diff --git a/src/pages/[locale]/examples/built-in-utilities/top-level-500-error.tsx b/src/pages/[locale]/demo/built-in-utilities/top-level-500-error.tsx
similarity index 72%
rename from src/pages/[locale]/examples/built-in-utilities/top-level-500-error.tsx
rename to src/pages/[locale]/demo/built-in-utilities/top-level-500-error.tsx
index c160142aa..4012f97c7 100644
--- a/src/pages/[locale]/examples/built-in-utilities/top-level-500-error.tsx
+++ b/src/pages/[locale]/demo/built-in-utilities/top-level-500-error.tsx
@@ -1,3 +1,13 @@
+import { CommonServerSideParams } from '@/app/types/CommonServerSideParams';
+import { OnlyBrowserPageProps } from '@/layouts/core/types/OnlyBrowserPageProps';
+import { SSGPageProps } from '@/layouts/core/types/SSGPageProps';
+import BuiltInUtilitiesSidebar from '@/layouts/demo/components/BuiltInUtilitiesSidebar';
+import DemoLayout from '@/layouts/demo/components/DemoLayout';
+import {
+ getDemoStaticPaths,
+ getDemoStaticProps,
+} from '@/layouts/demo/demoSSG';
+import withApollo from '@/modules/core/gql/hocs/withApollo';
import { isBrowser } from '@unly/utils';
import { createLogger } from '@unly/utils-simple-logger';
import {
@@ -8,18 +18,7 @@ import {
// eslint-disable-next-line @typescript-eslint/no-unused-vars,no-unused-vars
import React from 'react';
-import BuiltInUtilitiesSidebar from '../../../../components/doc/BuiltInUtilitiesSidebar';
-import DefaultLayout from '../../../../components/pageLayouts/DefaultLayout';
-import withApollo from '../../../../hocs/withApollo';
-import { CommonServerSideParams } from '../../../../types/nextjs/CommonServerSideParams';
-import { OnlyBrowserPageProps } from '../../../../types/pageProps/OnlyBrowserPageProps';
-import { SSGPageProps } from '../../../../types/pageProps/SSGPageProps';
-import {
- getExamplesCommonStaticPaths,
- getExamplesCommonStaticProps,
-} from '../../../../utils/nextjs/SSG';
-
-const fileLabel = 'pages/[locale]/examples/built-in-utilities/top-level-500-error';
+const fileLabel = 'pages/[locale]/demo/built-in-utilities/top-level-500-error';
const logger = createLogger({ // eslint-disable-line no-unused-vars,@typescript-eslint/no-unused-vars
label: fileLabel,
});
@@ -28,7 +27,7 @@ const logger = createLogger({ // eslint-disable-line no-unused-vars,@typescript-
* Only executed on the server side at build time
* Necessary when a page has dynamic routes and uses "getStaticProps"
*/
-export const getStaticPaths: GetStaticPaths = getExamplesCommonStaticPaths;
+export const getStaticPaths: GetStaticPaths = getDemoStaticPaths;
/**
* Only executed on the server side at build time.
@@ -38,7 +37,7 @@ export const getStaticPaths: GetStaticPaths = getExample
* @see https://github.com/vercel/next.js/discussions/10949#discussioncomment-6884
* @see https://nextjs.org/docs/basic-features/data-fetching#getstaticprops-static-generation
*/
-export const getStaticProps: GetStaticProps = getExamplesCommonStaticProps;
+export const getStaticProps: GetStaticProps = getDemoStaticProps;
/**
* SSG pages are first rendered by the server (during static bundling)
@@ -57,7 +56,7 @@ const TopLevel500ErrorPage: NextPage = (props): JSX.Element => {
}
return (
- = (props): JSX.Element => {
Sidebar={BuiltInUtilitiesSidebar}
>
Top-level 500 error example
-
+
);
};
diff --git a/src/pages/[locale]/examples/built-in-utilities/tracking-useless-re-renders.tsx b/src/pages/[locale]/demo/built-in-utilities/tracking-useless-re-renders.tsx
similarity index 80%
rename from src/pages/[locale]/examples/built-in-utilities/tracking-useless-re-renders.tsx
rename to src/pages/[locale]/demo/built-in-utilities/tracking-useless-re-renders.tsx
index 004892d3d..029bcdc75 100644
--- a/src/pages/[locale]/examples/built-in-utilities/tracking-useless-re-renders.tsx
+++ b/src/pages/[locale]/demo/built-in-utilities/tracking-useless-re-renders.tsx
@@ -1,3 +1,17 @@
+import { CommonServerSideParams } from '@/app/types/CommonServerSideParams';
+import Code from '@/common/components/dataDisplay/Code';
+import ExternalLink from '@/common/components/dataDisplay/ExternalLink';
+import { OnlyBrowserPageProps } from '@/layouts/core/types/OnlyBrowserPageProps';
+import { SSGPageProps } from '@/layouts/core/types/SSGPageProps';
+import BuiltInUtilitiesSidebar from '@/layouts/demo/components/BuiltInUtilitiesSidebar';
+import DemoLayout from '@/layouts/demo/components/DemoLayout';
+import DemoPage from '@/layouts/demo/components/DemoPage';
+import {
+ getDemoStaticPaths,
+ getDemoStaticProps,
+} from '@/layouts/demo/demoSSG';
+import withApollo from '@/modules/core/gql/hocs/withApollo';
+import I18nLink from '@/modules/core/i18n/components/I18nLink';
import { createLogger } from '@unly/utils-simple-logger';
import {
GetStaticPaths,
@@ -11,22 +25,7 @@ import {
Button,
} from 'reactstrap';
-import BuiltInUtilitiesSidebar from '../../../../components/doc/BuiltInUtilitiesSidebar';
-import DocPage from '../../../../components/doc/DocPage';
-import I18nLink from '../../../../components/i18n/I18nLink';
-import DefaultLayout from '../../../../components/pageLayouts/DefaultLayout';
-import Code from '../../../../components/utils/Code';
-import ExternalLink from '../../../../components/utils/ExternalLink';
-import withApollo from '../../../../hocs/withApollo';
-import { CommonServerSideParams } from '../../../../types/nextjs/CommonServerSideParams';
-import { OnlyBrowserPageProps } from '../../../../types/pageProps/OnlyBrowserPageProps';
-import { SSGPageProps } from '../../../../types/pageProps/SSGPageProps';
-import {
- getExamplesCommonStaticPaths,
- getExamplesCommonStaticProps,
-} from '../../../../utils/nextjs/SSG';
-
-const fileLabel = 'pages/[locale]/examples/built-in-utilities/tracking-useless-re-renders';
+const fileLabel = 'pages/[locale]/demo/built-in-utilities/tracking-useless-re-renders';
const logger = createLogger({ // eslint-disable-line no-unused-vars,@typescript-eslint/no-unused-vars
label: fileLabel,
});
@@ -35,7 +34,7 @@ const logger = createLogger({ // eslint-disable-line no-unused-vars,@typescript-
* Only executed on the server side at build time
* Necessary when a page has dynamic routes and uses "getStaticProps"
*/
-export const getStaticPaths: GetStaticPaths = getExamplesCommonStaticPaths;
+export const getStaticPaths: GetStaticPaths = getDemoStaticPaths;
/**
* Only executed on the server side at build time.
@@ -45,7 +44,7 @@ export const getStaticPaths: GetStaticPaths = getExample
* @see https://github.com/vercel/next.js/discussions/10949#discussioncomment-6884
* @see https://nextjs.org/docs/basic-features/data-fetching#getstaticprops-static-generation
*/
-export const getStaticProps: GetStaticProps = getExamplesCommonStaticProps;
+export const getStaticProps: GetStaticProps = getDemoStaticProps;
/**
* SSG pages are first rendered by the server (during static bundling)
@@ -59,7 +58,7 @@ type Props = {} & SSGPageProps>;
const TrackingUselessReRendersPage: NextPage = (props): JSX.Element => {
return (
- = (props): JSX.Element => {
}}
Sidebar={BuiltInUtilitiesSidebar}
>
-
+
Tracking useless re-renders examples, using why-did-you-render
@@ -134,8 +133,8 @@ const TrackingUselessReRendersPage: NextPage = (props): JSX.Element => {
Exactly, we actually made that exact mistake when writing NRN demo, and we thought that'd be a great example. (^_^)'
-
-
+
+
);
};
diff --git a/src/pages/[locale]/examples/index.tsx b/src/pages/[locale]/demo/index.tsx
similarity index 67%
rename from src/pages/[locale]/examples/index.tsx
rename to src/pages/[locale]/demo/index.tsx
index 64ac832dc..ab13cefda 100644
--- a/src/pages/[locale]/examples/index.tsx
+++ b/src/pages/[locale]/demo/index.tsx
@@ -1,3 +1,18 @@
+import { CommonServerSideParams } from '@/app/types/CommonServerSideParams';
+import { OnlyBrowserPageProps } from '@/layouts/core/types/OnlyBrowserPageProps';
+import { SSGPageProps } from '@/layouts/core/types/SSGPageProps';
+import BuiltInFeaturesSection from '@/layouts/demo/components/BuiltInFeaturesSection';
+import BuiltInUtilitiesSection from '@/layouts/demo/components/BuiltInUtilitiesSection';
+import DemoLayout from '@/layouts/demo/components/DemoLayout';
+import ExternalFeaturesSection from '@/layouts/demo/components/ExternalFeaturesSection';
+import IntroductionSection from '@/layouts/demo/components/IntroductionSection';
+import NativeFeaturesSection from '@/layouts/demo/components/NativeFeaturesSection';
+import {
+ getDemoStaticPaths,
+ getDemoStaticProps,
+} from '@/layouts/demo/demoSSG';
+import { LogEvent } from '@/modules/core/amplitude/types/Amplitude';
+import withApollo from '@/modules/core/gql/hocs/withApollo';
import { Amplitude } from '@amplitude/react-amplitude';
import { createLogger } from '@unly/utils-simple-logger';
import {
@@ -8,23 +23,7 @@ import {
// eslint-disable-next-line @typescript-eslint/no-unused-vars,no-unused-vars
import React from 'react';
-import BuiltInFeaturesSection from '../../../components/doc/BuiltInFeaturesSection';
-import BuiltInUtilitiesSection from '../../../components/doc/BuiltInUtilitiesSection';
-import ExternalFeaturesSection from '../../../components/doc/ExternalFeaturesSection';
-import IntroductionSection from '../../../components/doc/IntroductionSection';
-import NativeFeaturesSection from '../../../components/doc/NativeFeaturesSection';
-import DefaultLayout from '../../../components/pageLayouts/DefaultLayout';
-import withApollo from '../../../hocs/withApollo';
-import { LogEvent } from '../../../types/Amplitude';
-import { CommonServerSideParams } from '../../../types/nextjs/CommonServerSideParams';
-import { OnlyBrowserPageProps } from '../../../types/pageProps/OnlyBrowserPageProps';
-import { SSGPageProps } from '../../../types/pageProps/SSGPageProps';
-import {
- getExamplesCommonStaticPaths,
- getExamplesCommonStaticProps,
-} from '../../../utils/nextjs/SSG';
-
-const fileLabel = 'pages/[locale]/examples/index';
+const fileLabel = 'pages/[locale]/demo/index';
const logger = createLogger({ // eslint-disable-line no-unused-vars,@typescript-eslint/no-unused-vars
label: fileLabel,
});
@@ -33,7 +32,7 @@ const logger = createLogger({ // eslint-disable-line no-unused-vars,@typescript-
* Only executed on the server side at build time
* Necessary when a page has dynamic routes and uses "getStaticProps"
*/
-export const getStaticPaths: GetStaticPaths = getExamplesCommonStaticPaths;
+export const getStaticPaths: GetStaticPaths = getDemoStaticPaths;
/**
* Only executed on the server side at build time.
@@ -43,7 +42,7 @@ export const getStaticPaths: GetStaticPaths = getExample
* @see https://github.com/vercel/next.js/discussions/10949#discussioncomment-6884
* @see https://nextjs.org/docs/basic-features/data-fetching#getstaticprops-static-generation
*/
-export const getStaticProps: GetStaticProps = getExamplesCommonStaticProps;
+export const getStaticProps: GetStaticProps = getDemoStaticProps;
/**
* SSG pages are first rendered by the server (during static bundling)
@@ -57,7 +56,7 @@ type Props = {} & SSGPageProps>;
const ExampleHomePage: NextPage = (props): JSX.Element => {
return (
- = (props): JSX.Element => {
}
-
+
);
};
diff --git a/src/pages/[locale]/examples/native-features/example-optional-catch-all-routes/[[...slug]].tsx b/src/pages/[locale]/demo/native-features/example-optional-catch-all-routes/[[...slug]].tsx
similarity index 73%
rename from src/pages/[locale]/examples/native-features/example-optional-catch-all-routes/[[...slug]].tsx
rename to src/pages/[locale]/demo/native-features/example-optional-catch-all-routes/[[...slug]].tsx
index 9a0212112..88f5c64bc 100644
--- a/src/pages/[locale]/examples/native-features/example-optional-catch-all-routes/[[...slug]].tsx
+++ b/src/pages/[locale]/demo/native-features/example-optional-catch-all-routes/[[...slug]].tsx
@@ -1,3 +1,16 @@
+import { CommonServerSideParams } from '@/app/types/CommonServerSideParams';
+import { StaticPath } from '@/app/types/StaticPath';
+import { StaticPathsOutput } from '@/app/types/StaticPathsOutput';
+import { OnlyBrowserPageProps } from '@/layouts/core/types/OnlyBrowserPageProps';
+import { SSGPageProps } from '@/layouts/core/types/SSGPageProps';
+import DemoLayout from '@/layouts/demo/components/DemoLayout';
+import DemoPage from '@/layouts/demo/components/DemoPage';
+import NativeFeaturesSidebar from '@/layouts/demo/components/NativeFeaturesSidebar';
+import { getDemoStaticProps } from '@/layouts/demo/demoSSG';
+import withApollo from '@/modules/core/gql/hocs/withApollo';
+import I18nLink from '@/modules/core/i18n/components/I18nLink';
+import { supportedLocales } from '@/modules/core/i18n/i18nConfig';
+import { I18nLocale } from '@/modules/core/i18n/types/I18nLocale';
import { createLogger } from '@unly/utils-simple-logger';
import map from 'lodash.map';
import {
@@ -9,20 +22,8 @@ import { useRouter } from 'next/router';
// eslint-disable-next-line @typescript-eslint/no-unused-vars,no-unused-vars
import React from 'react';
import { Alert } from 'reactstrap';
-import DocPage from '../../../../../components/doc/DocPage';
-import NativeFeaturesSidebar from '../../../../../components/doc/NativeFeaturesSidebar';
-import I18nLink from '../../../../../components/i18n/I18nLink';
-import DefaultLayout from '../../../../../components/pageLayouts/DefaultLayout';
-import { supportedLocales } from '../../../../../i18nConfig';
-import { I18nLocale } from '../../../../../types/i18n/I18nLocale';
-import { CommonServerSideParams } from '../../../../../types/nextjs/CommonServerSideParams';
-import { StaticPath } from '../../../../../types/nextjs/StaticPath';
-import { StaticPathsOutput } from '../../../../../types/nextjs/StaticPathsOutput';
-import { OnlyBrowserPageProps } from '../../../../../types/pageProps/OnlyBrowserPageProps';
-import { SSGPageProps } from '../../../../../types/pageProps/SSGPageProps';
-import { getExamplesCommonStaticProps } from '../../../../../utils/nextjs/SSG';
-const fileLabel = 'pages/[locale]/examples/native-features/example-optional-catch-all-routes/[[...slug]]';
+const fileLabel = 'pages/[locale]/demo/native-features/example-optional-catch-all-routes/[[...slug]]';
const logger = createLogger({ // eslint-disable-line no-unused-vars,@typescript-eslint/no-unused-vars
label: fileLabel,
});
@@ -59,7 +60,7 @@ export const getStaticPaths: GetStaticPaths = async ():
* @see https://github.com/vercel/next.js/discussions/10949#discussioncomment-6884
* @see https://nextjs.org/docs/basic-features/data-fetching#getstaticprops-static-generation
*/
-export const getStaticProps: GetStaticProps = getExamplesCommonStaticProps;
+export const getStaticProps: GetStaticProps = getDemoStaticProps;
/**
* SSG pages are first rendered by the server (during static bundling)
@@ -76,7 +77,7 @@ const ExampleWithCatchAllRoutesPage: NextPage = (props): JSX.Element => {
const { slug } = query;
return (
- = (props): JSX.Element => {
}}
Sidebar={NativeFeaturesSidebar}
>
-
+
Catch-all dynamic routes examples
@@ -93,7 +94,7 @@ const ExampleWithCatchAllRoutesPage: NextPage = (props): JSX.Element => {
URL slug parameters:{(slug as string[])?.join('/')}
- Go to some nested path
+ Go to some nested path
@@ -107,9 +108,9 @@ const ExampleWithCatchAllRoutesPage: NextPage = (props): JSX.Element => {
Make sure you use fallback: true
{' '}when using SSG, otherwise it'll generate a 404 page, and won't be able to dynamically generate the page.
-
-
+
+
);
};
-export default (ExampleWithCatchAllRoutesPage);
+export default withApollo()(ExampleWithCatchAllRoutesPage);
diff --git a/src/pages/[locale]/examples/native-features/example-with-ssg-and-fallback/[albumId].tsx b/src/pages/[locale]/demo/native-features/example-with-ssg-and-fallback/[albumId].tsx
similarity index 81%
rename from src/pages/[locale]/examples/native-features/example-with-ssg-and-fallback/[albumId].tsx
rename to src/pages/[locale]/demo/native-features/example-with-ssg-and-fallback/[albumId].tsx
index 61a414111..90e3d756b 100644
--- a/src/pages/[locale]/examples/native-features/example-with-ssg-and-fallback/[albumId].tsx
+++ b/src/pages/[locale]/demo/native-features/example-with-ssg-and-fallback/[albumId].tsx
@@ -1,3 +1,22 @@
+import { CommonServerSideParams } from '@/app/types/CommonServerSideParams';
+import { StaticPath } from '@/app/types/StaticPath';
+import { StaticPathsOutput } from '@/app/types/StaticPathsOutput';
+import { StaticPropsInput } from '@/app/types/StaticPropsInput';
+import Btn from '@/common/components/dataDisplay/Btn';
+import ExternalLink from '@/common/components/dataDisplay/ExternalLink';
+import waitFor from '@/common/utils/waitFor';
+import { OnlyBrowserPageProps } from '@/layouts/core/types/OnlyBrowserPageProps';
+import { SSGPageProps } from '@/layouts/core/types/SSGPageProps';
+import DemoLayout from '@/layouts/demo/components/DemoLayout';
+import NativeFeaturesSidebar from '@/layouts/demo/components/NativeFeaturesSidebar';
+import {
+ getDemoStaticPaths,
+ getDemoStaticProps,
+} from '@/layouts/demo/demoSSG';
+import withApollo from '@/modules/core/gql/hocs/withApollo';
+import I18nLink from '@/modules/core/i18n/components/I18nLink';
+import { getRandomInt } from '@/modules/core/js/random';
+import songs from '@/modules/core/testing/mocks/songs';
import { css } from '@emotion/react';
import { createLogger } from '@unly/utils-simple-logger';
import deepmerge from 'deepmerge';
@@ -13,27 +32,7 @@ import {
import React from 'react';
import { Alert } from 'reactstrap';
-import NativeFeaturesSidebar from '../../../../../components/doc/NativeFeaturesSidebar';
-import I18nLink from '../../../../../components/i18n/I18nLink';
-import DefaultLayout from '../../../../../components/pageLayouts/DefaultLayout';
-import Btn from '../../../../../components/utils/Btn';
-import ExternalLink from '../../../../../components/utils/ExternalLink';
-import withApollo from '../../../../../hocs/withApollo';
-import songs from '../../../../../mocks/songs';
-import { CommonServerSideParams } from '../../../../../types/nextjs/CommonServerSideParams';
-import { StaticPath } from '../../../../../types/nextjs/StaticPath';
-import { StaticPathsOutput } from '../../../../../types/nextjs/StaticPathsOutput';
-import { StaticPropsInput } from '../../../../../types/nextjs/StaticPropsInput';
-import { OnlyBrowserPageProps } from '../../../../../types/pageProps/OnlyBrowserPageProps';
-import { SSGPageProps } from '../../../../../types/pageProps/SSGPageProps';
-import { getRandomInt } from '../../../../../utils/math/random';
-import {
- getExamplesCommonStaticPaths,
- getExamplesCommonStaticProps,
-} from '../../../../../utils/nextjs/SSG';
-import waitFor from '../../../../../utils/timers/waitFor';
-
-const fileLabel = 'pages/[locale]/examples/native-features/example-with-ssg-and-fallback/[albumId]';
+const fileLabel = 'pages/[locale]/demo/native-features/example-with-ssg-and-fallback/[albumId]';
const logger = createLogger({ // eslint-disable-line no-unused-vars,@typescript-eslint/no-unused-vars
label: fileLabel,
});
@@ -47,7 +46,7 @@ type PageAdditionalServerSideParams = {
* Necessary when a page has dynamic routes and uses "getStaticProps"
*/
export const getStaticPaths: GetStaticPaths = async (context: GetStaticPathsContext): Promise> => {
- const commonStaticPaths: StaticPathsOutput = await getExamplesCommonStaticPaths(context) as StaticPathsOutput;
+ const commonStaticPaths: StaticPathsOutput = await getDemoStaticPaths(context) as StaticPathsOutput;
const { paths } = commonStaticPaths;
const albumIdsToPreBuild = ['1']; // Only '/album-1-with-ssg-and-fallback' is generated at build time, other will be generated on-demand
@@ -74,7 +73,7 @@ export const getStaticPaths: GetStaticPaths = async (con
* @see https://nextjs.org/docs/basic-features/data-fetching#getstaticprops-static-generation
*/
export const getStaticProps: GetStaticProps = async (props: StaticPropsInput): Promise> => {
- const commonStaticProps: GetStaticPropsResult = await getExamplesCommonStaticProps(props);
+ const commonStaticProps: GetStaticPropsResult = await getDemoStaticProps(props);
const { params: { albumId } } = props;
// Simulate API call by awaiting
@@ -140,7 +139,7 @@ const ExampleWithSSGAndFallbackAlbumPage: NextPage = (props): JSX.Element
} = album;
return (
- = (props): JSX.Element
{
id > 0 && (
= (props): JSX.Element
{' | '}
= (props): JSX.Element
-
+ Go to next+2 album (opens new tab)
@@ -251,7 +250,7 @@ const ExampleWithSSGAndFallbackAlbumPage: NextPage = (props): JSX.Element
-
+
);
};
diff --git a/src/pages/[locale]/examples/native-features/example-with-ssg-and-revalidate.tsx b/src/pages/[locale]/demo/native-features/example-with-ssg-and-revalidate.tsx
similarity index 79%
rename from src/pages/[locale]/examples/native-features/example-with-ssg-and-revalidate.tsx
rename to src/pages/[locale]/demo/native-features/example-with-ssg-and-revalidate.tsx
index d734d6e81..bfa4d25b4 100644
--- a/src/pages/[locale]/examples/native-features/example-with-ssg-and-revalidate.tsx
+++ b/src/pages/[locale]/demo/native-features/example-with-ssg-and-revalidate.tsx
@@ -1,5 +1,26 @@
+import { CommonServerSideParams } from '@/app/types/CommonServerSideParams';
+import { StaticPropsInput } from '@/app/types/StaticPropsInput';
+import AllProducts from '@/common/components/dataDisplay/AllProducts';
+import ExternalLink from '@/common/components/dataDisplay/ExternalLink';
+import DisplayOnBrowserMount from '@/common/components/rehydration/DisplayOnBrowserMount';
+import { OnlyBrowserPageProps } from '@/layouts/core/types/OnlyBrowserPageProps';
+import { SSGPageProps } from '@/layouts/core/types/SSGPageProps';
+import DemoLayout from '@/layouts/demo/components/DemoLayout';
+import NativeFeaturesSidebar from '@/layouts/demo/components/NativeFeaturesSidebar';
+import {
+ getDemoStaticPaths,
+ getDemoStaticProps,
+} from '@/layouts/demo/demoSSG';
+import { Product } from '@/modules/core/data/types/Product';
+import timeDifference from '@/modules/core/date/timeDifference';
+import createApolloClient from '@/modules/core/gql/graphql';
+import withApollo from '@/modules/core/gql/hocs/withApollo';
+import useI18n, { I18n } from '@/modules/core/i18n/hooks/useI18n';
import { createLogger } from '@unly/utils-simple-logger';
-import { ApolloQueryResult, QueryOptions } from 'apollo-client';
+import {
+ ApolloQueryResult,
+ QueryOptions,
+} from 'apollo-client';
import deepmerge from 'deepmerge';
import size from 'lodash.size';
import {
@@ -14,28 +35,9 @@ import {
Alert,
Container,
} from 'reactstrap';
+import { EXAMPLE_WITH_SSG_QUERY } from '../../../../gql/pages/demo/native-features/example-with-ssg';
-import AllProducts from '../../../../components/data/AllProducts';
-import NativeFeaturesSidebar from '../../../../components/doc/NativeFeaturesSidebar';
-import DefaultLayout from '../../../../components/pageLayouts/DefaultLayout';
-import DisplayOnBrowserMount from '../../../../components/rehydration/DisplayOnBrowserMount';
-import ExternalLink from '../../../../components/utils/ExternalLink';
-import { EXAMPLE_WITH_SSG_QUERY } from '../../../../gql/pages/examples/native-features/example-with-ssg';
-import withApollo from '../../../../hocs/withApollo';
-import useI18n, { I18n } from '../../../../hooks/useI18n';
-import { Product } from '../../../../types/data/Product';
-import { CommonServerSideParams } from '../../../../types/nextjs/CommonServerSideParams';
-import { StaticPropsInput } from '../../../../types/nextjs/StaticPropsInput';
-import { OnlyBrowserPageProps } from '../../../../types/pageProps/OnlyBrowserPageProps';
-import { SSGPageProps } from '../../../../types/pageProps/SSGPageProps';
-import { createApolloClient } from '../../../../utils/gql/graphql';
-import {
- getExamplesCommonStaticPaths,
- getExamplesCommonStaticProps,
-} from '../../../../utils/nextjs/SSG';
-import timeDifference from '../../../../utils/time/timeDifference';
-
-const fileLabel = 'pages/[locale]/examples/native-features/example-with-ssg-and-revalidate';
+const fileLabel = 'pages/[locale]/demo/native-features/example-with-ssg-and-revalidate';
const logger = createLogger({ // eslint-disable-line no-unused-vars,@typescript-eslint/no-unused-vars
label: fileLabel,
});
@@ -46,7 +48,7 @@ const regenerationDelay = 30; // Seconds
* Only executed on the server side at build time
* Necessary when a page has dynamic routes and uses "getStaticProps"
*/
-export const getStaticPaths: GetStaticPaths = getExamplesCommonStaticPaths;
+export const getStaticPaths: GetStaticPaths = getDemoStaticPaths;
/**
* Only executed on the server side at build time.
@@ -57,10 +59,13 @@ export const getStaticPaths: GetStaticPaths = getExample
* @see https://nextjs.org/docs/basic-features/data-fetching#getstaticprops-static-generation
*/
export const getStaticProps: GetStaticProps = async (props: StaticPropsInput): Promise> => {
- const commonStaticProps: GetStaticPropsResult = await getExamplesCommonStaticProps(props);
+ const commonStaticProps: GetStaticPropsResult = await getDemoStaticProps(props);
if ('props' in commonStaticProps) {
- const { customerRef, gcmsLocales } = commonStaticProps.props;
+ const {
+ customerRef,
+ gcmsLocales,
+ } = commonStaticProps.props;
const apolloClient = createApolloClient();
const variables = {
@@ -134,11 +139,14 @@ type Props = {
} & SSGPageProps>;
const ProductsWithSSGPage: NextPage = (props): JSX.Element => {
- const { products, builtAt } = props;
+ const {
+ products,
+ builtAt,
+ } = props;
const { locale }: I18n = useI18n();
return (
- = (props): JSX.Element => {
The page was built at: {builtAt} ({timeDifference(new Date(), new Date(builtAt))})
{' - '}
- Refresh
+ Refresh
@@ -184,7 +192,7 @@ const ProductsWithSSGPage: NextPage = (props): JSX.Element => {
-
+
);
};
diff --git a/src/pages/[locale]/examples/native-features/example-with-ssg.tsx b/src/pages/[locale]/demo/native-features/example-with-ssg.tsx
similarity index 77%
rename from src/pages/[locale]/examples/native-features/example-with-ssg.tsx
rename to src/pages/[locale]/demo/native-features/example-with-ssg.tsx
index 6490d0999..9c4ca1689 100644
--- a/src/pages/[locale]/examples/native-features/example-with-ssg.tsx
+++ b/src/pages/[locale]/demo/native-features/example-with-ssg.tsx
@@ -1,5 +1,26 @@
+import { CommonServerSideParams } from '@/app/types/CommonServerSideParams';
+import { StaticPropsInput } from '@/app/types/StaticPropsInput';
+import AllProducts from '@/common/components/dataDisplay/AllProducts';
+import ExternalLink from '@/common/components/dataDisplay/ExternalLink';
+import { OnlyBrowserPageProps } from '@/layouts/core/types/OnlyBrowserPageProps';
+import { SSGPageProps } from '@/layouts/core/types/SSGPageProps';
+import DemoLayout from '@/layouts/demo/components/DemoLayout';
+import NativeFeaturesSidebar from '@/layouts/demo/components/NativeFeaturesSidebar';
+import {
+ getDemoStaticPaths,
+ getDemoStaticProps,
+} from '@/layouts/demo/demoSSG';
+import { Product } from '@/modules/core/data/types/Product';
+import createApolloClient from '@/modules/core/gql/graphql';
+import withApollo from '@/modules/core/gql/hocs/withApollo';
+import I18nLink from '@/modules/core/i18n/components/I18nLink';
+import { SUPPORTED_LOCALES } from '@/modules/core/i18n/i18n';
+import { I18nLocale } from '@/modules/core/i18n/types/I18nLocale';
import { createLogger } from '@unly/utils-simple-logger';
-import { ApolloQueryResult, QueryOptions } from 'apollo-client';
+import {
+ ApolloQueryResult,
+ QueryOptions,
+} from 'apollo-client';
import deepmerge from 'deepmerge';
import map from 'lodash.map';
import size from 'lodash.size';
@@ -15,28 +36,9 @@ import {
Alert,
Container,
} from 'reactstrap';
+import { EXAMPLE_WITH_SSG_QUERY } from '../../../../gql/pages/demo/native-features/example-with-ssg';
-import AllProducts from '../../../../components/data/AllProducts';
-import NativeFeaturesSidebar from '../../../../components/doc/NativeFeaturesSidebar';
-import I18nLink from '../../../../components/i18n/I18nLink';
-import DefaultLayout from '../../../../components/pageLayouts/DefaultLayout';
-import ExternalLink from '../../../../components/utils/ExternalLink';
-import { EXAMPLE_WITH_SSG_QUERY } from '../../../../gql/pages/examples/native-features/example-with-ssg';
-import withApollo from '../../../../hocs/withApollo';
-import { Product } from '../../../../types/data/Product';
-import { I18nLocale } from '../../../../types/i18n/I18nLocale';
-import { CommonServerSideParams } from '../../../../types/nextjs/CommonServerSideParams';
-import { StaticPropsInput } from '../../../../types/nextjs/StaticPropsInput';
-import { OnlyBrowserPageProps } from '../../../../types/pageProps/OnlyBrowserPageProps';
-import { SSGPageProps } from '../../../../types/pageProps/SSGPageProps';
-import { createApolloClient } from '../../../../utils/gql/graphql';
-import { SUPPORTED_LOCALES } from '../../../../utils/i18n/i18n';
-import {
- getExamplesCommonStaticPaths,
- getExamplesCommonStaticProps,
-} from '../../../../utils/nextjs/SSG';
-
-const fileLabel = 'pages/[locale]/examples/native-features/example-with-ssg';
+const fileLabel = 'pages/[locale]/demo/native-features/example-with-ssg';
const logger = createLogger({ // eslint-disable-line no-unused-vars,@typescript-eslint/no-unused-vars
label: fileLabel,
});
@@ -45,7 +47,7 @@ const logger = createLogger({ // eslint-disable-line no-unused-vars,@typescript-
* Only executed on the server side at build time
* Necessary when a page has dynamic routes and uses "getStaticProps"
*/
-export const getStaticPaths: GetStaticPaths = getExamplesCommonStaticPaths;
+export const getStaticPaths: GetStaticPaths = getDemoStaticPaths;
/**
* Only executed on the server side at build time.
@@ -56,10 +58,13 @@ export const getStaticPaths: GetStaticPaths = getExample
* @see https://nextjs.org/docs/basic-features/data-fetching#getstaticprops-static-generation
*/
export const getStaticProps: GetStaticProps = async (props: StaticPropsInput): Promise> => {
- const commonStaticProps: GetStaticPropsResult = await getExamplesCommonStaticProps(props);
+ const commonStaticProps: GetStaticPropsResult = await getDemoStaticProps(props);
if ('props' in commonStaticProps) {
- const { customerRef, gcmsLocales } = commonStaticProps.props;
+ const {
+ customerRef,
+ gcmsLocales,
+ } = commonStaticProps.props;
const apolloClient = createApolloClient();
const variables = {
@@ -132,7 +137,7 @@ const ExampleWithSSGPage: NextPage = (props): JSX.Element => {
const { products } = props;
return (
- = (props): JSX.Element => {
map(SUPPORTED_LOCALES, (locale: I18nLocale, i) => {
return (
- {locale.name}
+ {locale.name}
{
i + 1 !== size(SUPPORTED_LOCALES) && (
<> | >
@@ -172,7 +177,7 @@ const ExampleWithSSGPage: NextPage = (props): JSX.Element => {
If you use NRN Admin and update the products there,{' '}
then the products below will NOT be updated, because each page refresh will still fetch the static content, which was generated at build time.
- Therefore, changes there won't be reflected here. (but they'll be reflected on the SSR version though)
+ Therefore, changes there won't be reflected here. (but they'll be reflected on the SSR version though)
N.B: During development, the static page is automatically rebuilt when refreshing, so the above behaviour is only valid in staging/production stages.
@@ -181,7 +186,7 @@ const ExampleWithSSGPage: NextPage = (props): JSX.Element => {
-
+
);
};
diff --git a/src/pages/[locale]/examples/native-features/example-with-ssr.tsx b/src/pages/[locale]/demo/native-features/example-with-ssr.tsx
similarity index 85%
rename from src/pages/[locale]/examples/native-features/example-with-ssr.tsx
rename to src/pages/[locale]/demo/native-features/example-with-ssr.tsx
index 9e9ce1118..d417a8cb9 100644
--- a/src/pages/[locale]/examples/native-features/example-with-ssr.tsx
+++ b/src/pages/[locale]/demo/native-features/example-with-ssr.tsx
@@ -1,3 +1,21 @@
+import { CommonServerSideParams } from '@/app/types/CommonServerSideParams';
+import AllProducts from '@/common/components/dataDisplay/AllProducts';
+import ExternalLink from '@/common/components/dataDisplay/ExternalLink';
+import { OnlyBrowserPageProps } from '@/layouts/core/types/OnlyBrowserPageProps';
+import { SSGPageProps } from '@/layouts/core/types/SSGPageProps';
+import { SSRPageProps } from '@/layouts/core/types/SSRPageProps';
+import DemoLayout from '@/layouts/demo/components/DemoLayout';
+import NativeFeaturesSidebar from '@/layouts/demo/components/NativeFeaturesSidebar';
+import {
+ GetCommonServerSidePropsResults,
+ getDemoServerSideProps,
+} from '@/layouts/demo/demoSSR';
+import useDataset from '@/modules/core/data/hooks/useDataset';
+import { Customer } from '@/modules/core/data/types/Customer';
+import { GraphCMSDataset } from '@/modules/core/data/types/GraphCMSDataset';
+import { Product } from '@/modules/core/data/types/Product';
+import withApollo from '@/modules/core/gql/hocs/withApollo';
+import serializeSafe from '@/modules/core/serializeSafe/serializeSafe';
import { createLogger } from '@unly/utils-simple-logger';
import {
ApolloQueryResult,
@@ -16,29 +34,9 @@ import {
Alert,
Container,
} from 'reactstrap';
+import { EXAMPLE_WITH_SSR_QUERY } from '../../../../gql/pages/demo/native-features/example-with-ssr';
-import AllProducts from '../../../../components/data/AllProducts';
-import NativeFeaturesSidebar from '../../../../components/doc/NativeFeaturesSidebar';
-
-import DefaultLayout from '../../../../components/pageLayouts/DefaultLayout';
-import ExternalLink from '../../../../components/utils/ExternalLink';
-import { EXAMPLE_WITH_SSR_QUERY } from '../../../../gql/pages/examples/native-features/example-with-ssr';
-import withApollo from '../../../../hocs/withApollo';
-import useDataset from '../../../../hooks/useDataset';
-import { Customer } from '../../../../types/data/Customer';
-import { Product } from '../../../../types/data/Product';
-import { CommonServerSideParams } from '../../../../types/nextjs/CommonServerSideParams';
-import { OnlyBrowserPageProps } from '../../../../types/pageProps/OnlyBrowserPageProps';
-import { SSGPageProps } from '../../../../types/pageProps/SSGPageProps';
-import { SSRPageProps } from '../../../../types/pageProps/SSRPageProps';
-import { GraphCMSDataset } from '../../../../utils/graphCMSDataset/GraphCMSDataset';
-import serializeSafe from '../../../../utils/graphCMSDataset/serializeSafe';
-import {
- getCommonServerSideProps,
- GetCommonServerSidePropsResults,
-} from '../../../../utils/nextjs/SSR';
-
-const fileLabel = 'pages/[locale]/examples/native-features/example-with-ssr';
+const fileLabel = 'pages/[locale]/demo/native-features/example-with-ssr';
const logger = createLogger({ // eslint-disable-line no-unused-vars,@typescript-eslint/no-unused-vars
label: fileLabel,
});
@@ -58,7 +56,7 @@ type GetServerSidePageProps = CustomPageProps & SSRPageProps
* @param context
*/
export const getServerSideProps: GetServerSideProps = async (context: GetServerSidePropsContext): Promise> => {
- const commonServerSideProps: GetServerSidePropsResult> = await getCommonServerSideProps(context);
+ const commonServerSideProps: GetServerSidePropsResult> = await getDemoServerSideProps(context);
if ('props' in commonServerSideProps) {
@@ -141,7 +139,7 @@ const ProductsWithSSRPage: NextPage = (props): JSX.Element => {
const { products } = dataset;
return (
- = (props): JSX.Element => {
-
+
);
};
diff --git a/src/pages/[locale]/examples/native-features/index.tsx b/src/pages/[locale]/demo/native-features/index.tsx
similarity index 74%
rename from src/pages/[locale]/examples/native-features/index.tsx
rename to src/pages/[locale]/demo/native-features/index.tsx
index 0863ca001..742abb644 100644
--- a/src/pages/[locale]/examples/native-features/index.tsx
+++ b/src/pages/[locale]/demo/native-features/index.tsx
@@ -1,10 +1,9 @@
+import { CommonServerSideParams } from '@/app/types/CommonServerSideParams';
+import { SSGPageProps } from '@/layouts/core/types/SSGPageProps';
import {
GetStaticPaths,
GetStaticProps,
} from 'next';
-
-import { CommonServerSideParams } from '../../../../types/nextjs/CommonServerSideParams';
-import { SSGPageProps } from '../../../../types/pageProps/SSGPageProps';
import ExampleWithSSGPage, {
getStaticPaths as getStaticPathsHomePage,
getStaticProps as getStaticPropsHomePage,
diff --git a/src/pages/[locale]/index.tsx b/src/pages/[locale]/index.tsx
index 8802659f0..2df88e6c0 100644
--- a/src/pages/[locale]/index.tsx
+++ b/src/pages/[locale]/index.tsx
@@ -1,17 +1,16 @@
+import { CommonServerSideParams } from '@/app/types/CommonServerSideParams';
+import { SSGPageProps } from '@/layouts/core/types/SSGPageProps';
import {
GetStaticPaths,
GetStaticProps,
} from 'next';
-
-import { CommonServerSideParams } from '../../types/nextjs/CommonServerSideParams';
-import { SSGPageProps } from '../../types/pageProps/SSGPageProps';
import DocsHomePage, {
getStaticPaths as getStaticPathsHomePage,
getStaticProps as getStaticPropsHomePage,
-} from './examples/';
+} from './demo/';
/*
- XXX This page is an "alias", it basically imports the whole /examples/index page and export it back
+ XXX This page is an "alias", it basically imports the whole /demo/index page and export it back
It's a trick that is similar to a "url rewrite", and allows 2 different urls to serve the exact same content, without code duplication
We use it so that you can build your own /index page while keeping the docs available for later use
Check out /pageTemplateSSG for getting started with your own index page and override this one
diff --git a/src/pages/[locale]/pageTemplateSSG.tsx b/src/pages/[locale]/pageTemplateSSG.tsx
index 9720a90a0..ccc2eef9c 100644
--- a/src/pages/[locale]/pageTemplateSSG.tsx
+++ b/src/pages/[locale]/pageTemplateSSG.tsx
@@ -1,24 +1,22 @@
+import { CommonServerSideParams } from '@/app/types/CommonServerSideParams';
+import { OnlyBrowserPageProps } from '@/layouts/core/types/OnlyBrowserPageProps';
+import { SSGPageProps } from '@/layouts/core/types/SSGPageProps';
+import DefaultLayout from '@/layouts/default/components/DefaultLayout';
+import {
+ getDefaultStaticPaths,
+ getDefaultStaticProps,
+} from '@/layouts/default/defaultSSG';
+import useCustomer from '@/modules/core/data/hooks/useCustomer';
+import { Customer } from '@/modules/core/data/types/Customer';
+import withApollo from '@/modules/core/gql/hocs/withApollo';
import { createLogger } from '@unly/utils-simple-logger';
import {
GetStaticPaths,
GetStaticProps,
NextPage,
} from 'next';
-// eslint-disable-next-line @typescript-eslint/no-unused-vars,no-unused-vars
import React from 'react';
-import DefaultLayout from '../../components/pageLayouts/DefaultLayout';
-import withApollo from '../../hocs/withApollo';
-import useCustomer from '../../hooks/useCustomer';
-import { Customer } from '../../types/data/Customer';
-import { CommonServerSideParams } from '../../types/nextjs/CommonServerSideParams';
-import { OnlyBrowserPageProps } from '../../types/pageProps/OnlyBrowserPageProps';
-import { SSGPageProps } from '../../types/pageProps/SSGPageProps';
-import {
- getCommonStaticPaths,
- getCommonStaticProps,
-} from '../../utils/nextjs/SSG';
-
const fileLabel = 'pages/[locale]/pageTemplateSSG';
const logger = createLogger({ // eslint-disable-line no-unused-vars,@typescript-eslint/no-unused-vars
label: fileLabel,
@@ -28,7 +26,7 @@ const logger = createLogger({ // eslint-disable-line no-unused-vars,@typescript-
* Only executed on the server side at build time
* Necessary when a page has dynamic routes and uses "getStaticProps"
*/
-export const getStaticPaths: GetStaticPaths = getCommonStaticPaths;
+export const getStaticPaths: GetStaticPaths = getDefaultStaticPaths;
/**
* Only executed on the server side at build time.
@@ -38,7 +36,7 @@ export const getStaticPaths: GetStaticPaths = getCommonS
* @see https://github.com/vercel/next.js/discussions/10949#discussioncomment-6884
* @see https://nextjs.org/docs/basic-features/data-fetching#getstaticprops-static-generation
*/
-export const getStaticProps: GetStaticProps = getCommonStaticProps;
+export const getStaticProps: GetStaticProps = getDefaultStaticProps;
/**
* SSG pages are first rendered by the server (during static bundling)
diff --git a/src/pages/[locale]/pageTemplateSSR.tsx b/src/pages/[locale]/pageTemplateSSR.tsx
index bfc08b618..572a7736e 100644
--- a/src/pages/[locale]/pageTemplateSSR.tsx
+++ b/src/pages/[locale]/pageTemplateSSR.tsx
@@ -1,3 +1,14 @@
+import { CommonServerSideParams } from '@/app/types/CommonServerSideParams';
+import { OnlyBrowserPageProps } from '@/layouts/core/types/OnlyBrowserPageProps';
+import { SSGPageProps } from '@/layouts/core/types/SSGPageProps';
+import { SSRPageProps } from '@/layouts/core/types/SSRPageProps';
+import DefaultLayout from '@/layouts/default/components/DefaultLayout';
+import { getDefaultServerSideProps } from '@/layouts/default/defaultSSR';
+import { GetCommonServerSidePropsResults } from '@/layouts/demo/demoSSR';
+import useCustomer from '@/modules/core/data/hooks/useCustomer';
+import { Customer } from '@/modules/core/data/types/Customer';
+import withApollo from '@/modules/core/gql/hocs/withApollo';
+import serializeSafe from '@/modules/core/serializeSafe/serializeSafe';
import { createLogger } from '@unly/utils-simple-logger';
import { ApolloQueryResult } from 'apollo-client';
import {
@@ -6,23 +17,8 @@ import {
GetServerSidePropsResult,
NextPage,
} from 'next';
-// eslint-disable-next-line @typescript-eslint/no-unused-vars,no-unused-vars
import React from 'react';
-
-import DefaultLayout from '../../components/pageLayouts/DefaultLayout';
import { LAYOUT_QUERY } from '../../gql/common/layoutQuery';
-import withApollo from '../../hocs/withApollo';
-import useCustomer from '../../hooks/useCustomer';
-import { Customer } from '../../types/data/Customer';
-import { CommonServerSideParams } from '../../types/nextjs/CommonServerSideParams';
-import { OnlyBrowserPageProps } from '../../types/pageProps/OnlyBrowserPageProps';
-import { SSGPageProps } from '../../types/pageProps/SSGPageProps';
-import { SSRPageProps } from '../../types/pageProps/SSRPageProps';
-import serializeSafe from '../../utils/graphCMSDataset/serializeSafe';
-import {
- getCommonServerSideProps,
- GetCommonServerSidePropsResults,
-} from '../../utils/nextjs/SSR';
const fileLabel = 'pages/[locale]/pageTemplateSSR';
const logger = createLogger({ // eslint-disable-line no-unused-vars,@typescript-eslint/no-unused-vars
@@ -47,7 +43,7 @@ type GetServerSidePageProps = CustomPageProps & SSRPageProps
* @param context
*/
export const getServerSideProps: GetServerSideProps = async (context: GetServerSidePropsContext): Promise> => {
- const commonServerSideProps: GetServerSidePropsResult> = await getCommonServerSideProps(context);
+ const commonServerSideProps: GetServerSidePropsResult> = await getDefaultServerSideProps(context);
if ('props' in commonServerSideProps) {
const {
diff --git a/src/pages/[locale]/privacy.tsx b/src/pages/[locale]/privacy.tsx
index 3d55ae90b..4ff13f583 100644
--- a/src/pages/[locale]/privacy.tsx
+++ b/src/pages/[locale]/privacy.tsx
@@ -1,3 +1,17 @@
+import { CommonServerSideParams } from '@/app/types/CommonServerSideParams';
+import LegalContent from '@/common/components/dataDisplay/LegalContent';
+import { OnlyBrowserPageProps } from '@/layouts/core/types/OnlyBrowserPageProps';
+import { SSGPageProps } from '@/layouts/core/types/SSGPageProps';
+import DefaultLayout from '@/layouts/default/components/DefaultLayout';
+import {
+ getDefaultStaticPaths,
+ getDefaultStaticProps,
+} from '@/layouts/default/defaultSSG';
+import { AMPLITUDE_PAGES } from '@/modules/core/amplitude/amplitude';
+import useCustomer from '@/modules/core/data/hooks/useCustomer';
+import { Customer } from '@/modules/core/data/types/Customer';
+import withApollo from '@/modules/core/gql/hocs/withApollo';
+import { replaceAllOccurrences } from '@/modules/core/js/string';
import { createLogger } from '@unly/utils-simple-logger';
import {
GetStaticPaths,
@@ -6,19 +20,6 @@ import {
} from 'next';
// eslint-disable-next-line @typescript-eslint/no-unused-vars,no-unused-vars
import React from 'react';
-import DefaultLayout from '../../components/pageLayouts/DefaultLayout';
-import LegalContent from '../../components/utils/LegalContent';
-import useCustomer from '../../hooks/useCustomer';
-import { Customer } from '../../types/data/Customer';
-import { CommonServerSideParams } from '../../types/nextjs/CommonServerSideParams';
-import { OnlyBrowserPageProps } from '../../types/pageProps/OnlyBrowserPageProps';
-import { SSGPageProps } from '../../types/pageProps/SSGPageProps';
-import { AMPLITUDE_PAGES } from '../../utils/analytics/amplitude';
-import { replaceAllOccurrences } from '../../utils/js/string';
-import {
- getCommonStaticPaths,
- getCommonStaticProps,
-} from '../../utils/nextjs/SSG';
const fileLabel = 'pages/[locale]/privacy';
const logger = createLogger({ // eslint-disable-line no-unused-vars,@typescript-eslint/no-unused-vars
@@ -29,7 +30,7 @@ const logger = createLogger({ // eslint-disable-line no-unused-vars,@typescript-
* Only executed on the server side at build time
* Necessary when a page has dynamic routes and uses "getStaticProps"
*/
-export const getStaticPaths: GetStaticPaths = getCommonStaticPaths;
+export const getStaticPaths: GetStaticPaths = getDefaultStaticPaths;
/**
* Only executed on the server side at build time.
@@ -39,7 +40,7 @@ export const getStaticPaths: GetStaticPaths = getCommonS
* @see https://github.com/vercel/next.js/discussions/10949#discussioncomment-6884
* @see https://nextjs.org/docs/basic-features/data-fetching#getstaticprops-static-generation
*/
-export const getStaticProps: GetStaticProps = getCommonStaticProps;
+export const getStaticProps: GetStaticProps = getDefaultStaticProps;
/**
* SSG pages are first rendered by the server (during static bundling)
@@ -58,7 +59,10 @@ type Props = {} & SSGPageProps>;
*/
const PrivacyPage: NextPage = (props): JSX.Element => {
const customer: Customer = useCustomer();
- const { privacyDescription, serviceLabel } = customer || {};
+ const {
+ privacyDescription,
+ serviceLabel,
+ } = customer || {};
// Replace dynamic values (like "{customerLabel}") by their actual value
const privacy = replaceAllOccurrences(privacyDescription?.html, {
@@ -71,7 +75,7 @@ const PrivacyPage: NextPage = (props): JSX.Element => {
{...props}
pageName={AMPLITUDE_PAGES.PRIVACY_PAGE}
>
-
Field's value (fetched from Airtable API), as Long text (interpreted as Markdown):
+
Field's value (fetched from GraphCMS API), as Long text (interpreted as Markdown):
@@ -79,4 +83,4 @@ const PrivacyPage: NextPage = (props): JSX.Element => {
);
};
-export default (PrivacyPage);
+export default withApollo()(PrivacyPage);
diff --git a/src/pages/[locale]/terms.tsx b/src/pages/[locale]/terms.tsx
index 1a7cc798b..dec350d8f 100644
--- a/src/pages/[locale]/terms.tsx
+++ b/src/pages/[locale]/terms.tsx
@@ -1,3 +1,19 @@
+import { CommonServerSideParams } from '@/app/types/CommonServerSideParams';
+import { StaticPropsInput } from '@/app/types/StaticPropsInput';
+import LegalContent from '@/common/components/dataDisplay/LegalContent';
+import { OnlyBrowserPageProps } from '@/layouts/core/types/OnlyBrowserPageProps';
+import { SSGPageProps } from '@/layouts/core/types/SSGPageProps';
+import DefaultLayout from '@/layouts/default/components/DefaultLayout';
+import {
+ getDefaultStaticPaths,
+ getDefaultStaticProps,
+} from '@/layouts/default/defaultSSG';
+import { AMPLITUDE_PAGES } from '@/modules/core/amplitude/amplitude';
+import useCustomer from '@/modules/core/data/hooks/useCustomer';
+import { Customer } from '@/modules/core/data/types/Customer';
+import createApolloClient from '@/modules/core/gql/graphql';
+import withApollo from '@/modules/core/gql/hocs/withApollo';
+import { replaceAllOccurrences } from '@/modules/core/js/string';
import { createLogger } from '@unly/utils-simple-logger';
import { ApolloQueryResult } from 'apollo-client';
import deepmerge from 'deepmerge';
@@ -9,23 +25,7 @@ import {
} from 'next';
// eslint-disable-next-line @typescript-eslint/no-unused-vars,no-unused-vars
import React from 'react';
-import DefaultLayout from '../../components/pageLayouts/DefaultLayout';
-import LegalContent from '../../components/utils/LegalContent';
import { TERMS_PAGE_QUERY } from '../../gql/pages/terms';
-import withApollo from '../../hocs/withApollo';
-import useCustomer from '../../hooks/useCustomer';
-import { Customer } from '../../types/data/Customer';
-import { CommonServerSideParams } from '../../types/nextjs/CommonServerSideParams';
-import { StaticPropsInput } from '../../types/nextjs/StaticPropsInput';
-import { OnlyBrowserPageProps } from '../../types/pageProps/OnlyBrowserPageProps';
-import { SSGPageProps } from '../../types/pageProps/SSGPageProps';
-import { createApolloClient } from '../../utils/gql/graphql';
-import { AMPLITUDE_PAGES } from '../../utils/analytics/amplitude';
-import { replaceAllOccurrences } from '../../utils/js/string';
-import {
- getCommonStaticPaths,
- getCommonStaticProps,
-} from '../../utils/nextjs/SSG';
const fileLabel = 'pages/[locale]/terms';
const logger = createLogger({ // eslint-disable-line no-unused-vars,@typescript-eslint/no-unused-vars
@@ -36,7 +36,7 @@ const logger = createLogger({ // eslint-disable-line no-unused-vars,@typescript-
* Only executed on the server side at build time
* Necessary when a page has dynamic routes and uses "getStaticProps"
*/
-export const getStaticPaths: GetStaticPaths = getCommonStaticPaths;
+export const getStaticPaths: GetStaticPaths = getDefaultStaticPaths;
/**
* Only executed on the server side at build time.
@@ -47,10 +47,13 @@ export const getStaticPaths: GetStaticPaths = getCommonS
* @see https://nextjs.org/docs/basic-features/data-fetching#getstaticprops-static-generation
*/
export const getStaticProps: GetStaticProps = async (props: StaticPropsInput): Promise> => {
- const commonStaticProps: GetStaticPropsResult = await getCommonStaticProps(props);
+ const commonStaticProps: GetStaticPropsResult = await getDefaultStaticProps(props);
if ('props' in commonStaticProps) {
- const { customerRef, gcmsLocales } = commonStaticProps.props;
+ const {
+ customerRef,
+ gcmsLocales,
+ } = commonStaticProps.props;
const apolloClient = createApolloClient();
const variables = {
customerRef,
@@ -112,7 +115,10 @@ type Props = {} & SSGPageProps>;
*/
const TermsPage: NextPage = (props): JSX.Element => {
const customer: Customer = useCustomer();
- const { termsDescription, serviceLabel } = customer || {};
+ const {
+ termsDescription,
+ serviceLabel,
+ } = customer || {};
// Replace dynamic values (like "{customerLabel}") by their actual value
const terms = replaceAllOccurrences(termsDescription?.html, {
diff --git a/src/pages/_app.tsx b/src/pages/_app.tsx
index b4ce673fe..7c13d150b 100644
--- a/src/pages/_app.tsx
+++ b/src/pages/_app.tsx
@@ -1,18 +1,18 @@
+import MultiversalAppBootstrap from '@/app/components/MultiversalAppBootstrap';
+import '@/app/components/MultiversalGlobalExternalStyles';
+import { MultiversalAppBootstrapProps } from '@/app/types/MultiversalAppBootstrapProps';
+import '@/common/utils/ignoreNoisyWarningsHacks'; // HACK This ignore warnings and errors I personally find too noisy and useless
+import { SSGPageProps } from '@/layouts/core/types/SSGPageProps';
+import { SSRPageProps } from '@/layouts/core/types/SSRPageProps';
+import { sendWebVitals } from '@/modules/core/amplitude/amplitude';
+import '@/modules/core/fontAwesome/fontAwesome';
+import '@/modules/core/sentry/sentry';
+import '@/modules/core/wdyr/wdyr';
+import { NextWebVitalsMetrics } from '@/modules/core/webVitals/types/NextWebVitalsMetrics';
+import { NextWebVitalsMetricsReport } from '@/modules/core/webVitals/types/NextWebVitalsMetricsReport';
import size from 'lodash.size';
import React from 'react';
import { v1 as uuid } from 'uuid'; // XXX Use v1 for uniqueness - See https://www.sohamkamani.com/blog/2016/10/05/uuid1-vs-uuid4/
-import MultiversalAppBootstrap from '../components/appBootstrap/MultiversalAppBootstrap';
-import '../components/appBootstrap/MultiversalGlobalExternalStyles';
-import { MultiversalAppBootstrapProps } from '../types/nextjs/MultiversalAppBootstrapProps';
-import { NextWebVitalsMetrics } from '../types/nextjs/NextWebVitalsMetrics';
-import { NextWebVitalsMetricsReport } from '../types/nextjs/NextWebVitalsMetricsReport';
-import { SSGPageProps } from '../types/pageProps/SSGPageProps';
-import { SSRPageProps } from '../types/pageProps/SSRPageProps';
-import { sendWebVitals } from '../utils/analytics/amplitude';
-import '../utils/app/ignoreNoisyWarningsHacks'; // HACK This ignore warnings and errors I personally find too noisy and useless
-import '../utils/icons/font-awesome';
-import '../utils/monitoring/sentry';
-import '../utils/wdyr';
/**
* "props.pageProps" will depend on whether the page is served by server or client, SSG or SSR
diff --git a/src/pages/_document.tsx b/src/pages/_document.tsx
index 61a8fb8a4..468311068 100644
--- a/src/pages/_document.tsx
+++ b/src/pages/_document.tsx
@@ -1,3 +1,4 @@
+import { DEFAULT_LOCALE } from '@/modules/core/i18n/i18n';
import * as Sentry from '@sentry/node';
import { createLogger } from '@unly/utils-simple-logger';
import classnames from 'classnames';
@@ -12,8 +13,6 @@ import Document, {
} from 'next/document';
import React from 'react';
-import { DEFAULT_LOCALE } from '../utils/i18n/i18n';
-
const fileLabel = 'pages/_document';
const logger = createLogger({
label: fileLabel,
diff --git a/src/pages/api/autoRedirectToLocalisedPage.ts b/src/pages/api/autoRedirectToLocalisedPage.ts
index 4cc5a8e79..b7f461468 100644
--- a/src/pages/api/autoRedirectToLocalisedPage.ts
+++ b/src/pages/api/autoRedirectToLocalisedPage.ts
@@ -1,10 +1,9 @@
+import localeMiddleware from '@/modules/core/i18n/middlewares/localeMiddleware';
import {
NextApiRequest,
NextApiResponse,
} from 'next';
-import localeMiddleware from '../../middlewares/localeMiddleware';
-
/**
* I18n language/locale auto-detection.
*
diff --git a/src/pages/api/error.test.ts b/src/pages/api/error.test.ts
index 6023694dc..507ac6a38 100644
--- a/src/pages/api/error.test.ts
+++ b/src/pages/api/error.test.ts
@@ -1,12 +1,11 @@
+import {
+ mockRequest,
+ mockResponse,
+} from '@/modules/core/testing/mocks/tests-mocks';
import {
NextApiRequest,
NextApiResponse,
} from 'next';
-
-import {
- mockRequest,
- mockResponse,
-} from '../../utils/testing/tests-mocks';
import error from './error';
/**
diff --git a/src/pages/api/error.ts b/src/pages/api/error.ts
index e49ae8a96..51be68773 100644
--- a/src/pages/api/error.ts
+++ b/src/pages/api/error.ts
@@ -1,11 +1,10 @@
+import Sentry, { configureReq } from '@/modules/core/sentry/sentry';
import { createLogger } from '@unly/utils-simple-logger';
import {
NextApiRequest,
NextApiResponse,
} from 'next';
-import Sentry, { configureReq } from '../../utils/monitoring/sentry';
-
const fileLabel = 'api/error';
const logger = createLogger({
label: fileLabel,
diff --git a/src/pages/api/preview.ts b/src/pages/api/preview.ts
index 0905eae31..a527eb587 100644
--- a/src/pages/api/preview.ts
+++ b/src/pages/api/preview.ts
@@ -1,3 +1,5 @@
+import { filterExternalAbsoluteUrl } from '@/modules/core/js/url';
+import Sentry, { configureReq } from '@/modules/core/sentry/sentry';
import { createLogger } from '@unly/utils-simple-logger';
import appendQueryParameter from 'append-query';
import {
@@ -5,9 +7,6 @@ import {
NextApiResponse,
} from 'next';
-import { filterExternalAbsoluteUrl } from '../../utils/js/url';
-import Sentry, { configureReq } from '../../utils/monitoring/sentry';
-
const fileLabel = 'api/preview';
const logger = createLogger({
label: fileLabel,
diff --git a/src/pages/api/startVercelDeployment.ts b/src/pages/api/startVercelDeployment.ts
index 54ebeaab0..8f0f660d0 100644
--- a/src/pages/api/startVercelDeployment.ts
+++ b/src/pages/api/startVercelDeployment.ts
@@ -1,16 +1,15 @@
+import redirect from '@/common/utils/redirect';
+import dispatchWorkflowByPath from '@/modules/core/githubActions/dispatchWorkflowByPath';
+import Sentry, {
+ ALERT_TYPES,
+ configureReq,
+} from '@/modules/core/sentry/sentry';
import { createLogger } from '@unly/utils-simple-logger';
import size from 'lodash.size';
import {
NextApiRequest,
NextApiResponse,
} from 'next';
-import redirect from '../../utils/app/redirect';
-import dispatchWorkflowByPath from '../../utils/gitHubActions/dispatchWorkflowByPath';
-
-import Sentry, {
- ALERT_TYPES,
- configureReq,
-} from '../../utils/monitoring/sentry';
const fileLabel = 'api/startVercelDeployment';
const logger = createLogger({
diff --git a/src/pages/api/status.test.ts b/src/pages/api/status.test.ts
index 91963f5cc..70dd660da 100644
--- a/src/pages/api/status.test.ts
+++ b/src/pages/api/status.test.ts
@@ -1,12 +1,11 @@
+import {
+ mockRequest,
+ mockResponse,
+} from '@/modules/core/testing/mocks/tests-mocks';
import {
NextApiRequest,
NextApiResponse,
} from 'next';
-
-import {
- mockRequest,
- mockResponse,
-} from '../../utils/testing/tests-mocks';
import status from './status';
/**
diff --git a/src/pages/api/status.ts b/src/pages/api/status.ts
index 6b171c430..646732aeb 100644
--- a/src/pages/api/status.ts
+++ b/src/pages/api/status.ts
@@ -1,11 +1,10 @@
+import Sentry, { configureReq } from '@/modules/core/sentry/sentry';
import { createLogger } from '@unly/utils-simple-logger';
import {
NextApiRequest,
NextApiResponse,
} from 'next';
-import Sentry, { configureReq } from '../../utils/monitoring/sentry';
-
const fileLabel = 'api/status';
const logger = createLogger({
label: fileLabel,
diff --git a/src/pages/api/webhooks/deploymentCompleted.ts b/src/pages/api/webhooks/deploymentCompleted.ts
index 57d2963ea..9d7971dd7 100644
--- a/src/pages/api/webhooks/deploymentCompleted.ts
+++ b/src/pages/api/webhooks/deploymentCompleted.ts
@@ -1,14 +1,13 @@
+import { convertRequestBodyToJSObject } from '@/modules/core/api/convertRequestBodyToJSObject';
+import Sentry, {
+ ALERT_TYPES,
+ configureReq,
+} from '@/modules/core/sentry/sentry';
import { createLogger } from '@unly/utils-simple-logger';
import {
NextApiRequest,
NextApiResponse,
} from 'next';
-import { convertRequestBodyToJSObject } from '../../../utils/api/convertRequestBodyToJSObject';
-
-import Sentry, {
- ALERT_TYPES,
- configureReq,
-} from '../../../utils/monitoring/sentry';
const fileLabel = 'api/webhooks/deploymentCompleted';
const logger = createLogger({
diff --git a/src/propTypes/GraphCMSAssetPropTypes.ts b/src/propTypes/GraphCMSAssetPropTypes.ts
deleted file mode 100644
index 72861f953..000000000
--- a/src/propTypes/GraphCMSAssetPropTypes.ts
+++ /dev/null
@@ -1,16 +0,0 @@
-import PropTypes from 'prop-types';
-import stylePropType from 'react-style-proptype';
-
-import GraphCMSAssetTransformationsPropTypes from './GraphCMSAssetTransformationsPropTypes';
-
-// Can't use any required field here, as this shape can be used for default values that won't specify props such as "url"
-export default {
- url: PropTypes.string,
- title: PropTypes.string,
- alt: PropTypes.string,
- classes: PropTypes.string,
- style: stylePropType,
- linkUrl: PropTypes.string,
- linkTarget: PropTypes.string,
- defaultTransformations: PropTypes.shape(GraphCMSAssetTransformationsPropTypes),
-};
diff --git a/src/propTypes/GraphCMSAssetTransformationsPropTypes.ts b/src/propTypes/GraphCMSAssetTransformationsPropTypes.ts
deleted file mode 100644
index 84344c8a2..000000000
--- a/src/propTypes/GraphCMSAssetTransformationsPropTypes.ts
+++ /dev/null
@@ -1,6 +0,0 @@
-import PropTypes from 'prop-types';
-
-export default {
- width: PropTypes.number,
- height: PropTypes.number,
-};
diff --git a/src/propTypes/LogoPropTypes.ts b/src/propTypes/LogoPropTypes.ts
deleted file mode 100644
index 44f41ceb6..000000000
--- a/src/propTypes/LogoPropTypes.ts
+++ /dev/null
@@ -1,31 +0,0 @@
-import PropTypes from 'prop-types';
-import stylePropType from 'react-style-proptype';
-
-export default {
- url: PropTypes.string,
- link: PropTypes.shape({
- url: PropTypes.string,
- target: PropTypes.string,
- classes: PropTypes.string,
- style: stylePropType,
- }),
- title: PropTypes.string,
- alt: PropTypes.string,
- width: PropTypes.oneOfType([
- PropTypes.number,
- PropTypes.string,
- ]),
- height: PropTypes.oneOfType([
- PropTypes.number,
- PropTypes.string,
- ]),
- classes: PropTypes.string,
- style: stylePropType,
- sizes: PropTypes.shape({
- xs: PropTypes.object, // ~20px
- sm: PropTypes.object, // ~50px
- md: PropTypes.object, // ~100px
- lg: PropTypes.object, // ~200px
- xl: PropTypes.object, // ~400px
- }),
-};
diff --git a/src/propTypes/README.md b/src/propTypes/README.md
deleted file mode 100644
index dad96e5d2..000000000
--- a/src/propTypes/README.md
+++ /dev/null
@@ -1,16 +0,0 @@
-# Proptypes (AKA "types of properties")
-
-> TLDR; Our decision is to prefer **TypeScript** over _PropTypes_.
-
-Prop types "_conflicts_" with TypeScript types because:
-- They **duplicate** information in a non-trivial way, you can't just copy/paste propTypes into TS types and converting them manually requires time
-- PropTypes run at **runtime**, unlike TS types which run at **compile time**
- - Typescript is useful when you are writing code: it will warn you if you pass an argument of the wrong type to your React components, give you autocomplete for function calls, etc.
- - PropTypes are useful when you test how the components interact with external data, for example when you load JSON from an API.
- PropTypes will help you debug (when in React's Development mode) why your component is failing by printing helpful messages like:
- > Warning: Failed prop type: Invalid prop `id` of type `number` supplied to `Table`, expected `string`
-
-We decided not to use PropTypes mostly because of the additional work which doesn't seem worth it.
-There are a few PropTypes being used, but they come from a time when we weren't using TS.
-
-Feel free to use both if you'd like to.
diff --git a/src/stories/README.md b/src/stories/README.md
new file mode 100644
index 000000000..e75cb23f9
--- /dev/null
+++ b/src/stories/README.md
@@ -0,0 +1,8 @@
+Storybook stories
+===
+
+> Check out the [documentation about the folder structure](../README.md#stories-folder)
+
+Summary:
+- This folder contains code that is used by Storybook.
+- The Next.js app doesn't use the code in this folder.
diff --git a/src/stories/nrn/animation/Animated3Dots.stories.tsx b/src/stories/nrn/animation/Animated3Dots.stories.tsx
index f9256819f..013918d66 100644
--- a/src/stories/nrn/animation/Animated3Dots.stories.tsx
+++ b/src/stories/nrn/animation/Animated3Dots.stories.tsx
@@ -3,7 +3,7 @@ import {
Story,
} from '@storybook/react/types-6-0';
import React from 'react';
-import Animated3Dots, { Props } from '../../../components/svg/Animated3Dots';
+import Animated3Dots, { Props } from '@/common/components/animations/Animated3Dots';
export default {
title: 'Next Right Now/Animation/Animated3Dots',
diff --git a/src/stories/nrn/animation/AnimatedTextBubble.stories.tsx b/src/stories/nrn/animation/AnimatedTextBubble.stories.tsx
index 1d314243a..00a2aad1d 100644
--- a/src/stories/nrn/animation/AnimatedTextBubble.stories.tsx
+++ b/src/stories/nrn/animation/AnimatedTextBubble.stories.tsx
@@ -3,7 +3,7 @@ import {
Story,
} from '@storybook/react/types-6-0';
import React from 'react';
-import AnimatedTextBubble, { Props } from '../../../components/svg/AnimatedTextBubble';
+import AnimatedTextBubble, { Props } from '@/common/components/animations/AnimatedTextBubble';
export default {
title: 'Next Right Now/Animation/AnimatedTextBubble',
diff --git a/src/stories/nrn/animation/BubbleTimer.stories.tsx b/src/stories/nrn/animation/BubbleTimer.stories.tsx
index 4a3bf1168..2c3693647 100644
--- a/src/stories/nrn/animation/BubbleTimer.stories.tsx
+++ b/src/stories/nrn/animation/BubbleTimer.stories.tsx
@@ -3,7 +3,7 @@ import {
Story,
} from '@storybook/react/types-6-0';
import React from 'react';
-import BubbleTimer, { Props } from '../../../components/utils/BubbleTimer';
+import BubbleTimer, { Props } from '@/common/components/dataDisplay/BubbleTimer';
export default {
title: 'Next Right Now/Animation/BubbleTimer',
diff --git a/src/stories/nrn/animation/Loader.stories.tsx b/src/stories/nrn/animation/Loader.stories.tsx
index ede3981d7..aaa31a87d 100644
--- a/src/stories/nrn/animation/Loader.stories.tsx
+++ b/src/stories/nrn/animation/Loader.stories.tsx
@@ -3,7 +3,7 @@ import {
Story,
} from '@storybook/react/types-6-0';
import React from 'react';
-import Loader, { Props } from '../../../components/animations/Loader';
+import Loader, { Props } from '@/common/components/animations/Loader';
export default {
title: 'Next Right Now/Animation/Loader',
diff --git a/src/stories/nrn/asset/GraphCMSAsset.stories.tsx b/src/stories/nrn/asset/GraphCMSAsset.stories.tsx
index b4f3ac262..e3bff0362 100644
--- a/src/stories/nrn/asset/GraphCMSAsset.stories.tsx
+++ b/src/stories/nrn/asset/GraphCMSAsset.stories.tsx
@@ -1,10 +1,10 @@
+import { Asset } from '@/modules/core/data/types/Asset';
+import GraphCMSAsset, { Props } from '@/modules/core/gql/components/GraphCMSAsset';
import {
Meta,
Story,
} from '@storybook/react/types-6-0';
import React from 'react';
-import GraphCMSAsset, { Props } from '../../../components/assets/GraphCMSAsset';
-import { Asset } from '../../../types/data/Asset';
const defaultLogoUrl = 'https://media.graphcms.com/EKw3Em7aRkqaYmowHWAN';
@@ -14,14 +14,14 @@ export default {
argTypes: {},
} as Meta;
-export const DynamicAirtableLogo: Story = (props) => {
+export const DynamicGraphCMSLogo: Story = (props) => {
return (
);
};
-DynamicAirtableLogo.args = {
+DynamicGraphCMSLogo.args = {
id: 'default-logo',
className: 'default-class',
asset: {
@@ -37,6 +37,6 @@ DynamicAirtableLogo.args = {
},
onClick: () => console.log('click on asset'),
};
-DynamicAirtableLogo.parameters = {
- jest: ['AirtableAsset.test.tsx'],
+DynamicGraphCMSLogo.parameters = {
+ jest: ['GraphCMSAsset.test.tsx'],
};
diff --git a/src/stories/nrn/dataDisplay/Btn.stories.tsx b/src/stories/nrn/dataDisplay/Btn.stories.tsx
index 9b8d982c8..c08d59f29 100644
--- a/src/stories/nrn/dataDisplay/Btn.stories.tsx
+++ b/src/stories/nrn/dataDisplay/Btn.stories.tsx
@@ -4,7 +4,7 @@ import {
Story,
} from '@storybook/react/types-6-0';
import React from 'react';
-import Btn, { Props } from '../../../components/utils/Btn';
+import Btn, { Props } from '@/common/components/dataDisplay/Btn';
import withPropMock from '../../shared/hocs/withPropMock';
type PropsWithChildrenMock = Props & {
diff --git a/src/stories/nrn/dataDisplay/CircleBtn.stories.tsx b/src/stories/nrn/dataDisplay/CircleBtn.stories.tsx
index 2826bba87..730bdf208 100644
--- a/src/stories/nrn/dataDisplay/CircleBtn.stories.tsx
+++ b/src/stories/nrn/dataDisplay/CircleBtn.stories.tsx
@@ -3,7 +3,7 @@ import {
Story,
} from '@storybook/react/types-6-0';
import React from 'react';
-import CircleBtn, { Props } from '../../../components/utils/CircleBtn';
+import CircleBtn, { Props } from '@/common/components/dataDisplay/CircleBtn';
import withPropMock from '../../shared/hocs/withPropMock';
type PropsWithChildrenMock = Props & {
diff --git a/src/stories/nrn/dataDisplay/Code.stories.tsx b/src/stories/nrn/dataDisplay/Code.stories.tsx
index 1ecac6c28..55e04e9eb 100644
--- a/src/stories/nrn/dataDisplay/Code.stories.tsx
+++ b/src/stories/nrn/dataDisplay/Code.stories.tsx
@@ -3,7 +3,7 @@ import {
Story,
} from '@storybook/react/types-6-0';
import React from 'react';
-import Code, { Props } from '../../../components/utils/Code';
+import Code, { Props } from '@/common/components/dataDisplay/Code';
export default {
title: 'Next Right Now/Data display/Code',
diff --git a/src/stories/nrn/dataDisplay/DocumentButton.stories.tsx b/src/stories/nrn/dataDisplay/DocumentButton.stories.tsx
index 0e188aacb..91c425768 100644
--- a/src/stories/nrn/dataDisplay/DocumentButton.stories.tsx
+++ b/src/stories/nrn/dataDisplay/DocumentButton.stories.tsx
@@ -3,7 +3,7 @@ import {
Story,
} from '@storybook/react/types-6-0';
import React from 'react';
-import DocumentButton, { Props } from '../../../components/utils/DocumentButton';
+import DocumentButton, { Props } from '@/common/components/dataDisplay/DocumentButton';
import withPropMock from '../../shared/hocs/withPropMock';
type PropsWithChildrenMock = Props & {
diff --git a/src/stories/nrn/dataDisplay/ExternalLink.stories.tsx b/src/stories/nrn/dataDisplay/ExternalLink.stories.tsx
index 429d01ae4..748d17d41 100644
--- a/src/stories/nrn/dataDisplay/ExternalLink.stories.tsx
+++ b/src/stories/nrn/dataDisplay/ExternalLink.stories.tsx
@@ -3,7 +3,7 @@ import {
Story,
} from '@storybook/react/types-6-0';
import React from 'react';
-import ExternalLink, { Props } from '../../../components/utils/ExternalLink';
+import ExternalLink, { Props } from '@/common/components/dataDisplay/ExternalLink';
import withPropMock from '../../shared/hocs/withPropMock';
type PropsWithChildrenMock = Props & {
diff --git a/src/stories/nrn/dataDisplay/LinkButton.stories.tsx b/src/stories/nrn/dataDisplay/LinkButton.stories.tsx
index c0a7f9ec0..5a9d54065 100644
--- a/src/stories/nrn/dataDisplay/LinkButton.stories.tsx
+++ b/src/stories/nrn/dataDisplay/LinkButton.stories.tsx
@@ -3,8 +3,8 @@ import {
Story,
} from '@storybook/react/types-6-0';
import React from 'react';
-import ExternalLink from '../../../components/utils/ExternalLink';
-import LinkButton, { Props } from '../../../components/utils/LinkButton';
+import ExternalLink from '@/common/components/dataDisplay/ExternalLink';
+import LinkButton, { Props } from '@/common/components/dataDisplay/LinkButton';
import withPropMock from '../../shared/hocs/withPropMock';
type PropsWithChildrenMock = Props & {
diff --git a/src/stories/nrn/dataDisplay/Markdown.stories.tsx b/src/stories/nrn/dataDisplay/Markdown.stories.tsx
index 9be71a102..e180f7b1f 100644
--- a/src/stories/nrn/dataDisplay/Markdown.stories.tsx
+++ b/src/stories/nrn/dataDisplay/Markdown.stories.tsx
@@ -3,7 +3,7 @@ import {
Story,
} from '@storybook/react/types-6-0';
import React from 'react';
-import Markdown, { Props } from '../../../components/utils/Markdown';
+import Markdown, { Props } from '@/common/components/dataDisplay/Markdown';
export default {
title: 'Next Right Now/Data display/Markdown',
diff --git a/src/stories/nrn/dataDisplay/SpoilerLink.stories.tsx b/src/stories/nrn/dataDisplay/SpoilerLink.stories.tsx
index 51d69069b..07d1df24f 100644
--- a/src/stories/nrn/dataDisplay/SpoilerLink.stories.tsx
+++ b/src/stories/nrn/dataDisplay/SpoilerLink.stories.tsx
@@ -3,8 +3,8 @@ import {
Story,
} from '@storybook/react/types-6-0';
import React from 'react';
-import Btn from '../../../components/utils/Btn';
-import SpoilerLink, { Props } from '../../../components/utils/SpoilerLink';
+import Btn from '@/common/components/dataDisplay/Btn';
+import SpoilerLink, { Props } from '@/common/components/dataDisplay/SpoilerLink';
export default {
title: 'Next Right Now/Data display/SpoilerLink',
diff --git a/src/stories/nrn/dataDisplay/Stamp.stories.tsx b/src/stories/nrn/dataDisplay/Stamp.stories.tsx
index 7778194e8..a934d05f1 100644
--- a/src/stories/nrn/dataDisplay/Stamp.stories.tsx
+++ b/src/stories/nrn/dataDisplay/Stamp.stories.tsx
@@ -3,8 +3,8 @@ import {
Story,
} from '@storybook/react/types-6-0';
import React from 'react';
-import EllipsisText from '../../../components/utils/EllipsisText';
-import Stamp, { Props } from '../../../components/utils/Stamp';
+import EllipsisText from '@/common/components/dataDisplay/EllipsisText';
+import Stamp, { Props } from '@/common/components/dataDisplay/Stamp';
import withPropMock from '../../shared/hocs/withPropMock';
type PropsWithChildrenMock = Props & {
diff --git a/src/stories/nrn/dataDisplay/Text.stories.tsx b/src/stories/nrn/dataDisplay/Text.stories.tsx
index 274f98b74..f4445ca53 100644
--- a/src/stories/nrn/dataDisplay/Text.stories.tsx
+++ b/src/stories/nrn/dataDisplay/Text.stories.tsx
@@ -3,7 +3,7 @@ import {
Story,
} from '@storybook/react/types-6-0';
import React from 'react';
-import Text, { Props } from '../../../components/utils/Text';
+import Text, { Props } from '@/common/components/dataDisplay/Text';
import withPropMock from '../../shared/hocs/withPropMock';
type PropsWithChildrenMock = Props & {
diff --git a/src/stories/nrn/dataDisplay/ToggleButton.stories.tsx b/src/stories/nrn/dataDisplay/ToggleButton.stories.tsx
index cc0e66a8e..b02485423 100644
--- a/src/stories/nrn/dataDisplay/ToggleButton.stories.tsx
+++ b/src/stories/nrn/dataDisplay/ToggleButton.stories.tsx
@@ -3,7 +3,7 @@ import {
Story,
} from '@storybook/react/types-6-0';
import React, { useState } from 'react';
-import ToggleButton, { Props } from '../../../components/utils/ToggleButton';
+import ToggleButton, { Props } from '@/common/components/dataDisplay/ToggleButton';
export default {
title: 'Next Right Now/Data display/ToggleButton',
diff --git a/src/stories/nrn/dataDisplay/ToggleLanguagesButton.stories.tsx b/src/stories/nrn/dataDisplay/ToggleLanguagesButton.stories.tsx
index fa2e2f76c..a03ced6bc 100644
--- a/src/stories/nrn/dataDisplay/ToggleLanguagesButton.stories.tsx
+++ b/src/stories/nrn/dataDisplay/ToggleLanguagesButton.stories.tsx
@@ -3,7 +3,7 @@ import {
Story,
} from '@storybook/react/types-6-0';
import React, { useState } from 'react';
-import ToggleLanguagesButton, { Props } from '../../../components/utils/ToggleLanguagesButton';
+import ToggleLanguagesButton, { Props } from '@/modules/core/i18n/components/ToggleLanguagesButton';
export default {
title: 'Next Right Now/Data display/ToggleLanguagesButton',
diff --git a/src/stories/nrn/i18n/I18nBtnChangeLocale.stories.tsx b/src/stories/nrn/i18n/I18nBtnChangeLocale.stories.tsx
index 615af9040..1a8acdf58 100644
--- a/src/stories/nrn/i18n/I18nBtnChangeLocale.stories.tsx
+++ b/src/stories/nrn/i18n/I18nBtnChangeLocale.stories.tsx
@@ -3,7 +3,7 @@ import {
Story,
} from '@storybook/react/types-6-0';
import React from 'react';
-import I18nBtnChangeLocale, { Props } from '../../../components/i18n/I18nBtnChangeLocale';
+import I18nBtnChangeLocale, { Props } from '@/modules/core/i18n/components/I18nBtnChangeLocale';
export default {
title: 'Next Right Now/I18n/I18nBtnChangeLocale',
diff --git a/src/stories/nrn/i18n/I18nLink.stories.tsx b/src/stories/nrn/i18n/I18nLink.stories.tsx
index 8363e3a02..a05596854 100644
--- a/src/stories/nrn/i18n/I18nLink.stories.tsx
+++ b/src/stories/nrn/i18n/I18nLink.stories.tsx
@@ -3,7 +3,7 @@ import {
Story,
} from '@storybook/react/types-6-0';
import React from 'react';
-import I18nLink, { Props } from '../../../components/i18n/I18nLink';
+import I18nLink, { Props } from '@/modules/core/i18n/components/I18nLink';
import withPropMock from '../../shared/hocs/withPropMock';
import styles from './I18nLink.module.css';
diff --git a/src/stories/nrn/layout/Cards.stories.tsx b/src/stories/nrn/layout/Cards.stories.tsx
index 00bd6fef5..073859fbb 100644
--- a/src/stories/nrn/layout/Cards.stories.tsx
+++ b/src/stories/nrn/layout/Cards.stories.tsx
@@ -11,10 +11,10 @@ import {
CardText,
CardTitle,
} from 'reactstrap';
-import I18nLink from '../../../components/i18n/I18nLink';
-import Btn from '../../../components/utils/Btn';
-import Cards, { Props } from '../../../components/utils/Cards';
-import ExternalLink from '../../../components/utils/ExternalLink';
+import I18nLink from '@/modules/core/i18n/components/I18nLink';
+import Btn from '@/common/components/dataDisplay/Btn';
+import Cards, { Props } from '@/common/components/dataDisplay/Cards';
+import ExternalLink from '@/common/components/dataDisplay/ExternalLink';
export default {
title: 'Next Right Now/Layout/Cards',
@@ -37,7 +37,7 @@ const Template: Story = (props) => {
Learn how to configure and use Vercel
-
+ Learn why we chose Vercel
@@ -57,7 +57,7 @@ const Template: Story = (props) => {
Learn how to configure Vercel secrets, using the CLI
-
+ Learn more about their usage and differences
@@ -94,7 +94,7 @@ const Template: Story = (props) => {
Learn how to setup CI/CD
-
+ See how to bypass automated CI/CD and deploy manually
@@ -114,7 +114,7 @@ const Template: Story = (props) => {
Learn how to use the "Locize" vendor
-
+ See usage examples
@@ -134,21 +134,7 @@ const Template: Story = (props) => {
Learn how to use the "Sentry" vendor
-
- See usage examples
-
-
-
-
-
-
-
-
-
API
- “API fetching using Amplitude vendor (REST))”
-
-
-
+ See usage examples
@@ -165,7 +151,7 @@ const Template: Story = (props) => {
Learn how to use the "Emotion" library
-
+ See usage examples
@@ -182,7 +168,7 @@ const Template: Story = (props) => {
Learn more about the "Cookie consent" library
-
+ Learn more about user consent and its impact on analytics
@@ -202,7 +188,7 @@ const Template: Story = (props) => {
Learn how to use the "Amplitude" vendor
-
+ See usage examples
@@ -236,7 +222,7 @@ const Template: Story = (props) => {
See all available FA icons
-
+ See usage examples
@@ -253,7 +239,7 @@ const Template: Story = (props) => {
See all available animations
-
+ See usage examples
@@ -270,7 +256,7 @@ const Template: Story = (props) => {
See all available Reactstrap components
-
+ See components examples
@@ -290,27 +276,13 @@ const Template: Story = (props) => {
Learn more about "just-the-docs" built-in template
-
+ Learn how to use it
-
-
-
-
Markdown as JSX components at runtime
- “Dynamically transform Markdown into JSX components at runtime”
-
-
-
- See usage examples
-
-
-
-
-
);
};
diff --git a/src/stories/nrn/layout/DefaultErrorLayout.stories.tsx b/src/stories/nrn/layout/DefaultErrorLayout.stories.tsx
index 715e9d93e..f94119af6 100644
--- a/src/stories/nrn/layout/DefaultErrorLayout.stories.tsx
+++ b/src/stories/nrn/layout/DefaultErrorLayout.stories.tsx
@@ -3,7 +3,7 @@ import {
Story,
} from '@storybook/react/types-6-0';
import React from 'react';
-import DefaultErrorLayout, { Props } from '../../../components/errors/DefaultErrorLayout';
+import DefaultErrorLayout, { Props } from '@/modules/core/errorHandling/DefaultErrorLayout';
export default {
title: 'Next Right Now/Layout/DefaultErrorLayout',
diff --git a/src/stories/nrn/layout/Footer.stories.tsx b/src/stories/nrn/layout/Footer.stories.tsx
index c8abb8478..861438e7a 100644
--- a/src/stories/nrn/layout/Footer.stories.tsx
+++ b/src/stories/nrn/layout/Footer.stories.tsx
@@ -3,16 +3,16 @@ import {
Story,
} from '@storybook/react/types-6-0';
import React from 'react';
-import Footer, { Props } from '../../../components/pageLayouts/Footer';
+import BaseFooter, { Props } from '@/layouts/core/components/Footer';
export default {
title: 'Next Right Now/Layout/Footer',
- component: Footer,
+ component: BaseFooter,
argTypes: {},
} as Meta;
export const DefaultExample: Story = () => {
return (
-
+
);
};
diff --git a/src/stories/nrn/layout/LegalContent.stories.tsx b/src/stories/nrn/layout/LegalContent.stories.tsx
index 788799594..3a56a20f0 100644
--- a/src/stories/nrn/layout/LegalContent.stories.tsx
+++ b/src/stories/nrn/layout/LegalContent.stories.tsx
@@ -3,7 +3,7 @@ import {
Story,
} from '@storybook/react/types-6-0';
import React from 'react';
-import LegalContent, { Props } from '../../../components/utils/LegalContent';
+import LegalContent, { Props } from '@/common/components/dataDisplay/LegalContent';
export default {
title: 'Next Right Now/Layout/LegalContent',
diff --git a/src/stories/nrn/layout/Nav.stories.tsx b/src/stories/nrn/layout/Nav.stories.tsx
index 08fad306e..f4d7307ab 100644
--- a/src/stories/nrn/layout/Nav.stories.tsx
+++ b/src/stories/nrn/layout/Nav.stories.tsx
@@ -3,7 +3,7 @@ import {
Story,
} from '@storybook/react/types-6-0';
import React from 'react';
-import Nav, { Props } from '../../../components/pageLayouts/Nav';
+import Nav, { Props } from '@/layouts/core/components/Nav';
export default {
title: 'Next Right Now/Layout/Nav',
diff --git a/src/stories/nrn/layout/PreviewModeBanner.stories.tsx b/src/stories/nrn/layout/PreviewModeBanner.stories.tsx
index cd52c4078..7a016c37d 100644
--- a/src/stories/nrn/layout/PreviewModeBanner.stories.tsx
+++ b/src/stories/nrn/layout/PreviewModeBanner.stories.tsx
@@ -3,7 +3,7 @@ import {
Story,
} from '@storybook/react/types-6-0';
import React from 'react';
-import PreviewModeBanner, { Props } from '../../../components/pageLayouts/PreviewModeBanner';
+import PreviewModeBanner, { Props } from '@/modules/core/previewMode/components/PreviewModeBanner';
export default {
title: 'Next Right Now/Layout/PreviewModeBanner',
diff --git a/src/stories/nrn/layout/QuickPreviewBanner.stories.tsx b/src/stories/nrn/layout/QuickPreviewBanner.stories.tsx
index fc84ab746..d58e1246f 100644
--- a/src/stories/nrn/layout/QuickPreviewBanner.stories.tsx
+++ b/src/stories/nrn/layout/QuickPreviewBanner.stories.tsx
@@ -3,7 +3,7 @@ import {
Story,
} from '@storybook/react/types-6-0';
import React from 'react';
-import QuickPreviewBanner, { Props } from '../../../components/pageLayouts/QuickPreviewBanner';
+import QuickPreviewBanner, { Props } from '@/modules/core/quickPreview/components/QuickPreviewBanner';
export default {
title: 'Next Right Now/Layout/QuickPreviewBanner',
diff --git a/src/stories/nrn/overlay/SimpleTooltip.stories.tsx b/src/stories/nrn/overlay/SimpleTooltip.stories.tsx
index f4ef16734..58ef2e71a 100644
--- a/src/stories/nrn/overlay/SimpleTooltip.stories.tsx
+++ b/src/stories/nrn/overlay/SimpleTooltip.stories.tsx
@@ -3,7 +3,7 @@ import {
Story,
} from '@storybook/react/types-6-0';
import React from 'react';
-import SimpleTooltip, { Props } from '../../../components/utils/SimpleTooltip';
+import SimpleTooltip, { Props } from '@/common/components/dataDisplay/SimpleTooltip';
import withPropMock from '../../shared/hocs/withPropMock';
type PropsWithChildrenMock = Props & {
diff --git a/src/stories/nrn/overlay/Tooltip.stories.tsx b/src/stories/nrn/overlay/Tooltip.stories.tsx
index d35b2c108..56cf26cf0 100644
--- a/src/stories/nrn/overlay/Tooltip.stories.tsx
+++ b/src/stories/nrn/overlay/Tooltip.stories.tsx
@@ -3,7 +3,7 @@ import {
Story,
} from '@storybook/react/types-6-0';
import React from 'react';
-import Tooltip, { Props } from '../../../components/utils/Tooltip';
+import Tooltip, { Props } from '@/common/components/dataDisplay/Tooltip';
import withPropMock from '../../shared/hocs/withPropMock';
type PropsWithChildrenMock = Props & {
diff --git a/src/stories/nrn/reactRehydration/DisplayOnBrowserMount.stories.tsx b/src/stories/nrn/reactRehydration/DisplayOnBrowserMount.stories.tsx
index 38add75a1..61b402ec2 100644
--- a/src/stories/nrn/reactRehydration/DisplayOnBrowserMount.stories.tsx
+++ b/src/stories/nrn/reactRehydration/DisplayOnBrowserMount.stories.tsx
@@ -3,7 +3,7 @@ import {
Story,
} from '@storybook/react/types-6-0';
import React from 'react';
-import DisplayOnBrowserMount, { Props } from '../../../components/rehydration/DisplayOnBrowserMount';
+import DisplayOnBrowserMount, { Props } from '@/common/components/rehydration/DisplayOnBrowserMount';
export default {
title: 'Next Right Now/React rehydration/DisplayOnBrowserMount',
diff --git a/src/stories/nrn/text/EllipsisText.stories.tsx b/src/stories/nrn/text/EllipsisText.stories.tsx
index 46cb02ec6..009cb90ce 100644
--- a/src/stories/nrn/text/EllipsisText.stories.tsx
+++ b/src/stories/nrn/text/EllipsisText.stories.tsx
@@ -3,7 +3,7 @@ import {
Story,
} from '@storybook/react/types-6-0';
import React from 'react';
-import EllipsisText, { Props } from '../../../components/utils/EllipsisText';
+import EllipsisText, { Props } from '@/common/components/dataDisplay/EllipsisText';
import withPropMock from '../../shared/hocs/withPropMock';
type PropsWithChildrenMock = Props & {
diff --git a/src/types/I18nMarkdown.ts b/src/types/I18nMarkdown.ts
deleted file mode 100644
index e5b07b9c1..000000000
--- a/src/types/I18nMarkdown.ts
+++ /dev/null
@@ -1,7 +0,0 @@
-import { Markdown } from './Markdown';
-
-/**
- * I18n markdown field auto computed by our own algorithm
- * (we don't use the Airtable field, it is calculated again instead in "sanitizeRecord")
- */
-export type I18nMarkdown = Markdown;
diff --git a/src/types/I18nString.ts b/src/types/I18nString.ts
deleted file mode 100644
index d367f3cf6..000000000
--- a/src/types/I18nString.ts
+++ /dev/null
@@ -1,5 +0,0 @@
-/**
- * I18n field auto computed by our own algorithm
- * (we don't use the Airtable field, it is calculated again instead in "sanitizeRecord")
- */
-export type I18nString = string;
diff --git a/src/utils/graphCMSDataset/deserializeSafe.ts b/src/utils/graphCMSDataset/deserializeSafe.ts
deleted file mode 100644
index 5286e4509..000000000
--- a/src/utils/graphCMSDataset/deserializeSafe.ts
+++ /dev/null
@@ -1,19 +0,0 @@
-import { parse as parseSafe } from 'flatted';
-
-/**
- * Deserializes a serialized dataset.
- *
- * The serialized dataset must be created using the Flatter library.
- *
- * @param serializedValue
- * @see serializeSafe
- */
-export const deserializeSafe = (serializedValue: string): T => {
- if(typeof serializedValue !== 'string'){
- throw new Error(`The deserialization expects the serializedValue to be of type "string, got ${typeof serializedValue}`);
- }
-
- return parseSafe(serializedValue);
-};
-
-export default deserializeSafe;
diff --git a/src/utils/graphCMSDataset/serializeSafe.ts b/src/utils/graphCMSDataset/serializeSafe.ts
deleted file mode 100644
index 107c92851..000000000
--- a/src/utils/graphCMSDataset/serializeSafe.ts
+++ /dev/null
@@ -1,23 +0,0 @@
-import { stringify as stringifySafe } from 'flatted';
-import { Flatted } from '../../types/Flatted';
-import { GenericObject } from '../../types/GenericObject';
-
-/**
- * Serializes a dataset.
- *
- * The dataset should be a JS object.
- * The serialized dataset must be deserialized using Flatted library.
- *
- * XXX Serializing objects when sharing them from server to browser is a very efficient way to avoid serialization errors.
- * When Next.js encounters a JS object that is returned as page props, it will serialize it automatically, using JSON.stringify.
- * But, JSON.stringify will fail if the object contains circular references.
- * Using Flatted is a more robust way to serialize data, and is required when using circular references.
- *
- * @param value
- * @see deserializeSafe
- */
-export const serializeSafe = (value: GenericObject | any[]): Flatted => {
- return stringifySafe(value);
-};
-
-export default serializeSafe;
diff --git a/src/utils/nextjs/SSG.ts b/src/utils/nextjs/SSG.ts
deleted file mode 100644
index b13899169..000000000
--- a/src/utils/nextjs/SSG.ts
+++ /dev/null
@@ -1,196 +0,0 @@
-import { ApolloQueryResult } from 'apollo-client';
-import map from 'lodash.map';
-import {
- GetStaticPaths,
- GetStaticPathsContext,
- GetStaticProps,
- GetStaticPropsResult,
-} from 'next';
-
-import { LAYOUT_QUERY } from '../../gql/common/layoutQuery';
-import { supportedLocales } from '../../i18nConfig';
-import { Customer } from '../../types/data/Customer';
-import { I18nLocale } from '../../types/i18n/I18nLocale';
-import { CommonServerSideParams } from '../../types/nextjs/CommonServerSideParams';
-import { PreviewData } from '../../types/nextjs/PreviewData';
-import { StaticPath } from '../../types/nextjs/StaticPath';
-import { StaticPathsOutput } from '../../types/nextjs/StaticPathsOutput';
-import { StaticPropsInput } from '../../types/nextjs/StaticPropsInput';
-import { SSGPageProps } from '../../types/pageProps/SSGPageProps';
-import { prepareGraphCMSLocaleHeader } from '../gql/graphcms';
-import { createApolloClient } from '../gql/graphql';
-import serializeSafe from '../graphCMSDataset/serializeSafe';
-import {
- DEFAULT_LOCALE,
- resolveFallbackLanguage,
-} from '../i18n/i18n';
-import {
- fetchTranslations,
- I18nextResources,
-} from '../i18n/i18nextLocize';
-
-/**
- * Only executed on the server side at build time.
- * Computes all static paths that should be available for all SSG pages
- * Necessary when a page has dynamic routes and uses "getStaticProps", in order to build the HTML pages
- *
- * You can use "fallback" option to avoid building all page variants and allow runtime fallback
- *
- * Meant to avoid code duplication
- * Can be overridden for per-page customisation (e.g: deepmerge)
- *
- * @return
- *
- * @see https://nextjs.org/docs/basic-features/data-fetching#getstaticpaths-static-generation
- */
-export const getCommonStaticPaths: GetStaticPaths = async (context: GetStaticPathsContext): Promise => {
- // TODO Make your own implementation.
- // XXX Having this as separate function helps making your own pages without affecting existing examples under "pages/[locale]/examples".
- // For instance, you may want to replace the GraphQL query by your own API query, while keeping the existing example pages working.
- // eslint-disable-next-line @typescript-eslint/no-use-before-define
- return getExamplesCommonStaticPaths(context);
-};
-
-/**
- * Only executed on the server side at build time.
- * Computes all static props that should be available for all SSG pages
- *
- * Note that when a page uses "getStaticProps", then "_app:getInitialProps" is executed (if defined) but not actually used by the page,
- * only the results from getStaticProps are actually injected into the page (as "SSGPageProps").
- *
- * Meant to avoid code duplication
- * Can be overridden for per-page customisation (e.g: deepmerge)
- *
- * @param props
- * @return Props (as "SSGPageProps") that will be passed to the Page component, as props
- *
- * @see https://github.com/vercel/next.js/discussions/10949#discussioncomment-6884
- * @see https://nextjs.org/docs/basic-features/data-fetching#getstaticprops-static-generation
- */
-export const getCommonStaticProps: GetStaticProps = async (props: StaticPropsInput): Promise> => {
- // TODO Make your own implementation.
- // XXX Having this as separate function helps making your own pages without affecting existing examples under "pages/[locale]/examples".
- // For instance, you may want to replace the GraphQL query by your own API query, while keeping the existing example pages working.
- // eslint-disable-next-line @typescript-eslint/no-use-before-define
- return getExamplesCommonStaticProps(props);
-};
-
-/**
- * XXX This method is meant for people creating their own project based on NRN.
- * It's meant to be deleted eventually when you don't need to keep the examples around.
- *
- * Only executed on the server side at build time.
- * Computes all static paths that should be available for all SSG pages
- * Necessary when a page has dynamic routes and uses "getStaticProps", in order to build the HTML pages
- *
- * You can use "fallback" option to avoid building all page variants and allow runtime fallback
- *
- * Meant to avoid code duplication
- * Can be overridden for per-page customisation (e.g: deepmerge)
- *
- * @return
- *
- * @see https://nextjs.org/docs/basic-features/data-fetching#getstaticpaths-static-generation
- */
-export const getExamplesCommonStaticPaths: GetStaticPaths = async (context: GetStaticPathsContext): Promise => {
- const paths: StaticPath[] = map(supportedLocales, (supportedLocale: I18nLocale): StaticPath => {
- return {
- params: {
- locale: supportedLocale.name,
- },
- };
- });
-
- return {
- fallback: false,
- paths,
- };
-};
-
-/**
- * XXX This method is meant for people creating their own project based on NRN.
- * It's meant to be deleted eventually when you don't need to keep the examples around.
- *
- * Only executed on the server side at build time.
- * Computes all static props that should be available for all SSG pages
- *
- * Note that when a page uses "getStaticProps", then "_app:getInitialProps" is executed (if defined) but not actually used by the page,
- * only the results from getStaticProps are actually injected into the page (as "SSGPageProps").
- *
- * Meant to avoid code duplication
- * Can be overridden for per-page customisation (e.g: deepmerge)
- *
- * @param props
- * @return Props (as "SSGPageProps") that will be passed to the Page component, as props
- *
- * @see https://github.com/vercel/next.js/discussions/10949#discussioncomment-6884
- * @see https://nextjs.org/docs/basic-features/data-fetching#getstaticprops-static-generation
- */
-export const getExamplesCommonStaticProps: GetStaticProps = async (props: StaticPropsInput): Promise> => {
- const customerRef: string = process.env.NEXT_PUBLIC_CUSTOMER_REF;
- const preview: boolean = props?.preview || false;
- const previewData: PreviewData = props?.previewData || null;
- const hasLocaleFromUrl = !!props?.params?.locale;
- const locale: string = hasLocaleFromUrl ? props?.params?.locale : DEFAULT_LOCALE; // If the locale isn't found (e.g: 404 page)
- const lang: string = locale.split('-')?.[0];
- const bestCountryCodes: string[] = [lang, resolveFallbackLanguage(lang)];
- const gcmsLocales: string = prepareGraphCMSLocaleHeader(bestCountryCodes);
- const i18nTranslations: I18nextResources = await fetchTranslations(lang); // Pre-fetches translations from Locize API
- const apolloClient = createApolloClient();
- const variables = {
- customerRef,
- };
- const queryOptions = {
- displayName: 'LAYOUT_QUERY',
- query: LAYOUT_QUERY,
- variables,
- context: {
- headers: {
- 'gcms-locales': gcmsLocales,
- },
- },
- };
-
- const {
- data,
- errors,
- loading,
- networkStatus,
- stale,
- }: ApolloQueryResult<{
- customer: Customer;
- }> = await apolloClient.query(queryOptions);
-
- if (errors) {
- console.error(errors);
- throw new Error('Errors were detected in GraphQL query.');
- }
-
- const {
- customer,
- } = data || {}; // XXX Use empty object as fallback, to avoid app crash when destructuring, if no data is returned
- const dataset = {
- customer,
- };
-
- return {
- // Props returned here will be available as page properties (pageProps)
- props: {
- apolloState: apolloClient.cache.extract(),
- bestCountryCodes,
- serializedDataset: serializeSafe(dataset),
- customerRef,
- i18nTranslations,
- gcmsLocales,
- hasLocaleFromUrl,
- isReadyToRender: true,
- isStaticRendering: true,
- lang,
- locale,
- preview,
- previewData,
- },
- // revalidate: false,
- };
-};
-
diff --git a/svg-to-react/.gitignore b/svg-to-react/.gitignore
new file mode 100644
index 000000000..a25be42f6
--- /dev/null
+++ b/svg-to-react/.gitignore
@@ -0,0 +1 @@
+*.tsx
diff --git a/src/svg/AnimatedBubble.svg b/svg-to-react/AnimatedBubble.svg
similarity index 100%
rename from src/svg/AnimatedBubble.svg
rename to svg-to-react/AnimatedBubble.svg
diff --git a/src/svg/AnimatedLoader.svg b/svg-to-react/AnimatedLoader.svg
similarity index 100%
rename from src/svg/AnimatedLoader.svg
rename to svg-to-react/AnimatedLoader.svg
diff --git a/src/svg/AnimatedTextBubble.svg b/svg-to-react/AnimatedTextBubble.svg
similarity index 100%
rename from src/svg/AnimatedTextBubble.svg
rename to svg-to-react/AnimatedTextBubble.svg
diff --git a/src/svg/EnglishHybridFlag.svg b/svg-to-react/EnglishHybridFlag.svg
similarity index 100%
rename from src/svg/EnglishHybridFlag.svg
rename to svg-to-react/EnglishHybridFlag.svg
diff --git a/src/svg/EnglishUkFlag.svg b/svg-to-react/EnglishUkFlag.svg
similarity index 100%
rename from src/svg/EnglishUkFlag.svg
rename to svg-to-react/EnglishUkFlag.svg
diff --git a/src/svg/FrenchFlag.svg b/svg-to-react/FrenchFlag.svg
similarity index 100%
rename from src/svg/FrenchFlag.svg
rename to svg-to-react/FrenchFlag.svg
diff --git a/src/utils/svg/svgTemplate.ts b/svg-to-react/svgTemplate.ts
similarity index 100%
rename from src/utils/svg/svgTemplate.ts
rename to svg-to-react/svgTemplate.ts
diff --git a/tsconfig.json b/tsconfig.json
index e9ec97baa..b063d0ac5 100644
--- a/tsconfig.json
+++ b/tsconfig.json
@@ -1,5 +1,29 @@
{
"compilerOptions": {
+ "baseUrl": ".",
+ "paths": {
+ "@/app/*": [
+ "src/app/*"
+ ],
+ "@/common/*": [
+ "src/common/*"
+ ],
+ "@/components/*": [
+ "src/common/components/*"
+ ],
+ "@/utils/*": [
+ "src/common/utils/*"
+ ],
+ "@/layouts/*": [
+ "src/layouts/*"
+ ],
+ "@/modules/*": [
+ "src/modules/*"
+ ],
+ "@/pages/*": [
+ "src/pages/*"
+ ]
+ },
"allowJs": false,
"allowSyntheticDefaultImports": true,
"esModuleInterop": true,
diff --git a/yarn.lock b/yarn.lock
index e095bce63..e7907382d 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -224,7 +224,7 @@
semver "^5.4.1"
source-map "^0.5.0"
-"@babel/core@^7.12.1", "@babel/core@^7.12.3":
+"@babel/core@^7.12.1", "@babel/core@^7.12.3", "@babel/core@^7.6.2":
version "7.12.10"
resolved "https://registry.yarnpkg.com/@babel/core/-/core-7.12.10.tgz#b79a2e1b9f70ed3d84bbfb6d8c4ef825f606bccd"
integrity sha512-eTAlQKq65zHfkHZV0sIVODCPGVgoo1HdBlbSLi9CqOzuZanMv2ihzY+4paiKr1mH+XmYESMAmJ/dpZ68eN6d8w==
@@ -254,7 +254,7 @@
jsesc "^2.5.1"
source-map "^0.5.0"
-"@babel/generator@^7.12.1", "@babel/generator@^7.12.10", "@babel/generator@^7.12.11", "@babel/generator@^7.12.5", "@babel/generator@^7.4.4":
+"@babel/generator@^7.12.1", "@babel/generator@^7.12.10", "@babel/generator@^7.12.11", "@babel/generator@^7.12.5", "@babel/generator@^7.4.4", "@babel/generator@^7.6.2":
version "7.12.11"
resolved "https://registry.yarnpkg.com/@babel/generator/-/generator-7.12.11.tgz#98a7df7b8c358c9a37ab07a24056853016aba3af"
integrity sha512-Ggg6WPOJtSi8yYQvLVjG8F/TlpWDlKx0OpS4Kt+xMQPs5OaGYWy+v1A+1TvxI6sAMGZpKWWoAQ1DaeQbImlItA==
@@ -631,7 +631,7 @@
resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.8.4.tgz#d1dbe64691d60358a974295fa53da074dd2ce8e8"
integrity sha512-0fKu/QqildpXmPVaRBoXOlyBb3MC+J0A66x97qEfLOMkn3u6nfY5esWogQwi/K0BjASYy4DbnsEWnpNL6qT5Mw==
-"@babel/parser@^7.12.10", "@babel/parser@^7.12.11", "@babel/parser@^7.12.3", "@babel/parser@^7.12.7", "@babel/parser@^7.4.5":
+"@babel/parser@^7.12.10", "@babel/parser@^7.12.11", "@babel/parser@^7.12.3", "@babel/parser@^7.12.7", "@babel/parser@^7.4.5", "@babel/parser@^7.6.2":
version "7.12.11"
resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.12.11.tgz#9ce3595bcd74bc5c466905e86c535b8b25011e79"
integrity sha512-N3UxG+uuF4CMYoNj8AhnbAcJF0PiuJ9KHuy1lQmkYsxTer/MAH9UBNHsBoAX/4s6NvlDD047No8mYVGGzLL4hg==
@@ -4023,6 +4023,13 @@
"@types/react" "*"
"@types/reactcss" "*"
+"@types/react-dom@17.0.0":
+ version "17.0.0"
+ resolved "https://registry.yarnpkg.com/@types/react-dom/-/react-dom-17.0.0.tgz#b3b691eb956c4b3401777ee67b900cb28415d95a"
+ integrity sha512-lUqY7OlkF/RbNtD5nIq7ot8NquXrdFrjSOR6+w9a9RFQevGi1oZO1dcJbXMeONAPKtZ2UrZOEJ5UOCVsxbLk/g==
+ dependencies:
+ "@types/react" "*"
+
"@types/react-syntax-highlighter@11.0.4":
version "11.0.4"
resolved "https://registry.yarnpkg.com/@types/react-syntax-highlighter/-/react-syntax-highlighter-11.0.4.tgz#d86d17697db62f98046874f62fdb3e53a0bbc4cd"
@@ -14274,7 +14281,7 @@ path-browserify@1.0.1:
resolved "https://registry.yarnpkg.com/path-browserify/-/path-browserify-1.0.1.tgz#d98454a9c3753d5790860f16f68867b9e46be1fd"
integrity sha512-b7uo2UCUOYZcnF/3ID0lulOJi/bafxa1xPe7ZPsammBSpjSWQkjNxlt635YGS2MiR9GjvuXCtz2emr3jbsz98g==
-path-dirname@^1.0.0:
+path-dirname@^1.0.0, path-dirname@^1.0.2:
version "1.0.2"
resolved "https://registry.yarnpkg.com/path-dirname/-/path-dirname-1.0.2.tgz#cc33d24d525e099a5388c0336c6e32b9160609e0"
integrity sha1-zDPSTVJeCZpTiMAzbG4yuRYGCeA=
@@ -15769,6 +15776,18 @@ relateurl@^0.2.7:
resolved "https://registry.yarnpkg.com/relateurl/-/relateurl-0.2.7.tgz#54dbf377e51440aca90a4cd274600d3ff2d888a9"
integrity sha1-VNvzd+UUQKypCkzSdGANP/LYiKk=
+relative-to-alias@2.0.1:
+ version "2.0.1"
+ resolved "https://registry.yarnpkg.com/relative-to-alias/-/relative-to-alias-2.0.1.tgz#556a4902f335405c77ae5bbeef312e323b848e79"
+ integrity sha512-F3RvxKYQRPzbY4303doOlmsqNErwhQH+6NVDlmOCtZeXhLXT0DMuzyDeD2nPvThT4IEg8OiTlHDBEZJ+sjsxmQ==
+ dependencies:
+ "@babel/core" "^7.6.2"
+ "@babel/generator" "^7.6.2"
+ "@babel/parser" "^7.6.2"
+ glob "^7.1.4"
+ path-dirname "^1.0.2"
+ yargs "^14.0.0"
+
release-zalgo@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/release-zalgo/-/release-zalgo-1.0.0.tgz#09700b7e5074329739330e535c5a90fb67851730"
@@ -18968,6 +18987,14 @@ yargs-parser@^13.1.1:
camelcase "^5.0.0"
decamelize "^1.2.0"
+yargs-parser@^15.0.1:
+ version "15.0.1"
+ resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-15.0.1.tgz#54786af40b820dcb2fb8025b11b4d659d76323b3"
+ integrity sha512-0OAMV2mAZQrs3FkNpDQcBk1x5HXb8X4twADss4S0Iuk+2dGnLOE/fRHrsYm542GduMveyA77OF4wrNJuanRCWw==
+ dependencies:
+ camelcase "^5.0.0"
+ decamelize "^1.2.0"
+
yargs-parser@^18.1.2, yargs-parser@^18.1.3:
version "18.1.3"
resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-18.1.3.tgz#be68c4975c6b2abf469236b0c870362fab09a7b0"
@@ -18992,6 +19019,23 @@ yargs@^13.3.0:
y18n "^4.0.0"
yargs-parser "^13.1.1"
+yargs@^14.0.0:
+ version "14.2.3"
+ resolved "https://registry.yarnpkg.com/yargs/-/yargs-14.2.3.tgz#1a1c3edced1afb2a2fea33604bc6d1d8d688a414"
+ integrity sha512-ZbotRWhF+lkjijC/VhmOT9wSgyBQ7+zr13+YLkhfsSiTriYsMzkTUFP18pFhWwBeMa5gUc1MzbhrO6/VB7c9Xg==
+ dependencies:
+ cliui "^5.0.0"
+ decamelize "^1.2.0"
+ find-up "^3.0.0"
+ get-caller-file "^2.0.1"
+ require-directory "^2.1.1"
+ require-main-filename "^2.0.0"
+ set-blocking "^2.0.0"
+ string-width "^3.0.0"
+ which-module "^2.0.0"
+ y18n "^4.0.0"
+ yargs-parser "^15.0.1"
+
yargs@^15.0.2, yargs@^15.4.1:
version "15.4.1"
resolved "https://registry.yarnpkg.com/yargs/-/yargs-15.4.1.tgz#0d87a16de01aee9d8bec2bfbf74f67851730f4f8"