From b2b06ab5b52a1e02d0f2b666b7d2397768eb7f11 Mon Sep 17 00:00:00 2001 From: Nadun De Silva Date: Sun, 3 Sep 2023 18:08:19 +1200 Subject: [PATCH] Switch to NextJS app router --- .github/workflows/deploy-site.yaml | 32 +- .github/workflows/deployment-check.yaml | 8 +- .github/workflows/website-oracle-checks.yaml | 4 +- .lycheeignore | 2 +- .../routes.tsx => app/[...not_found]/page.tsx | 20 +- app/error.tsx | 41 + {public => app}/favicon.ico | Bin app/layout.tsx | 269 ++ app/loading.tsx | 30 + app/manifest.ts | 41 + app/page.tsx | 96 + pages/404.tsx => app/robots.ts | 21 +- app/sitemap.ts | 45 + .../index.tsx => app/solutions/page.tsx | 0 app/solutions/website-oracle/layout.tsx | 97 + app/solutions/website-oracle/loading.tsx | 30 + app/solutions/website-oracle/page.tsx | 122 + .../website-oracle/terms-of-use/page.tsx | 211 +- components/RouterBreadcrumbs.test.tsx | 99 +- components/RouterBreadcrumbs.tsx | 27 +- components/WebVitals.tsx | 32 + components/content/Logo.test.tsx | 25 +- components/content/Logo.tsx | 5 +- components/content/Paragraph.test.tsx | 1 - components/content/Paragraph.tsx | 1 - components/content/Photo.test.tsx | 1 - components/content/Photo.tsx | 1 - components/content/Section.test.tsx | 1 - components/content/Section.tsx | 2 +- components/content/SectionHeading.test.tsx | 1 - components/content/SectionHeading.tsx | 1 - components/content/index.tsx | 21 + components/theme/EmotionCacheProvider.tsx | 103 + .../WebsiteThemeProvider.test.tsx} | 28 +- .../WebsiteThemeProvider.tsx} | 54 +- components/theme/index.tsx | 17 + constants/{images.tsx => images.ts} | 1 - constants/{logos.tsx => logos.ts} | 22 +- constants/routes.ts | 65 + generate-sitemap.js | 57 - package-lock.json | 2411 +++++++++-------- package.json | 35 +- pages/_app.tsx | 144 - pages/_document.tsx | 262 -- pages/index.tsx | 97 - public/manifest.json | 19 - public/robots.txt | 2 - 47 files changed, 2382 insertions(+), 2222 deletions(-) rename constants/routes.tsx => app/[...not_found]/page.tsx (57%) create mode 100644 app/error.tsx rename {public => app}/favicon.ico (100%) create mode 100644 app/layout.tsx create mode 100644 app/loading.tsx create mode 100644 app/manifest.ts create mode 100644 app/page.tsx rename pages/404.tsx => app/robots.ts (63%) create mode 100644 app/sitemap.ts rename pages/solutions/index.tsx => app/solutions/page.tsx (100%) create mode 100644 app/solutions/website-oracle/layout.tsx create mode 100644 app/solutions/website-oracle/loading.tsx create mode 100644 app/solutions/website-oracle/page.tsx rename pages/solutions/website-oracle.tsx => app/solutions/website-oracle/terms-of-use/page.tsx (58%) create mode 100644 components/WebVitals.tsx create mode 100644 components/content/index.tsx create mode 100644 components/theme/EmotionCacheProvider.tsx rename components/{theme.test.tsx => theme/WebsiteThemeProvider.test.tsx} (91%) rename components/{theme.tsx => theme/WebsiteThemeProvider.tsx} (73%) create mode 100644 components/theme/index.tsx rename constants/{images.tsx => images.ts} (99%) rename constants/{logos.tsx => logos.ts} (63%) create mode 100644 constants/routes.ts delete mode 100644 generate-sitemap.js delete mode 100644 pages/_app.tsx delete mode 100644 pages/_document.tsx delete mode 100644 pages/index.tsx delete mode 100644 public/manifest.json delete mode 100644 public/robots.txt diff --git a/.github/workflows/deploy-site.yaml b/.github/workflows/deploy-site.yaml index 2b29d1b..449a830 100644 --- a/.github/workflows/deploy-site.yaml +++ b/.github/workflows/deploy-site.yaml @@ -14,19 +14,19 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: fetch-depth: 0 - name: Setup Node.js uses: actions/setup-node@v3 with: - node-version: "18.12.1" + node-version: "18.17.1" - name: Install Dependencies run: npm ci - name: Build NextJS types run: npm run build - name: Lint Code Base - uses: github/super-linter@v4 + uses: github/super-linter@v5 env: DEFAULT_BRANCH: main GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} @@ -47,7 +47,7 @@ jobs: security-events: write steps: - name: Checkout repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Initialize CodeQL uses: github/codeql-action/init@v2 with: @@ -64,7 +64,7 @@ jobs: security-events: write steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Run Trivy vulnerability scanner uses: aquasecurity/trivy-action@master with: @@ -84,11 +84,11 @@ jobs: runs-on: ubuntu-20.04 steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Setup Node.js uses: actions/setup-node@v3 with: - node-version: "18.12.1" + node-version: "18.17.1" - name: Install Dependencies run: npm ci - name: Running Unit Tests @@ -113,10 +113,10 @@ jobs: runs-on: ubuntu-20.04 steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - uses: actions/setup-node@v3 with: - node-version: "18.12.1" + node-version: "18.17.1" - name: Install Dependencies run: npm ci - name: Build Site @@ -142,11 +142,11 @@ jobs: needs: build-site steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Setup Node.js uses: actions/setup-node@v3 with: - node-version: "18.12.1" + node-version: "18.17.1" - name: Install Dependencies run: npm ci - name: Download Site @@ -161,7 +161,7 @@ jobs: WEBSITE_BUILD_DIR: _site - name: Link Checker id: lychee - uses: lycheeverse/lychee-action@v1.5.4 + uses: lycheeverse/lychee-action@v1.8.0 with: args: --verbose --no-progress https://cadmus-labs.github.io/ fail: true @@ -183,7 +183,7 @@ jobs: # needs: build-site # steps: # - name: Checkout - # uses: actions/checkout@v3 + # uses: actions/checkout@v4 # - name: Download Site # uses: actions/download-artifact@v3 # with: @@ -192,7 +192,7 @@ jobs: # - name: Setup Node.js # uses: actions/setup-node@v3 # with: - # node-version: "18.12.1" + # node-version: "18.17.1" # - name: Run Lighthouse Audit # run: | # npm install -g @lhci/cli@0.10.x @@ -224,7 +224,7 @@ jobs: # - run-website-audit steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Download Site uses: actions/download-artifact@v3 with: @@ -233,7 +233,7 @@ jobs: - name: Setup Node.js uses: actions/setup-node@v3 with: - node-version: "18.12.1" + node-version: "18.17.1" - name: Deploy uses: JamesIves/github-pages-deploy-action@v4 with: diff --git a/.github/workflows/deployment-check.yaml b/.github/workflows/deployment-check.yaml index b509206..f3b1881 100644 --- a/.github/workflows/deployment-check.yaml +++ b/.github/workflows/deployment-check.yaml @@ -17,10 +17,10 @@ jobs: runs-on: ubuntu-20.04 steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Link Checker id: lychee - uses: lycheeverse/lychee-action@v1.5.4 + uses: lycheeverse/lychee-action@v1.8.0 with: args: --verbose --no-progress https://cadmus-labs.github.io/ fail: true @@ -36,7 +36,7 @@ jobs: # runs-on: ubuntu-20.04 # steps: # - name: Checkout - # uses: actions/checkout@v3 + # uses: actions/checkout@v4 # - name: Setup Node.js # uses: actions/setup-node@v3 # with: @@ -62,7 +62,7 @@ jobs: security-events: write steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Run Trivy vulnerability scanner uses: aquasecurity/trivy-action@master with: diff --git a/.github/workflows/website-oracle-checks.yaml b/.github/workflows/website-oracle-checks.yaml index 92bbc58..17a28c3 100644 --- a/.github/workflows/website-oracle-checks.yaml +++ b/.github/workflows/website-oracle-checks.yaml @@ -11,7 +11,7 @@ jobs: name: Check Certificate steps: - name: Checkout Repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Check Website Certificate uses: cadmus-labs/check-website-certificate-action@main with: @@ -23,7 +23,7 @@ jobs: name: Check Dependencies steps: - name: Checkout Repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Check Dependencies uses: cadmus-labs/check-website-dependencies-action@main with: diff --git a/.lycheeignore b/.lycheeignore index ba79296..3194721 100644 --- a/.lycheeignore +++ b/.lycheeignore @@ -1 +1 @@ -^https?://www.googletagmanager.com/$ +^https?://www\.googletagmanager\.com/$ diff --git a/constants/routes.tsx b/app/[...not_found]/page.tsx similarity index 57% rename from constants/routes.tsx rename to app/[...not_found]/page.tsx index c941fe4..994c0c9 100644 --- a/constants/routes.tsx +++ b/app/[...not_found]/page.tsx @@ -12,21 +12,9 @@ * * © 2023 Cadmus Labs. All rights reserved. */ +import { redirect } from "next/navigation"; +import type React from "react"; -export interface Route { - name: string; - subRoutes?: Record; -} +const NotFound = (): React.ReactElement => redirect("/"); -export const ANY_ROUTE = "*"; - -export const Routes: Record = { - "/solutions": { - name: "Solutions", - subRoutes: { - "/website-oracle": { - name: "Website Oracle", - }, - }, - }, -}; +export default NotFound; diff --git a/app/error.tsx b/app/error.tsx new file mode 100644 index 0000000..a9b10b2 --- /dev/null +++ b/app/error.tsx @@ -0,0 +1,41 @@ +"use client"; +/* + * Cadmus Labs - All Rights Reserved + * + * This source code and its associated files are the + * confidential and proprietary information of Cadmus Labs. + * Unauthorized reproduction, distribution, or disclosure + * in any form, in whole or in part, is strictly prohibited + * except as explicitly provided under a separate license + * agreement with Cadmus Labs. + * + * Website: https://cadmus-labs.github.io + * + * © 2023 Cadmus Labs. All rights reserved. + */ +import { Button, Typography, type Theme, Container, Box } from "@mui/material"; + +interface ErrorProps { + reset: () => void; +} + +const Error = ({ reset }: ErrorProps): React.ReactElement => ( + + `calc(100vh - ${theme.spacing(15)} - ${ + theme.typography.fontSize + }px - ${theme.mixins.toolbar.minHeight ?? 0}px)`, + display: "flex", + justifyContent: "center", + alignItems: "center", + }} + > + + Something went wrong + + + +); + +export default Error; diff --git a/public/favicon.ico b/app/favicon.ico similarity index 100% rename from public/favicon.ico rename to app/favicon.ico diff --git a/app/layout.tsx b/app/layout.tsx new file mode 100644 index 0000000..b56fd5e --- /dev/null +++ b/app/layout.tsx @@ -0,0 +1,269 @@ +/* + * Cadmus Labs - All Rights Reserved + * + * This source code and its associated files are the + * confidential and proprietary information of Cadmus Labs. + * Unauthorized reproduction, distribution, or disclosure + * in any form, in whole or in part, is strictly prohibited + * except as explicitly provided under a separate license + * agreement with Cadmus Labs. + * + * Website: https://cadmus-labs.github.io + * + * © 2023 Cadmus Labs. All rights reserved. + */ +import { AppBar, Container, Toolbar, Typography } from "@mui/material"; +import { type Metadata } from "next"; +import { Roboto } from "next/font/google"; +import Link from "next/link"; +import Script from "next/script"; +import React from "react"; + +import RouterBreadcrumbs from "@/components/RouterBreadcrumbs"; +import { WebsiteThemeProvider } from "@/components/theme"; +import WebVitals from "@/components/WebVitals"; +import "@/styles/main.css"; + +const FULL_NAME = "Cadmus Labs"; +const DESCRIPTION = `${FULL_NAME} - Innovative software solutions for businesses and individuals. Explore our offerings and drive your digital transformation.`; +const PUBLIC_URL = process.env.PUBLIC_URL ?? "https://cadmus-labs.github.io"; + +const GA_TRACKING_ID = "GTM-WGFR7MN"; +const GOOGLE_SITE_VERIFICATION = "M8dg6gzVYU0noXFvsPOqknm_WjREFeNE212YeUk0g30"; +const YANDEX_VERIFICATION = "e69c5a3df2c9a0e8"; + +export const metadata: Metadata = { + title: `${FULL_NAME}`, + description: DESCRIPTION, + metadataBase: new URL(PUBLIC_URL), + applicationName: FULL_NAME, + authors: { name: FULL_NAME, url: PUBLIC_URL }, + creator: FULL_NAME, + publisher: FULL_NAME, + generator: "Next.js", + keywords: ["Cadmus Labs", "APIs", "Software Solutions"], + referrer: "origin", + themeColor: [ + { + media: "(prefers-color-scheme: light)", + color: "#6c63ff", + }, + { + media: "(prefers-color-scheme: dark)", + color: "#000000", + }, + ], + colorScheme: "light", + viewport: { + minimumScale: 1, + initialScale: 1, + width: "device-width", + userScalable: true, + viewportFit: "cover", + interactiveWidget: "resizes-visual", + }, + robots: `${PUBLIC_URL}/robots.txt`, + alternates: { + canonical: PUBLIC_URL, + }, + icons: { + icon: `${PUBLIC_URL}/icon-maskable-x512.png`, + shortcut: `${PUBLIC_URL}/icon-maskable-x512.png`, + apple: `${PUBLIC_URL}/icon-maskable-x512.png`, + }, + manifest: `${PUBLIC_URL}/manifest.webmanifest`, + openGraph: { + type: "website", + title: FULL_NAME, + description: DESCRIPTION, + emails: "cadmuslabsinnovations@gmail.com", + url: PUBLIC_URL, + siteName: FULL_NAME, + locale: "en_US", + images: { + url: `${PUBLIC_URL}/icon-maskable-x512.png`, + alt: FULL_NAME, + type: "image/jpeg", + width: 1960, + height: 1960, + }, + }, + verification: { + google: GOOGLE_SITE_VERIFICATION, + yandex: YANDEX_VERIFICATION, + }, + appleWebApp: { + capable: true, + title: FULL_NAME, + startupImage: { + url: `${PUBLIC_URL}/icon-maskable-x512.png`, + media: "image/jpeg", + }, + statusBarStyle: "black-translucent", + }, + formatDetection: { + telephone: true, + date: true, + address: true, + email: true, + url: true, + }, +}; + +const createCspValues = (): string[] => { + const cspValues = { + "default-src": ["'none'"], + "manifest-src": ["'self'"], + "img-src": [ + "'self'", + "data:", + "https://www.google.lk", + "https://www.googletagmanager.com", + ], + "style-src": ["'unsafe-inline'"], + "style-src-elem": ["'self'", "'unsafe-inline'"], + "font-src": ["'self'"], + "script-src": [ + "'self'", + "https://www.googletagmanager.com", + "http://www.googletagmanager.com", + "'unsafe-inline'", + ], + "connect-src": ["'self'", "https://www.google-analytics.com"], + }; + if ( + process.env.NODE_ENV === "development" || + process.env.BUILD_TYPE === "test" + ) { + cspValues["script-src"].push("'unsafe-eval'"); + } + const csps: string[] = []; + for (const [cspKey, cspValue] of Object.entries(cspValues)) { + csps.push(`${cspKey} ${cspValue.join(" ")}`); + } + return csps; +}; + +const roboto = Roboto({ + weight: "400", + subsets: ["latin"], +}); + +interface RootLayoutProps { + children: React.ReactNode; +} + +const RootLayout = ({ children }: RootLayoutProps): React.ReactElement => { + const csps = createCspValues(); + return ( + + + + + + + + + + + + +