Skip to content

Commit

Permalink
Update CMS contentstack commerce example to the App Router (#842)
Browse files Browse the repository at this point in the history
Co-authored-by: Lee Robinson <[email protected]>
  • Loading branch information
lfades and leerob authored Dec 25, 2023
1 parent 3c5d318 commit 40a32c1
Show file tree
Hide file tree
Showing 54 changed files with 1,573 additions and 1,968 deletions.
22 changes: 12 additions & 10 deletions solutions/cms-contentstack-commerce/.gitignore
Original file line number Diff line number Diff line change
@@ -1,40 +1,42 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
# Dependencies
/node_modules
/.pnp
.pnp.js

# testing
# Testing
/coverage

# next.js
# Next.js
/.next/
/out/
next-env.d.ts

# production
/build
# Production
build
dist

# misc
# Misc
.DS_Store
*.pem

# debug
# Debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# local env files
# Local ENV files
.env.local
.env.development.local
.env.test.local
.env.production.local

# vercel
# Vercel
.vercel

# Turborepo
.turbo

# typescript
*.tsbuildinfo
*.tsbuildinfo
17 changes: 17 additions & 0 deletions solutions/cms-contentstack-commerce/app/[lang]/layout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/**
* We use a nested layout to define all the possible languages supported by all pages after /[lang]
*/

import type { ReactNode } from 'react'
import { LOCALES } from '@lib/i18n'

// Only the known locales are supported
export const dynamicParams = false

export async function generateStaticParams() {
return LOCALES.map((lang) => ({ lang }))
}

export default function DashboardLayout({ children }: { children: ReactNode }) {
return <>{children}</>
}
61 changes: 61 additions & 0 deletions solutions/cms-contentstack-commerce/app/[lang]/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
import type { Metadata } from 'next'
import { getEntry } from '@lib/contentstack'
import { Navbar } from '@components/ui/navbar'
import { Footer } from '@components/ui/footer'
import { UIComponent } from '@components/ui/ui-component'
import { Container } from '@components/ui/container'

type Props = {
params: { lang: string }
}

async function getHomeEntry(locale: string) {
const entry = await getEntry(
{
contentType: 'home_page',
entryId: 'blt5c760b6ce70ae18b',
locale,
},
{
next: { revalidate: 3600 }, // revalidate every hour
}
)
if (!entry) throw new Error('Home entry not found')
return entry
}

export async function generateMetadata({
params: { lang },
}: Props): Promise<Metadata> {
const { seo, title } = await getHomeEntry(lang)
return {
title: `${seo.title ? seo.title : title} - ${seo.description}`,
description: seo.description,
}
}

async function Page({ params: { lang } }: Props) {
const entry = await getHomeEntry(lang)
return (
<>
<Container>
<Navbar data={entry.header} />
{entry.modular_blocks.map(({ component }, i) => {
const { component_type, component_variant, ...rest } = component
return (
<UIComponent
key={`${component_type}_${i}`}
componentType={component_type}
componentVariant={component_variant}
data={rest}
priority={i < 3}
/>
)
})}
</Container>
<Footer />
</>
)
}

export default Page
26 changes: 26 additions & 0 deletions solutions/cms-contentstack-commerce/app/layout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import type { ReactNode } from 'react'
import { Metadata } from 'next'
import { Inter } from 'next/font/google'
import '../styles/globals.css'

// If loading a variable font, you don't need to specify the font weight
const inter = Inter({
subsets: ['latin'],
display: 'optional',
})

export const metadata: Metadata = {
title: 'Next.js and Contentstack',
description: 'Example using the Next.js App Router.',
}

export default function Layout({ children }: { children: ReactNode }) {
return (
<html className={inter.className}>
<head>
<link rel="icon" href="/favicon.ico" />
</head>
<body>{children}</body>
</html>
)
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export { default as Logo } from './Logo'
export { default as Bag } from './Bag'
export { default as Heart } from './Heart'
export { default as Trash } from './Trash'
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

118 changes: 0 additions & 118 deletions solutions/cms-contentstack-commerce/components/ui/Grid/Grid.tsx

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Loading

72 comments on commit 40a32c1

@vercel
Copy link

@vercel vercel bot commented on 40a32c1 Dec 25, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

postgres-pgvector – ./storage/postgres-pgvector

postgres-pgvector.vercel.app
postgres-pgvector-git-main.vercel.rocks
postgres-pgvector.vercel.rocks

@vercel
Copy link

@vercel vercel bot commented on 40a32c1 Dec 25, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

kv-redis-starter – ./storage/kv-redis-starter

kv-starter.vercel.app
kv-redis-starter.vercel.app
kv-redis-starter-git-main.vercel.rocks
nextjs-kv-starter.vercel.app
kv-redis-starter.vercel.rocks

@vercel
Copy link

@vercel vercel bot commented on 40a32c1 Dec 25, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

examples – ./storage/postgres-starter

examples-bice.vercel.app
examples.vercel.rocks
examples-git-main.vercel.rocks

@vercel
Copy link

@vercel vercel bot commented on 40a32c1 Dec 25, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

next-flask – ./python/nextjs-flask

nextjs-flask-starter.vercel.app
nextjs-python.vercel.app
next-flask.vercel.rocks
next-flask-git-main.vercel.rocks

@vercel
Copy link

@vercel vercel bot commented on 40a32c1 Dec 25, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vercel
Copy link

@vercel vercel bot commented on 40a32c1 Dec 25, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vercel
Copy link

@vercel vercel bot commented on 40a32c1 Dec 25, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vercel
Copy link

@vercel vercel bot commented on 40a32c1 Dec 25, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vercel
Copy link

@vercel vercel bot commented on 40a32c1 Dec 25, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vercel
Copy link

@vercel vercel bot commented on 40a32c1 Dec 25, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vercel
Copy link

@vercel vercel bot commented on 40a32c1 Dec 25, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vercel
Copy link

@vercel vercel bot commented on 40a32c1 Dec 25, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vercel
Copy link

@vercel vercel bot commented on 40a32c1 Dec 25, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vercel
Copy link

@vercel vercel bot commented on 40a32c1 Dec 25, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vercel
Copy link

@vercel vercel bot commented on 40a32c1 Dec 25, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vercel
Copy link

@vercel vercel bot commented on 40a32c1 Dec 25, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vercel
Copy link

@vercel vercel bot commented on 40a32c1 Dec 25, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vercel
Copy link

@vercel vercel bot commented on 40a32c1 Dec 25, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vercel
Copy link

@vercel vercel bot commented on 40a32c1 Dec 25, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vercel
Copy link

@vercel vercel bot commented on 40a32c1 Dec 25, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vercel
Copy link

@vercel vercel bot commented on 40a32c1 Dec 25, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vercel
Copy link

@vercel vercel bot commented on 40a32c1 Dec 25, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vercel
Copy link

@vercel vercel bot commented on 40a32c1 Dec 25, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vercel
Copy link

@vercel vercel bot commented on 40a32c1 Dec 25, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vercel
Copy link

@vercel vercel bot commented on 40a32c1 Dec 25, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

edge-functions-news – ./starter/next-news

edge-functions-news-now-examples.vercel.app
edge-functions-news-git-main-now-examples.vercel.app
edge-functions-next-news.vercel.sh

@vercel
Copy link

@vercel vercel bot commented on 40a32c1 Dec 25, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vercel
Copy link

@vercel vercel bot commented on 40a32c1 Dec 25, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vercel
Copy link

@vercel vercel bot commented on 40a32c1 Dec 25, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vercel
Copy link

@vercel vercel bot commented on 40a32c1 Dec 25, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

solutions-image-offset – ./solutions/image-offset

solutions-image-offset-git-main-now-examples.vercel.app
solutions-image-offset.vercel.app
solutions-image-offset-now-examples.vercel.app

@vercel
Copy link

@vercel vercel bot commented on 40a32c1 Dec 25, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vercel
Copy link

@vercel vercel bot commented on 40a32c1 Dec 25, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vercel
Copy link

@vercel vercel bot commented on 40a32c1 Dec 25, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vercel
Copy link

@vercel vercel bot commented on 40a32c1 Dec 25, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vercel
Copy link

@vercel vercel bot commented on 40a32c1 Dec 25, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vercel
Copy link

@vercel vercel bot commented on 40a32c1 Dec 25, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

edge-rewrites-upstash – ./edge-middleware/rewrites-upstash

edge-rewrites-upstash.vercel.app
edge-rewrites-upstash-now-examples.vercel.app
edge-rewrites-upstash.vercel.sh
edge-rewrites-upstash-git-main-now-examples.vercel.app

@vercel
Copy link

@vercel vercel bot commented on 40a32c1 Dec 25, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vercel
Copy link

@vercel vercel bot commented on 40a32c1 Dec 25, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

solutions-on-demand-isr – ./solutions/on-demand-isr

solutions-on-demand-isr-git-main-now-examples.vercel.app
solutions-on-demand-isr-now-examples.vercel.app
solutions-on-demand-isr.vercel.app

@vercel
Copy link

@vercel vercel bot commented on 40a32c1 Dec 25, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vercel
Copy link

@vercel vercel bot commented on 40a32c1 Dec 25, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vercel
Copy link

@vercel vercel bot commented on 40a32c1 Dec 25, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vercel
Copy link

@vercel vercel bot commented on 40a32c1 Dec 25, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

solutions-loading-web-fonts – ./solutions/loading-web-fonts

solutions-loading-web-fonts-now-examples.vercel.app
solutions-loading-web-fonts.vercel.app
solutions-loading-web-fonts-git-main-now-examples.vercel.app

@vercel
Copy link

@vercel vercel bot commented on 40a32c1 Dec 25, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

edge-user-agent-based-rendering – ./edge-middleware/user-agent-based-rendering

edge-user-agent-based-rendering-now-examples.vercel.app
edge-user-agent-based-rendering.vercel.app
edge-user-agent-based-rendering-git-main-now-examples.vercel.app

@vercel
Copy link

@vercel vercel bot commented on 40a32c1 Dec 25, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

feature-flag-optimizely – ./edge-middleware/feature-flag-optimizely

feature-flag-optimizely.vercel.app
feature-flag-optimizely-git-main-now-examples.vercel.app
feature-flag-optimizely-now-examples.vercel.app

@vercel
Copy link

@vercel vercel bot commented on 40a32c1 Dec 25, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

solutions-script-component-ad – ./solutions/script-component-ad

solutions-script-component-ad.vercel.app
solutions-script-component-ad-git-main-now-examples.vercel.app
solutions-script-component-ad-now-examples.vercel.app

@vercel
Copy link

@vercel vercel bot commented on 40a32c1 Dec 25, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

edge-ab-testing-statsig – ./edge-middleware/ab-testing-statsig

edge-ab-testing-statsig-now-examples.vercel.app
edge-ab-testing-statsig.vercel.app
edge-ab-testing-statsig-git-main-now-examples.vercel.app
edge-ab-testing-statsig.vercel.sh

@vercel
Copy link

@vercel vercel bot commented on 40a32c1 Dec 25, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

solutions-microfrontends – ./solutions/microfrontends/apps/main

solutions-microfrontends-git-main-now-examples.vercel.app
microfrontends.vercel.sh
solutions-microfrontends-now-examples.vercel.app
solutions-microfrontends.vercel.app

@vercel
Copy link

@vercel vercel bot commented on 40a32c1 Dec 25, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

edge-maintenance-page – ./edge-middleware/maintenance-page

edge-maintenance-page-now-examples.vercel.app
edge-maintenance-page.vercel.app
edge-maintenance-page-git-main-now-examples.vercel.app
edge-maintenance-page.vercel.sh

@vercel
Copy link

@vercel vercel bot commented on 40a32c1 Dec 25, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vercel
Copy link

@vercel vercel bot commented on 40a32c1 Dec 25, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

i18n – ./edge-middleware/i18n

i18n-git-main-now-examples.vercel.app
middleware-i18n.vercel.app
i18n-now-examples.vercel.app
i18n.vercel.sh

@vercel
Copy link

@vercel vercel bot commented on 40a32c1 Dec 25, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vercel
Copy link

@vercel vercel bot commented on 40a32c1 Dec 25, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vercel
Copy link

@vercel vercel bot commented on 40a32c1 Dec 25, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

app-dir-share-state – ./app-directory/share-state

app-dir-share-state-git-main-now-examples.vercel.app
app-dir-share-state.vercel.app
app-dir-share-state-now-examples.vercel.app

@vercel
Copy link

@vercel vercel bot commented on 40a32c1 Dec 25, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

app-dir-css-in-js – ./app-directory/css-in-js

app-dir-css-in-js.vercel.app
app-dir-css-in-js-now-examples.vercel.app
app-dir-css-in-js-git-main-now-examples.vercel.app

@vercel
Copy link

@vercel vercel bot commented on 40a32c1 Dec 25, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

app-dir-i18n – ./app-directory/i18n

app-dir-i18n-git-main-now-examples.vercel.app
app-dir-i18n.vercel.app
app-dir-i18n-now-examples.vercel.app

@vercel
Copy link

@vercel vercel bot commented on 40a32c1 Dec 25, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

edge-geolocation-country-block – ./edge-middleware/geolocation-country-block

edge-geolocation-country-block-now-examples.vercel.app
edge-geolocation-country-block-git-main-now-examples.vercel.app
edge-geolocation-country-block.vercel.app

@vercel
Copy link

@vercel vercel bot commented on 40a32c1 Dec 25, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vercel
Copy link

@vercel vercel bot commented on 40a32c1 Dec 25, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

edge-middleware-modify-request-header – ./edge-middleware/modify-request-header

edge-middleware-modify-request-header-git-main-now-examples.vercel.app
edge-middleware-modify-request-header-now-examples.vercel.app
edge-middleware-modify-request-header.vercel.app

@vercel
Copy link

@vercel vercel bot commented on 40a32c1 Dec 25, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

feature-flag-launchdarkly – ./edge-middleware/feature-flag-launchdarkly

feature-flag-launchdarkly-git-main-now-examples.vercel.app
feature-flag-launchdarkly.vercel.app
feature-flag-launchdarkly-now-examples.vercel.app

@vercel
Copy link

@vercel vercel bot commented on 40a32c1 Dec 25, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

nodejs-api – ./solutions/node-hello-world

nodejs-api-example.vercel.app
nodejs-api-now-examples.vercel.app
nodejs-api-git-main-now-examples.vercel.app
nodejs-api-murex.vercel.app

@vercel
Copy link

@vercel vercel bot commented on 40a32c1 Dec 25, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

feature-flag-hypertune – ./edge-middleware/feature-flag-hypertune

feature-flag-hypertune-now-examples.vercel.app
feature-flag-hypertune-git-main-now-examples.vercel.app
feature-flag-hypertune.vercel.app

Please sign in to comment.