-
Notifications
You must be signed in to change notification settings - Fork 2
CMS-45730 Add alloy template #139
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
TRomesh
wants to merge
11
commits into
main
Choose a base branch
from
feature/CMS-45730-add-alloy-template
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+1,973
−175
Open
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
ae01ebb
Init alloy template
TRomesh fa470d9
Add basic content types and basic components
TRomesh 0024878
Add new components Article, News, Standard, Start, and BlankSection.
TRomesh 8b5ebf6
Add news component and content types
TRomesh f2c8930
Refactor News, Standard, and BlankSection components for improved lay…
TRomesh 0f7dc25
Add env.example file with CMS configuration variables
TRomesh bf0f109
CMS-45730 Rename OPTIMIZELY_CMS_HOST to OPTIMIZELY_CMS_URL in env.exa…
TRomesh 6a57634
CMS-45730 Add Header and Footer components; implement breadcrumbs in …
TRomesh a9cfd70
CMS-45730 Add SEO, Site Settings property groups and update contet types
TRomesh a761fcd
CMS-45730 Move SEO to block type and import in pages/experience
TRomesh 7b71628
CMS-45730 Add Button component and update Start
TRomesh File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,5 @@ | ||
| packages: | ||
| - 'packages/*' | ||
| - 'samples/*' | ||
| - '__test__/*' | ||
| - 'templates/*' | ||
| - '__test__/*' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. | ||
|
|
||
| # dependencies | ||
| /node_modules | ||
| /.pnp | ||
| .pnp.* | ||
| .yarn/* | ||
| !.yarn/patches | ||
| !.yarn/plugins | ||
| !.yarn/releases | ||
| !.yarn/versions | ||
|
|
||
| # testing | ||
| /coverage | ||
|
|
||
| # next.js | ||
| /.next/ | ||
| /out/ | ||
|
|
||
| # production | ||
| /build | ||
|
|
||
| # misc | ||
| .DS_Store | ||
| *.pem | ||
|
|
||
| # debug | ||
| npm-debug.log* | ||
| yarn-debug.log* | ||
| yarn-error.log* | ||
| .pnpm-debug.log* | ||
|
|
||
| # env files (can opt-in for committing if needed) | ||
| .env* | ||
|
|
||
| # vercel | ||
| .vercel | ||
|
|
||
| # typescript | ||
| *.tsbuildinfo | ||
| next-env.d.ts | ||
|
|
||
| certificates |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| This is a [Next.js](https://nextjs.org) project bootstrapped with [`create-next-app`](https://nextjs.org/docs/app/api-reference/cli/create-next-app). | ||
|
|
||
| ## Getting Started | ||
|
|
||
| First, run the development server: | ||
|
|
||
| ```bash | ||
| npm run dev | ||
| # or | ||
| yarn dev | ||
| # or | ||
| pnpm dev | ||
| # or | ||
| bun dev | ||
| ``` | ||
|
|
||
| Open [http://localhost:3000](http://localhost:3000) with your browser to see the result. | ||
|
|
||
| You can start editing the page by modifying `app/page.tsx`. The page auto-updates as you edit the file. | ||
|
|
||
| This project uses [`next/font`](https://nextjs.org/docs/app/building-your-application/optimizing/fonts) to automatically optimize and load [Geist](https://vercel.com/font), a new font family for Vercel. | ||
|
|
||
| ## Learn More | ||
|
|
||
| To learn more about Next.js, take a look at the following resources: | ||
|
|
||
| - [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API. | ||
| - [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial. | ||
|
|
||
| You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js) - your feedback and contributions are welcome! | ||
|
|
||
| ## Deploy on Vercel | ||
|
|
||
| The easiest way to deploy your Next.js app is to use the [Vercel Platform](https://vercel.com/new?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme) from the creators of Next.js. | ||
|
|
||
| Check out our [Next.js deployment documentation](https://nextjs.org/docs/app/building-your-application/deploying) for more details. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| # Key to fetch content from the CMS. | ||
| # To get the key go to your CMS instance > Settings > API Keys | ||
| OPTIMIZELY_GRAPH_SINGLE_KEY='<SECRET>' | ||
|
|
||
| # Client ID and Secret from your CMS instance | ||
| # Go to your CMS instance > Settings > API Keys and click "Create API key" | ||
| OPTIMIZELY_CMS_CLIENT_ID= | ||
| OPTIMIZELY_CMS_CLIENT_SECRET= | ||
|
|
||
| # Root CMS instance. For example "https://<something>.cms.optimizely.com" | ||
| OPTIMIZELY_CMS_URL= | ||
| # From here, all environmental variables are optional | ||
| # | ||
| # Endpoint of GraphQL. Use this variable if you use a non-production instance or a different version | ||
| # OPTIMIZELY_GRAPH_URL=https://cg.optimizely.com/content/v2 | ||
| # |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| import type { NextConfig } from 'next'; | ||
|
|
||
| const nextConfig: NextConfig = { | ||
| images: { | ||
| domains: ['app-opinjssdk1sob7t001.cms.optimizely.com'], | ||
| remotePatterns: [ | ||
| { | ||
| protocol: 'https', | ||
| hostname: '*.cms.optimizely.com', | ||
| port: '', | ||
| pathname: '/**', | ||
| }, | ||
| ], | ||
| }, | ||
| }; | ||
|
|
||
| export default nextConfig; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| import { buildConfig } from '@optimizely/cms-sdk'; | ||
|
|
||
| export default buildConfig({ | ||
| components: ['./src/components/*.tsx', './src/components/**/*.tsx'], | ||
| propertyGroups: [ | ||
| { | ||
| key: 'SEO', | ||
| displayName: 'SEO', | ||
| sortOrder: 1, | ||
| }, | ||
| { | ||
| key: 'SiteSettings', | ||
| displayName: 'Site Settings', | ||
| sortOrder: 2, | ||
| }, | ||
| ], | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| { | ||
| "name": "alloy-template", | ||
| "version": "0.1.0", | ||
| "private": true, | ||
| "scripts": { | ||
| "dev": "next dev --experimental-https", | ||
| "build": "next build", | ||
| "start": "next start" | ||
| }, | ||
| "dependencies": { | ||
| "@optimizely/cms-sdk": "workspace:*", | ||
| "clsx": "^2.1.1", | ||
| "next": "15.5.4", | ||
| "react": "19.1.0", | ||
| "react-dom": "19.1.0", | ||
| "tailwind-merge": "^3.3.1" | ||
| }, | ||
| "devDependencies": { | ||
| "@optimizely/cms-cli": "workspace:*", | ||
| "@tailwindcss/postcss": "^4", | ||
| "@types/node": "^20", | ||
| "@types/react": "^19", | ||
| "@types/react-dom": "^19", | ||
| "tailwindcss": "^4", | ||
| "typescript": "^5" | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| const config = { | ||
| plugins: ["@tailwindcss/postcss"], | ||
| }; | ||
|
|
||
| export default config; |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| import Footer from '@/components/base/Footer'; | ||
| import Header from '@/components/base/Header'; | ||
| import { GraphClient } from '@optimizely/cms-sdk'; | ||
| import { OptimizelyComponent } from '@optimizely/cms-sdk/react/server'; | ||
| import { notFound } from 'next/navigation'; | ||
| import React from 'react'; | ||
|
|
||
| type Props = { | ||
| params: Promise<{ | ||
| slug: string[]; | ||
| }>; | ||
| }; | ||
|
|
||
| export default async function Page({ params }: Props) { | ||
| const { slug } = await params; | ||
|
|
||
| const client = new GraphClient(process.env.OPTIMIZELY_GRAPH_SINGLE_KEY!, { | ||
| graphUrl: process.env.OPTIMIZELY_GRAPH_URL, | ||
| }); | ||
| const path = `/${slug.join('/')}/`; | ||
| const c = await client.getContentByPath(path); | ||
|
|
||
| const children = (await client.getItems(path)) ?? []; | ||
| const ancestors = (await client.getPath(path)) ?? []; | ||
|
|
||
| if (c.length === 0) { | ||
| notFound(); | ||
| } | ||
|
|
||
| return ( | ||
| <> | ||
| <Header currentPath={{ children, ancestors }} /> | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Wouldn't it make more sense to let this component load its own data? |
||
| <div className="container mx-auto p-10"> | ||
| <OptimizelyComponent opti={c[0]} /> | ||
| </div> | ||
| <Footer /> | ||
| </> | ||
| ); | ||
| } | ||
Binary file not shown.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| @import 'tailwindcss'; | ||
|
|
||
| :root { | ||
| --background: #ffffff; | ||
| --foreground: #171717; | ||
| } | ||
|
|
||
| @theme inline { | ||
| --color-background: var(--background); | ||
| --color-foreground: var(--foreground); | ||
| --font-sans: var(--font-geist-sans); | ||
| --font-mono: var(--font-geist-mono); | ||
| } | ||
|
|
||
| /* @media (prefers-color-scheme: dark) { | ||
| :root { | ||
| --background: #0a0a0a; | ||
| --foreground: #ededed; | ||
| } | ||
| } */ | ||
|
|
||
| body { | ||
| background: var(--background); | ||
| color: var(--foreground); | ||
| font-family: Arial, Helvetica, sans-serif; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,83 @@ | ||
| import type { Metadata } from 'next'; | ||
| import { Geist, Geist_Mono } from 'next/font/google'; | ||
| import { | ||
| BlankExperienceContentType, | ||
| initContentTypeRegistry, | ||
| } from '@optimizely/cms-sdk'; | ||
| import { initReactComponentRegistry } from '@optimizely/cms-sdk/react/server'; | ||
|
|
||
| import './globals.css'; | ||
| import Teaser, { TeaserContentType } from '@/components/base/Teaser'; | ||
| import Editorial, { EditorialContentType } from '@/components/base/Editorial'; | ||
| import Contact, { ContactContentType } from '@/components/base/Contact'; | ||
| import Start, { StartContentType } from '@/components/Start'; | ||
| import Product, { ProductContentType } from '@/components/Product'; | ||
| import Standard, { StandardContentType } from '@/components/Standard'; | ||
| import Notice, { NoticeContentType } from '@/components/base/Notice'; | ||
| import News, { NewsContentType } from '@/components/News'; | ||
| import Article, { ArticleContentType } from '@/components/base/Article'; | ||
| import BlankSection from '@/components/base/BlankSection'; | ||
| import { SEOContentType } from '@/components/base/SEO'; | ||
| import Button, { ButtonContentType } from '@/components/base/Button'; | ||
|
|
||
| const geistSans = Geist({ | ||
| variable: '--font-geist-sans', | ||
| subsets: ['latin'], | ||
| }); | ||
|
|
||
| const geistMono = Geist_Mono({ | ||
| variable: '--font-geist-mono', | ||
| subsets: ['latin'], | ||
| }); | ||
|
|
||
| export const metadata: Metadata = { | ||
| title: 'Create Next App', | ||
| description: 'Generated by create next app', | ||
| }; | ||
|
|
||
| initContentTypeRegistry([ | ||
| ArticleContentType, | ||
| BlankExperienceContentType, | ||
| ContactContentType, | ||
| EditorialContentType, | ||
| NewsContentType, | ||
| NoticeContentType, | ||
| ProductContentType, | ||
| StartContentType, | ||
| TeaserContentType, | ||
| StandardContentType, | ||
| SEOContentType, | ||
| ButtonContentType, | ||
| ]); | ||
|
|
||
| initReactComponentRegistry({ | ||
| resolver: { | ||
| Article, | ||
| Contact, | ||
| Editorial, | ||
| News, | ||
| Notice, | ||
| Product, | ||
| Standard, | ||
| Start, | ||
| Teaser, | ||
| BlankSection, | ||
| Button, | ||
| }, | ||
| }); | ||
|
|
||
| export default async function RootLayout({ | ||
| children, | ||
| }: Readonly<{ | ||
| children: React.ReactNode; | ||
| }>) { | ||
| return ( | ||
| <html lang="en"> | ||
| <body | ||
| className={`${geistSans.variable} ${geistMono.variable} antialiased`} | ||
| > | ||
| {children} | ||
| </body> | ||
| </html> | ||
| ); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| export default function Home() { | ||
| return <></>; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| import { GraphClient, type PreviewParams } from '@optimizely/cms-sdk'; | ||
| import { OptimizelyComponent } from '@optimizely/cms-sdk/react/server'; | ||
| import { PreviewComponent } from '@optimizely/cms-sdk/react/client'; | ||
| import Script from 'next/script'; | ||
|
|
||
| type Props = { | ||
| searchParams: Promise<{ [key: string]: string | string[] | undefined }>; | ||
| }; | ||
|
|
||
| export default async function Page({ searchParams }: Props) { | ||
| const client = new GraphClient(process.env.OPTIMIZELY_GRAPH_SINGLE_KEY!, { | ||
| graphUrl: process.env.OPTIMIZELY_GRAPH_URL, | ||
| }); | ||
|
|
||
| const response = await client | ||
| .getPreviewContent( | ||
| // TODO: check types in runtime properly | ||
| (await searchParams) as PreviewParams | ||
| ) | ||
| .catch((err) => { | ||
| console.log(err.errors); | ||
| console.log(err.request?.query); | ||
| throw err; | ||
| }); | ||
|
|
||
| return ( | ||
| <> | ||
| <Script | ||
| src={`${process.env.OPTIMIZELY_CMS_URL}/util/javascript/communicationinjector.js`} | ||
| ></Script> | ||
| <PreviewComponent /> | ||
| <OptimizelyComponent opti={response} /> | ||
| </> | ||
| ); | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.