From ef0716e9649906d8285d10511d97d900bdd2747a Mon Sep 17 00:00:00 2001 From: Aravind Kumar Date: Tue, 18 Jun 2024 14:41:34 +0530 Subject: [PATCH 01/30] sca-scan.yml --- .github/workflows/sca-scan.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/sca-scan.yml b/.github/workflows/sca-scan.yml index bf9c1eb..f09161f 100644 --- a/.github/workflows/sca-scan.yml +++ b/.github/workflows/sca-scan.yml @@ -3,7 +3,7 @@ on: pull_request: types: [opened, synchronize, reopened] jobs: - security: + security-sca: runs-on: ubuntu-latest steps: - uses: actions/checkout@master From bcabe5466962c46099372bbafbe8d3e62c24d581 Mon Sep 17 00:00:00 2001 From: Aravind Kumar Date: Tue, 18 Jun 2024 14:41:47 +0530 Subject: [PATCH 02/30] jira.yml --- .github/workflows/jira.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/jira.yml b/.github/workflows/jira.yml index 63960ea..caa4bbd 100644 --- a/.github/workflows/jira.yml +++ b/.github/workflows/jira.yml @@ -3,7 +3,7 @@ on: pull_request: types: [opened] jobs: - security: + security-jira: if: ${{ github.actor == 'dependabot[bot]' || github.actor == 'snyk-bot' || contains(github.event.pull_request.head.ref, 'snyk-fix-') || contains(github.event.pull_request.head.ref, 'snyk-upgrade-')}} runs-on: ubuntu-latest steps: From 8ae9a5ab7bb6de0d1cc35457d1e7d11b63f7cd70 Mon Sep 17 00:00:00 2001 From: Aravind Kumar Date: Tue, 18 Jun 2024 14:41:47 +0530 Subject: [PATCH 03/30] sast-scan.yml --- .github/workflows/sast-scan.yml | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 .github/workflows/sast-scan.yml diff --git a/.github/workflows/sast-scan.yml b/.github/workflows/sast-scan.yml new file mode 100644 index 0000000..3b9521a --- /dev/null +++ b/.github/workflows/sast-scan.yml @@ -0,0 +1,11 @@ +name: SAST Scan +on: + pull_request: + types: [opened, synchronize, reopened] +jobs: + security-sast: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Semgrep Scan + run: docker run -v /var/run/docker.sock:/var/run/docker.sock -v "${PWD}:/src" returntocorp/semgrep semgrep scan --config auto \ No newline at end of file From e3764b7288fd83352cb353c806f92ad817775e27 Mon Sep 17 00:00:00 2001 From: Aravind Kumar Date: Tue, 18 Jun 2024 14:41:49 +0530 Subject: [PATCH 04/30] codeql-analysis.yml From a88c6273ca75245398cadfbe98b86368c0de81ff Mon Sep 17 00:00:00 2001 From: Aravind Kumar Date: Tue, 22 Oct 2024 15:58:16 +0530 Subject: [PATCH 05/30] sca-scan.yml From e22a7f1c1d681eabbcfcbe13f096ae1f327c5be0 Mon Sep 17 00:00:00 2001 From: Aravind Kumar Date: Tue, 22 Oct 2024 16:43:03 +0530 Subject: [PATCH 06/30] sca-scan.yml From d88726851e210f8e24fb0c9e585aa9cc836fd607 Mon Sep 17 00:00:00 2001 From: Aravind Kumar Date: Tue, 22 Oct 2024 16:43:14 +0530 Subject: [PATCH 07/30] jira.yml From f0e85d0685cc9170abdc5525bde27af235d27ce2 Mon Sep 17 00:00:00 2001 From: Aravind Kumar Date: Tue, 22 Oct 2024 16:43:15 +0530 Subject: [PATCH 08/30] sast-scan.yml From edb64f401cfc66390f1f5a9854b9524a25620539 Mon Sep 17 00:00:00 2001 From: Aravind Kumar Date: Tue, 22 Oct 2024 16:43:16 +0530 Subject: [PATCH 09/30] codeql-analysis.yml From 328c66e7f98712585fa960a844cd32233da4ae18 Mon Sep 17 00:00:00 2001 From: Aravind Kumar Date: Tue, 22 Oct 2024 16:43:21 +0530 Subject: [PATCH 10/30] Updated codeowners --- CODEOWNERS | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CODEOWNERS b/CODEOWNERS index 0773923..1be7e0d 100644 --- a/CODEOWNERS +++ b/CODEOWNERS @@ -1 +1 @@ -* @contentstack/security-admin \ No newline at end of file +* @contentstack/security-admin From 566cccd69414bc3a4d94b673048faf533c5472e0 Mon Sep 17 00:00:00 2001 From: Aravind Kumar Date: Sun, 19 Jan 2025 20:50:26 +0530 Subject: [PATCH 11/30] sca-scan.yml From 70ee17afd03c8ad20fdd1658e51b0b8360827a95 Mon Sep 17 00:00:00 2001 From: Aravind Kumar Date: Sun, 19 Jan 2025 20:50:40 +0530 Subject: [PATCH 12/30] jira.yml --- .github/workflows/jira.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/jira.yml b/.github/workflows/jira.yml index caa4bbd..250abc7 100644 --- a/.github/workflows/jira.yml +++ b/.github/workflows/jira.yml @@ -21,7 +21,7 @@ jobs: project: ${{ secrets.JIRA_PROJECT }} issuetype: ${{ secrets.JIRA_ISSUE_TYPE }} summary: | - ${{ github.event.pull_request.title }} + Snyk | Vulnerability | ${{ github.event.repository.name }} | ${{ github.event.pull_request.title }} description: | PR: ${{ github.event.pull_request.html_url }} From cfdeb35fba2a5b1483763cfa0f24d6cb6c3625dd Mon Sep 17 00:00:00 2001 From: Aravind Kumar Date: Sun, 19 Jan 2025 20:50:41 +0530 Subject: [PATCH 13/30] sast-scan.yml From 2c69012af1c1e89b31b8921a7383d49cbc5d9c83 Mon Sep 17 00:00:00 2001 From: Aravind Kumar Date: Sun, 19 Jan 2025 20:50:43 +0530 Subject: [PATCH 14/30] codeql-analysis.yml From 45e0d830e7c351a63054eaa46d4a918d00a71687 Mon Sep 17 00:00:00 2001 From: Aravind Kumar Date: Sun, 19 Jan 2025 20:50:49 +0530 Subject: [PATCH 15/30] Updated codeowners From 9fc025fffacf6f7410dbfee3db7cee2214d9a1be Mon Sep 17 00:00:00 2001 From: Aravind Kumar Date: Wed, 16 Apr 2025 14:49:57 +0530 Subject: [PATCH 16/30] policy-scan.yml --- .github/workflows/policy-scan.yml | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 .github/workflows/policy-scan.yml diff --git a/.github/workflows/policy-scan.yml b/.github/workflows/policy-scan.yml new file mode 100644 index 0000000..fe9c6f7 --- /dev/null +++ b/.github/workflows/policy-scan.yml @@ -0,0 +1,27 @@ +name: Checks the security policy and configurations +on: + pull_request: + types: [opened, synchronize, reopened] +jobs: + security-policy: + if: github.event.repository.visibility == 'public' + runs-on: ubuntu-latest + defaults: + run: + shell: bash + steps: + - uses: actions/checkout@master + - name: Checks for SECURITY.md policy file + run: | + if ! [[ -f "SECURITY.md" || -f ".github/SECURITY.md" ]]; then exit 1; fi + security-license: + if: github.event.repository.visibility == 'public' + runs-on: ubuntu-latest + defaults: + run: + shell: bash + steps: + - uses: actions/checkout@master + - name: Checks for License file + run: | + if ! [[ -f "LICENSE" || -f "License.txt" || -f "LICENSE.md" || -f "LICENSE.txt" ]]; then exit 1; fi \ No newline at end of file From 1142cfd95dbf9f413cd694a158e95c72b176937b Mon Sep 17 00:00:00 2001 From: Aravind Kumar Date: Wed, 16 Apr 2025 14:50:08 +0530 Subject: [PATCH 17/30] issues-jira.yml --- .github/workflows/issues-jira.yml | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 .github/workflows/issues-jira.yml diff --git a/.github/workflows/issues-jira.yml b/.github/workflows/issues-jira.yml new file mode 100644 index 0000000..7bf0469 --- /dev/null +++ b/.github/workflows/issues-jira.yml @@ -0,0 +1,31 @@ +name: Create Jira Ticket for Github Issue + +on: + issues: + types: [opened] + +jobs: + issue-jira: + runs-on: ubuntu-latest + steps: + + - name: Login to Jira + uses: atlassian/gajira-login@master + env: + JIRA_BASE_URL: ${{ secrets.JIRA_BASE_URL }} + JIRA_USER_EMAIL: ${{ secrets.JIRA_USER_EMAIL }} + JIRA_API_TOKEN: ${{ secrets.JIRA_API_TOKEN }} + + - name: Create Jira Issue + id: create_jira + uses: atlassian/gajira-create@master + with: + project: ${{ secrets.JIRA_PROJECT }} + issuetype: ${{ secrets.JIRA_ISSUE_TYPE }} + summary: Github | Issue | ${{ github.event.repository.name }} | ${{ github.event.issue.title }} + description: | + *GitHub Issue:* ${{ github.event.issue.html_url }} + + *Description:* + ${{ github.event.issue.body }} + fields: "${{ secrets.ISSUES_JIRA_FIELDS }}" \ No newline at end of file From e36e98cccf60177f118417b5dee84c29bf7b500b Mon Sep 17 00:00:00 2001 From: Aravind Kumar Date: Wed, 16 Apr 2025 14:50:09 +0530 Subject: [PATCH 18/30] Delete jira.yml --- .github/workflows/jira.yml | 33 --------------------------------- 1 file changed, 33 deletions(-) delete mode 100644 .github/workflows/jira.yml diff --git a/.github/workflows/jira.yml b/.github/workflows/jira.yml deleted file mode 100644 index 250abc7..0000000 --- a/.github/workflows/jira.yml +++ /dev/null @@ -1,33 +0,0 @@ -name: Create JIRA ISSUE -on: - pull_request: - types: [opened] -jobs: - security-jira: - if: ${{ github.actor == 'dependabot[bot]' || github.actor == 'snyk-bot' || contains(github.event.pull_request.head.ref, 'snyk-fix-') || contains(github.event.pull_request.head.ref, 'snyk-upgrade-')}} - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - name: Login into JIRA - uses: atlassian/gajira-login@master - env: - JIRA_BASE_URL: ${{ secrets.JIRA_BASE_URL }} - JIRA_USER_EMAIL: ${{ secrets.JIRA_USER_EMAIL }} - JIRA_API_TOKEN: ${{ secrets.JIRA_API_TOKEN }} - - name: Create a JIRA Issue - id: create - uses: atlassian/gajira-create@master - with: - project: ${{ secrets.JIRA_PROJECT }} - issuetype: ${{ secrets.JIRA_ISSUE_TYPE }} - summary: | - Snyk | Vulnerability | ${{ github.event.repository.name }} | ${{ github.event.pull_request.title }} - description: | - PR: ${{ github.event.pull_request.html_url }} - - fields: "${{ secrets.JIRA_FIELDS }}" - - name: Transition issue - uses: atlassian/gajira-transition@v3 - with: - issue: ${{ steps.create.outputs.issue }} - transition: ${{ secrets.JIRA_TRANSITION }} From 9248d7a8a6bb576f307dfed3755cec22a7bb3edd Mon Sep 17 00:00:00 2001 From: Aravind Kumar Date: Wed, 16 Apr 2025 14:50:10 +0530 Subject: [PATCH 19/30] Delete sast-scan.yml --- .github/workflows/sast-scan.yml | 11 ----------- 1 file changed, 11 deletions(-) delete mode 100644 .github/workflows/sast-scan.yml diff --git a/.github/workflows/sast-scan.yml b/.github/workflows/sast-scan.yml deleted file mode 100644 index 3b9521a..0000000 --- a/.github/workflows/sast-scan.yml +++ /dev/null @@ -1,11 +0,0 @@ -name: SAST Scan -on: - pull_request: - types: [opened, synchronize, reopened] -jobs: - security-sast: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - name: Semgrep Scan - run: docker run -v /var/run/docker.sock:/var/run/docker.sock -v "${PWD}:/src" returntocorp/semgrep semgrep scan --config auto \ No newline at end of file From 3ca44e862ef1ddbfe9fd8d6e0dcfff8c572b91d9 Mon Sep 17 00:00:00 2001 From: Aravind Kumar Date: Wed, 16 Apr 2025 14:50:11 +0530 Subject: [PATCH 20/30] codeql-analysis.yml From 34d084e29db1b3bf275eb2b3bc74108af50e927f Mon Sep 17 00:00:00 2001 From: Aravind Kumar Date: Wed, 16 Apr 2025 14:50:15 +0530 Subject: [PATCH 21/30] Updated codeowners From a28a0bfbc2cdcddf4e06410bfe5bd6e41789463d Mon Sep 17 00:00:00 2001 From: Aravind Kumar Date: Wed, 23 Apr 2025 21:39:21 +0530 Subject: [PATCH 22/30] policy-scan.yml --- .github/workflows/policy-scan.yml | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/.github/workflows/policy-scan.yml b/.github/workflows/policy-scan.yml index fe9c6f7..ff25923 100644 --- a/.github/workflows/policy-scan.yml +++ b/.github/workflows/policy-scan.yml @@ -24,4 +24,23 @@ jobs: - uses: actions/checkout@master - name: Checks for License file run: | - if ! [[ -f "LICENSE" || -f "License.txt" || -f "LICENSE.md" || -f "LICENSE.txt" ]]; then exit 1; fi \ No newline at end of file + expected_license_files=("LICENSE" "LICENSE.txt" "LICENSE.md" "License.txt") + license_file_found=false + current_year=$(date +"%Y") + + for license_file in "${expected_license_files[@]}"; do + if [ -f "$license_file" ]; then + license_file_found=true + # check the license file for the current year, if not exists, exit with error + if ! grep -q "$current_year" "$license_file"; then + echo "License file $license_file does not contain the current year." + exit 2 + fi + break + fi + done + + if [ "$license_file_found" = false ]; then + echo "No license file found. Please add a license file to the repository." + exit 1 + fi \ No newline at end of file From fb1697f4ff26fe8d1f2603d13099661d00be4918 Mon Sep 17 00:00:00 2001 From: Aravind Kumar Date: Tue, 6 May 2025 13:58:11 +0530 Subject: [PATCH 23/30] policy-scan.yml From 32b64df0d4e2e78481a408f059631ef61492cf59 Mon Sep 17 00:00:00 2001 From: Aravind Kumar Date: Tue, 6 May 2025 13:58:19 +0530 Subject: [PATCH 24/30] issues-jira.yml From 974afc1d810632c4df5613e69d0fd051ce7da2b8 Mon Sep 17 00:00:00 2001 From: Aravind Kumar Date: Tue, 6 May 2025 13:58:21 +0530 Subject: [PATCH 25/30] secrets-scan.yml --- .github/workflows/secrets-scan.yml | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 .github/workflows/secrets-scan.yml diff --git a/.github/workflows/secrets-scan.yml b/.github/workflows/secrets-scan.yml new file mode 100644 index 0000000..049c02f --- /dev/null +++ b/.github/workflows/secrets-scan.yml @@ -0,0 +1,29 @@ +name: Secrets Scan +on: + pull_request: + types: [opened, synchronize, reopened] +jobs: + security-secrets: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: '2' + ref: '${{ github.event.pull_request.head.ref }}' + - run: | + git reset --soft HEAD~1 + - name: Install Talisman + run: | + # Download Talisman + wget https://github.com/thoughtworks/talisman/releases/download/v1.37.0/talisman_linux_amd64 -O talisman + + # Checksum verification + checksum=$(sha256sum ./talisman | awk '{print $1}') + if [ "$checksum" != "8e0ae8bb7b160bf10c4fa1448beb04a32a35e63505b3dddff74a092bccaaa7e4" ]; then exit 1; fi + + # Make it executable + chmod +x talisman + - name: Run talisman + run: | + # Run Talisman with the pre-commit hook + ./talisman --githook pre-commit \ No newline at end of file From 5c7fda0610504e3715b1a439ca333b740334b8c7 Mon Sep 17 00:00:00 2001 From: Aravind Kumar Date: Tue, 6 May 2025 13:58:23 +0530 Subject: [PATCH 26/30] talismanrc file updated --- .talismanrc | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .talismanrc diff --git a/.talismanrc b/.talismanrc new file mode 100644 index 0000000..345ca2f --- /dev/null +++ b/.talismanrc @@ -0,0 +1,5 @@ +fileignoreconfig: +- filename: .github/workflows/secrets-scan.yml + ignore_detectors: + - filecontent +version: "1.0" \ No newline at end of file From 112a157d34c36f05b15c6794f8a59ebaa0f6f6b9 Mon Sep 17 00:00:00 2001 From: Aravind Kumar Date: Tue, 6 May 2025 13:58:28 +0530 Subject: [PATCH 27/30] Updated codeowners From bb83c281cf727a93974fe5929c6e319689df1668 Mon Sep 17 00:00:00 2001 From: Amitkanswal Date: Thu, 22 May 2025 11:20:43 +0530 Subject: [PATCH 28/30] feat:updated next to latest Signed-off-by: Amitkanswal --- .env.local.sample | 16 +- .gitignore | 1 + .npmrc | 1 - LICENSE | 2 +- app/[page]/page.tsx | 76 + app/app-layout.tsx | 106 + app/blog/[post]/blog-loader.css | 62 + app/blog/[post]/loading.tsx | 57 + app/blog/[post]/page.tsx | 131 + app/blog/blog-layout.css | 62 + app/blog/loading.tsx | 45 + app/blog/page.tsx | 67 + app/error.tsx | 32 + app/layout.tsx | 70 + app/loading.tsx | 37 + app/manifest.ts | 39 + app/not-found.tsx | 15 + app/page.tsx | 64 + app/robots.ts | 13 + app/sitemap.xml/route.ts | 43 + components/about-section-bucket.tsx | 2 + components/archive-relative.tsx | 2 + components/blog-banner.tsx | 2 + components/blog-list.tsx | 2 + components/blog-section.tsx | 2 + components/card-section.tsx | 2 + components/client-home-wrapper.tsx | 47 + components/devtools.tsx | 2 + components/footer.tsx | 87 +- components/header.tsx | 113 +- components/hero-banner.tsx | 2 + components/layout.tsx | 74 - components/liveprevew-init.tsx | 26 + components/navigation-progress.tsx | 37 + components/render-components.tsx | 164 +- components/section-bucket.tsx | 5 +- components/section-with-html-code.tsx | 2 + components/section.tsx | 2 + components/team-section.tsx | 2 + components/tool-tip.tsx | 2 + contentstack-sdk/config.ts | 13 + contentstack-sdk/index.ts | 23 +- contentstack-sdk/utils.ts | 84 +- helper/index.ts | 202 +- helper/live-preview.ts | 72 + middleware.ts | 42 + next-env.d.ts | 2 +- next.config.js | 36 +- package-lock.json | 20626 ++++++++++-------------- package.json | 14 +- pages/404.tsx | 12 - pages/[page].tsx | 53 - pages/_app.tsx | 83 - pages/_document.tsx | 52 - pages/blog/[post].tsx | 113 - pages/blog/index.tsx | 92 - pages/index.tsx | 52 - pages/sitemap.xml.tsx | 45 - provider/live-preview.tsx | 124 + styles/{Home.module.css => Home.css} | 0 styles/style.css | 9 +- tsconfig.json | 10 +- 62 files changed, 10649 insertions(+), 12626 deletions(-) create mode 100644 app/[page]/page.tsx create mode 100644 app/app-layout.tsx create mode 100644 app/blog/[post]/blog-loader.css create mode 100644 app/blog/[post]/loading.tsx create mode 100644 app/blog/[post]/page.tsx create mode 100644 app/blog/blog-layout.css create mode 100644 app/blog/loading.tsx create mode 100644 app/blog/page.tsx create mode 100644 app/error.tsx create mode 100644 app/layout.tsx create mode 100644 app/loading.tsx create mode 100644 app/manifest.ts create mode 100644 app/not-found.tsx create mode 100644 app/page.tsx create mode 100644 app/robots.ts create mode 100644 app/sitemap.xml/route.ts create mode 100644 components/client-home-wrapper.tsx delete mode 100644 components/layout.tsx create mode 100644 components/liveprevew-init.tsx create mode 100644 components/navigation-progress.tsx create mode 100644 contentstack-sdk/config.ts create mode 100644 helper/live-preview.ts create mode 100644 middleware.ts delete mode 100644 pages/404.tsx delete mode 100644 pages/[page].tsx delete mode 100644 pages/_app.tsx delete mode 100644 pages/_document.tsx delete mode 100644 pages/blog/[post].tsx delete mode 100644 pages/blog/index.tsx delete mode 100644 pages/index.tsx delete mode 100644 pages/sitemap.xml.tsx create mode 100644 provider/live-preview.tsx rename styles/{Home.module.css => Home.css} (100%) diff --git a/.env.local.sample b/.env.local.sample index 194ec91..5ed0d32 100644 --- a/.env.local.sample +++ b/.env.local.sample @@ -3,17 +3,17 @@ # Contentstack is the tool we use to manage our website's content. # You need to replace 'your_stack_api_key', 'your_delivery_token', and 'your_environment_name' with the actual information. -CONTENTSTACK_API_KEY=your_stack_api_key -CONTENTSTACK_DELIVERY_TOKEN=your_delivery_token -CONTENTSTACK_ENVIRONMENT=your_environment_name +NEXT_PUBLIC_CONTENTSTACK_API_KEY=your_stack_api_key +NEXT_PUBLIC_CONTENTSTACK_DELIVERY_TOKEN=your_delivery_token +NEXT_PUBLIC_CONTENTSTACK_ENVIRONMENT=your_environment_name # Live Preview lets us see changes before they are shown on the website. # Replace 'your_live_preview_token' with the actual information. -CONTENTSTACK_PREVIEW_HOST=rest-preview.contentstack.com -CONTENTSTACK_PREVIEW_TOKEN=your_live_preview_token -CONTENTSTACK_APP_HOST=app.contentstack.com -CONTENTSTACK_LIVE_PREVIEW=true -CONTENTSTACK_LIVE_EDIT_TAGS=false +NEXT_PUBLIC_CONTENTSTACK_PREVIEW_HOST=rest-preview.contentstack.com +NEXT_PUBLIC_CONTENTSTACK_PREVIEW_TOKEN=your_live_preview_token +NEXT_PUBLIC_CONTENTSTACK_APP_HOST=app.contentstack.com +NEXT_PUBLIC_CONTENTSTACK_LIVE_PREVIEW=true +NEXT_PUBLIC_CONTENTSTACK_LIVE_EDIT_TAGS=false # These are extra settings. You can remove the '#' at the start of the line and fill these if needed. # CONTENTSTACK_API_HOST= api.contentstack.io diff --git a/.gitignore b/.gitignore index 737d872..ec1856b 100644 --- a/.gitignore +++ b/.gitignore @@ -26,6 +26,7 @@ yarn-error.log* .pnpm-debug.log* # local env files +.env .env*.local # vercel diff --git a/.npmrc b/.npmrc index 235a549..e69de29 100644 --- a/.npmrc +++ b/.npmrc @@ -1 +0,0 @@ -timeout=60000 \ No newline at end of file diff --git a/LICENSE b/LICENSE index ffb4ad0..25403cd 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2024 Contentstack +Copyright (c) 2025 Contentstack Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/app/[page]/page.tsx b/app/[page]/page.tsx new file mode 100644 index 0000000..53727df --- /dev/null +++ b/app/[page]/page.tsx @@ -0,0 +1,76 @@ +import { Metadata } from 'next'; +import { notFound } from 'next/navigation'; +import { getPageRes } from '../../helper'; +import { initializeLivePreview } from '@/helper/live-preview'; +import RenderComponents from '@/components/render-components'; + +interface PageParams { + params: { + page: string; + }; +} + +// Generate dynamic metadata for the page +export async function generateMetadata({ params }: PageParams): Promise { + try { + // Await the params object before accessing its properties + const pageParam = await params.page; + const entryUrl = pageParam.includes('/') ? pageParam : `/${pageParam}`; + const page = await getPageRes(entryUrl); + + if (page?.seo && page.seo.enable_search_indexing) { + const seoData: Record = {}; + + for (const key in page.seo) { + if (key !== 'enable_search_indexing') { + const metaKey = key.includes('meta_') ? key.split('meta_')[1] : key; + //@ts-ignore + seoData[metaKey] = page.seo[key].toString(); + } + } + + return { + title: seoData.title || `${pageParam} - Contentstack-Nextjs-Starter-App`, + description: seoData.description, + ...seoData + }; + } + + return { + title: `${pageParam} - Contentstack-Nextjs-Starter-App` + }; + } catch (error) { + console.error('Error generating metadata:', error); + return { + title: 'Contentstack-Nextjs-Starter-App' + }; + } +} + +export default async function DynamicPage({ params }: PageParams) { + try { + // Initialize LivePreview if applicable (handled by middleware + utility function) + await initializeLivePreview(); + + // Await the params object before accessing its properties + const pageParam = await params.page; + const entryUrl = pageParam.includes('/') ? pageParam : `/${pageParam}`; + const page = await getPageRes(entryUrl); + + if (!page) { + notFound(); + } + + return ( + + ); + } catch (error) { + console.error('Error in dynamic page:', error); + notFound(); + } +} \ No newline at end of file diff --git a/app/app-layout.tsx b/app/app-layout.tsx new file mode 100644 index 0000000..0e9f991 --- /dev/null +++ b/app/app-layout.tsx @@ -0,0 +1,106 @@ +import React from 'react'; +import Header from '../components/header'; +import Footer from '../components/footer'; +import DevTools from '../components/devtools'; +import { getHeaderRes, getFooterRes, getAllEntries } from '../helper'; +import { HeaderProps, FooterProps } from "../typescript/layout"; +import { Page } from '@/typescript/pages'; +import { unstable_cache } from 'next/cache'; +import { initializeLivePreview } from '@/helper/live-preview'; + +const getCachedNavigation = unstable_cache( + async (entries: Page[], header: HeaderProps, footer: FooterProps) => { + return dynamicHeadersAndFooter(entries, header, footer); + }, + ['navigation-data'], +); +// dynamically update header and footer page links +const dynamicHeadersAndFooter = (entries: Page[], header: HeaderProps, footer: FooterProps): [HeaderProps, FooterProps] => { + const newHeader = { ...header }; + const newFooter = { ...footer }; + + if (entries.length > 0 && newHeader.navigation_menu) { + entries.forEach((entry) => { + // Only process entries with valid title and URL + if (!entry.title || !entry.url) return; + + const hFound = newHeader.navigation_menu.find( + (navLink) => navLink.label === entry.title + ); + + if (!hFound) { + newHeader.navigation_menu.push({ + label: entry.title, + page_reference: [ + //@ts-ignore + { title: entry.title, url: entry.url, $: entry.$ }, + ], + $: {}, + }); + } + + const fFound = newFooter.navigation.link.find( + (nlink) => nlink.title === entry.title + ); + + if (!fFound) { + newFooter.navigation.link.push({ + title: entry.title, + href: entry.url, + //@ts-ignore + $: entry.$, + }); + } + }); + } + + return [newHeader, newFooter]; +} + +export default async function AppLayout({ + children, + hasLivePreview = false, +}: { + children: React.ReactNode; + hasLivePreview?: boolean; +}) { + try { + // Initialize LivePreview if the middleware detected LivePreview parameters + if (hasLivePreview) { + await initializeLivePreview(); + } + + const [headerData, footerData, entriesData] = await Promise.all([ + getHeaderRes(), + getFooterRes(), + getAllEntries() + ]); + + const [dynamicHeader, dynamicFooter] = await getCachedNavigation(entriesData, headerData, footerData); + + const JSON_DATA = { + header: dynamicHeader, + footer: dynamicFooter + }; + + return ( + <> + {dynamicHeader &&
} +
+ {children} + +
+ {dynamicFooter &&