Skip to content
Draft
Show file tree
Hide file tree
Changes from 30 commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
f7f3265
Merge pull request #99 from contentstack/staging
Amitkanswal Feb 29, 2024
ef0716e
sca-scan.yml
aravindbuilt Jun 18, 2024
bcabe54
jira.yml
aravindbuilt Jun 18, 2024
8ae9a5a
sast-scan.yml
aravindbuilt Jun 18, 2024
e3764b7
codeql-analysis.yml
aravindbuilt Jun 18, 2024
a88c627
sca-scan.yml
aravindbuilt Oct 22, 2024
e22a7f1
sca-scan.yml
aravindbuilt Oct 22, 2024
d887268
jira.yml
aravindbuilt Oct 22, 2024
f0e85d0
sast-scan.yml
aravindbuilt Oct 22, 2024
edb64f4
codeql-analysis.yml
aravindbuilt Oct 22, 2024
328c66e
Updated codeowners
aravindbuilt Oct 22, 2024
566cccd
sca-scan.yml
aravindbuilt Jan 19, 2025
70ee17a
jira.yml
aravindbuilt Jan 19, 2025
cfdeb35
sast-scan.yml
aravindbuilt Jan 19, 2025
2c69012
codeql-analysis.yml
aravindbuilt Jan 19, 2025
45e0d83
Updated codeowners
aravindbuilt Jan 19, 2025
9fc025f
policy-scan.yml
aravindbuilt Apr 16, 2025
1142cfd
issues-jira.yml
aravindbuilt Apr 16, 2025
e36e98c
Delete jira.yml
aravindbuilt Apr 16, 2025
9248d7a
Delete sast-scan.yml
aravindbuilt Apr 16, 2025
3ca44e8
codeql-analysis.yml
aravindbuilt Apr 16, 2025
34d084e
Updated codeowners
aravindbuilt Apr 16, 2025
a28a0bf
policy-scan.yml
aravindbuilt Apr 23, 2025
fb1697f
policy-scan.yml
aravindbuilt May 6, 2025
32b64df
issues-jira.yml
aravindbuilt May 6, 2025
974afc1
secrets-scan.yml
aravindbuilt May 6, 2025
5c7fda0
talismanrc file updated
aravindbuilt May 6, 2025
112a157
Updated codeowners
aravindbuilt May 6, 2025
bb83c28
feat:updated next to latest
Amitkanswal May 22, 2025
a009d96
fix:build and devTool issues
Amitkanswal May 23, 2025
752032b
fix:review changes
Amitkanswal May 23, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions .env.local.sample
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
31 changes: 31 additions & 0 deletions .github/workflows/issues-jira.yml
Original file line number Diff line number Diff line change
@@ -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 }}"
33 changes: 0 additions & 33 deletions .github/workflows/jira.yml

This file was deleted.

46 changes: 46 additions & 0 deletions .github/workflows/policy-scan.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
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: |
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
2 changes: 1 addition & 1 deletion .github/workflows/sca-scan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ on:
pull_request:
types: [opened, synchronize, reopened]
jobs:
security:
security-sca:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
Expand Down
29 changes: 29 additions & 0 deletions .github/workflows/secrets-scan.yml
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ yarn-error.log*
.pnpm-debug.log*

# local env files
.env
.env*.local

# vercel
Expand Down
1 change: 0 additions & 1 deletion .npmrc
Original file line number Diff line number Diff line change
@@ -1 +0,0 @@
timeout=60000
5 changes: 5 additions & 0 deletions .talismanrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
fileignoreconfig:
- filename: .github/workflows/secrets-scan.yml
ignore_detectors:
- filecontent
version: "1.0"
2 changes: 1 addition & 1 deletion CODEOWNERS
Original file line number Diff line number Diff line change
@@ -1 +1 @@
* @contentstack/security-admin
* @contentstack/security-admin
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -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
Expand Down
91 changes: 91 additions & 0 deletions app/[page]/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
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';
import { DevToolsClient } from '@/components/devToolClient';

interface PageProps {
params: Promise<{
page: string;
}>;
searchParams: Promise<{
[key: string]: string | string[] | undefined;
}>;
}

export async function generateMetadata({ params }: PageProps): Promise<Metadata> {
try {
const resolvedParams = await params;
const pageParam = resolvedParams.page;
const entryUrl = pageParam.includes('/') ? pageParam : `/${pageParam}`;
const page = await getPageRes(entryUrl);

if (page?.seo && page.seo.enable_search_indexing) {
const seoData: Record<string, string> = {};

for (const key in page.seo) {
if (key !== 'enable_search_indexing') {
const metaKey = key.includes('meta_') ? key.split('meta_')[1] : key;
const value = (page.seo as Record<string, unknown>)[key];
if (typeof value === 'string') {
seoData[metaKey] = value;
} else if (value !== null && value !== undefined) {
seoData[metaKey] = String(value);
}
}
}

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, searchParams }: PageProps) {
try {
const [resolvedParams, resolvedSearchParams] = await Promise.all([
params,
searchParams
]);

const filteredSearchParams = Object.fromEntries(
Object.entries(resolvedSearchParams).filter(([_, value]) => value !== undefined)
) as Record<string, string | string[]>;

await initializeLivePreview(filteredSearchParams);
const pageParam = resolvedParams.page;
const entryUrl = pageParam.includes('/') ? pageParam : `/${pageParam}`;
const page = await getPageRes(entryUrl);

if (!page) {
notFound();
}

return (
<DevToolsClient page={{page:page}} requiredField={['page']}>
<RenderComponents
pageComponents={page.page_components}
contentTypeUid="page"
entryUid={page.uid}
locale={page.locale}
/>
</DevToolsClient>
);
} catch (error) {
console.error('Error in dynamic page:', error);
notFound();
}
}
Loading
Loading