forked from vercel/next.js
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added Agility CMS example 🏆 (vercel#12788)
- Loading branch information
Showing
55 changed files
with
1,821 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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,4 @@ | ||
NEXT_EXAMPLE_CMS_AGILITY_GUID= | ||
NEXT_EXAMPLE_CMS_AGILITY_API_FETCH_KEY= | ||
NEXT_EXAMPLE_CMS_AGILITY_API_PREVIEW_KEY= | ||
NEXT_EXAMPLE_CMS_AGILITY_SECURITY_KEY= |
This file contains 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,2 @@ | ||
.env*.local | ||
.vercel |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains 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,42 @@ | ||
import Container from './container' | ||
import cn from 'classnames' | ||
import { EXAMPLE_PATH } from '../lib/constants' | ||
|
||
export default function Alert({ preview }) { | ||
return ( | ||
<div | ||
className={cn('border-b', { | ||
'bg-accent-7 border-accent-7 text-white': preview, | ||
'bg-accent-1 border-accent-2': !preview, | ||
})} | ||
> | ||
<Container> | ||
<div className="py-2 text-center text-sm"> | ||
{preview ? ( | ||
<> | ||
This is page is a preview.{' '} | ||
<a | ||
href="/api/exit-preview" | ||
className="underline hover:text-cyan duration-200 transition-colors" | ||
> | ||
Click here | ||
</a>{' '} | ||
to exit preview mode. | ||
</> | ||
) : ( | ||
<> | ||
The source code for this blog is{' '} | ||
<a | ||
href={`https://github.com/zeit/next.js/tree/canary/examples/${EXAMPLE_PATH}`} | ||
className="underline hover:text-success duration-200 transition-colors" | ||
> | ||
available on GitHub | ||
</a> | ||
. | ||
</> | ||
)} | ||
</div> | ||
</Container> | ||
</div> | ||
) | ||
} |
This file contains 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,12 @@ | ||
export default function Avatar({ name, picture }) { | ||
return ( | ||
<div className="flex items-center"> | ||
<img | ||
src={picture.url} | ||
className="w-12 h-12 rounded-full mr-4" | ||
alt={name} | ||
/> | ||
<div className="text-xl font-bold">{name}</div> | ||
</div> | ||
) | ||
} |
This file contains 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 Container({ children }) { | ||
return <div className="container mx-auto px-5">{children}</div> | ||
} |
This file contains 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,28 @@ | ||
//import { Image } from 'react-datocms' | ||
import Image from '../lib/components/image' | ||
import cn from 'classnames' | ||
import Link from 'next/link' | ||
|
||
export default function CoverImage({ title, responsiveImage, slug }) { | ||
const image = ( | ||
<Image | ||
data={{ | ||
...responsiveImage, | ||
}} | ||
className={cn('shadow-small', { | ||
'hover:shadow-medium transition-shadow duration-200': slug, | ||
})} | ||
/> | ||
) | ||
return ( | ||
<div className="-mx-5 sm:mx-0"> | ||
{slug ? ( | ||
<Link href="/[...slug]" as={`/posts/${slug}`}> | ||
<a aria-label={title}>{image}</a> | ||
</Link> | ||
) : ( | ||
image | ||
)} | ||
</div> | ||
) | ||
} |
This file contains 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,6 @@ | ||
import { parseISO, format } from 'date-fns' | ||
|
||
export default function Date({ dateString }) { | ||
const date = parseISO(dateString) | ||
return <time dateTime={dateString}>{format(date, 'LLLL d, yyyy')}</time> | ||
} |
This file contains 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,30 @@ | ||
import Container from './container' | ||
import { EXAMPLE_PATH } from '../lib/constants' | ||
|
||
export default function Footer() { | ||
return ( | ||
<footer className="bg-accent-1 border-t border-accent-2"> | ||
<Container> | ||
<div className="py-28 flex flex-col lg:flex-row items-center"> | ||
<h3 className="text-4xl lg:text-5xl font-bold tracking-tighter leading-tight text-center lg:text-left mb-10 lg:mb-0 lg:pr-4 lg:w-1/2"> | ||
Statically Generated with Next.js. | ||
</h3> | ||
<div className="flex flex-col lg:flex-row justify-center items-center lg:pl-4 lg:w-1/2"> | ||
<a | ||
href="https://nextjs.org/docs/basic-features/pages" | ||
className="mx-3 bg-black hover:bg-white hover:text-black border border-black text-white font-bold py-3 px-12 lg:px-8 duration-200 transition-colors mb-6 lg:mb-0" | ||
> | ||
Read Documentation | ||
</a> | ||
<a | ||
href={`https://github.com/zeit/next.js/tree/canary/examples/${EXAMPLE_PATH}`} | ||
className="mx-3 font-bold hover:underline" | ||
> | ||
View on GitHub | ||
</a> | ||
</div> | ||
</div> | ||
</Container> | ||
</footer> | ||
) | ||
} |
This file contains 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,12 @@ | ||
import Link from 'next/link' | ||
|
||
export default function Header() { | ||
return ( | ||
<h2 className="text-2xl md:text-4xl font-bold tracking-tight md:tracking-tighter leading-tight mb-20 mt-8"> | ||
<Link href="/"> | ||
<a className="hover:underline">Blog</a> | ||
</Link> | ||
. | ||
</h2> | ||
) | ||
} |
This file contains 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,49 @@ | ||
import Link from 'next/link' | ||
import Avatar from '../components/avatar' | ||
import Date from '../components/date' | ||
import CoverImage from '../components/cover-image' | ||
|
||
export default function HeroPost({ | ||
title, | ||
coverImage, | ||
date, | ||
excerpt, | ||
author, | ||
slug, | ||
}) { | ||
return ( | ||
<section> | ||
<div className="mb-8 md:mb-16"> | ||
<CoverImage | ||
title={title} | ||
responsiveImage={coverImage.responsiveImage} | ||
slug={slug} | ||
/> | ||
</div> | ||
<div className="md:grid md:grid-cols-2 md:col-gap-16 lg:col-gap-8 mb-20 md:mb-28"> | ||
<div> | ||
<h3 className="mb-4 text-4xl lg:text-6xl leading-tight"> | ||
<Link href="/[...slug]" as={`/posts/${slug}`}> | ||
<a className="hover:underline">{title}</a> | ||
</Link> | ||
</h3> | ||
<div className="mb-4 md:mb-0 text-lg"> | ||
<Date dateString={date} /> | ||
</div> | ||
</div> | ||
{author && ( | ||
<div> | ||
<p className="text-lg leading-relaxed mb-4">{excerpt}</p> | ||
<Avatar name={author.name} picture={author.picture} /> | ||
</div> | ||
)} | ||
</div> | ||
</section> | ||
) | ||
} | ||
|
||
// The data returned here will be send as `props` to the component | ||
HeroPost.getCustomInitialProps = async function ({ client }) { | ||
const post = await client.getLatestPost() | ||
return post | ||
} |
This file contains 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,28 @@ | ||
import { CMS_NAME, CMS_URL } from '../lib/constants' | ||
|
||
export default function Intro() { | ||
return ( | ||
<section className="flex-col md:flex-row flex items-center md:justify-between mt-16 mb-16 md:mb-12"> | ||
<h1 className="text-6xl md:text-8xl font-bold tracking-tighter leading-tight md:pr-8"> | ||
Blog. | ||
</h1> | ||
<h4 className="text-center md:text-left text-lg mt-5 md:pl-8"> | ||
A statically generated blog example using{' '} | ||
<a | ||
href="https://nextjs.org/" | ||
className="underline hover:text-success duration-200 transition-colors" | ||
> | ||
Next.js | ||
</a>{' '} | ||
and{' '} | ||
<a | ||
href={CMS_URL} | ||
className="underline hover:text-success duration-200 transition-colors" | ||
> | ||
{CMS_NAME} | ||
</a> | ||
. | ||
</h4> | ||
</section> | ||
) | ||
} |
This file contains 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 @@ | ||
import Alert from '../components/alert' | ||
import Footer from '../components/footer' | ||
import Meta from '../components/meta' | ||
|
||
export default function Layout({ preview, children }) { | ||
return ( | ||
<> | ||
<Meta /> | ||
<div className="min-h-screen"> | ||
<Alert preview={preview} /> | ||
<main>{children}</main> | ||
</div> | ||
<Footer /> | ||
</> | ||
) | ||
} |
18 changes: 18 additions & 0 deletions
18
examples/cms-agilitycms/components/markdown-styles.module.css
This file contains 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,18 @@ | ||
.markdown { | ||
@apply text-lg leading-relaxed; | ||
} | ||
|
||
.markdown p, | ||
.markdown ul, | ||
.markdown ol, | ||
.markdown blockquote { | ||
@apply my-6; | ||
} | ||
|
||
.markdown h2 { | ||
@apply text-3xl mt-12 mb-4 leading-snug; | ||
} | ||
|
||
.markdown h3 { | ||
@apply text-2xl mt-8 mb-4 leading-snug; | ||
} |
This file contains 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,42 @@ | ||
import Head from 'next/head' | ||
import { CMS_NAME, HOME_OG_IMAGE_URL } from '../lib/constants' | ||
|
||
export default function Meta() { | ||
return ( | ||
<Head> | ||
<link | ||
rel="apple-touch-icon" | ||
sizes="180x180" | ||
href="/favicon/apple-touch-icon.png" | ||
/> | ||
<link | ||
rel="icon" | ||
type="image/png" | ||
sizes="32x32" | ||
href="/favicon/favicon-32x32.png" | ||
/> | ||
<link | ||
rel="icon" | ||
type="image/png" | ||
sizes="16x16" | ||
href="/favicon/favicon-16x16.png" | ||
/> | ||
<link rel="manifest" href="/favicon/site.webmanifest" /> | ||
<link | ||
rel="mask-icon" | ||
href="/favicon/safari-pinned-tab.svg" | ||
color="#000000" | ||
/> | ||
<link rel="shortcut icon" href="/favicon/favicon.ico" /> | ||
<meta name="msapplication-TileColor" content="#000000" /> | ||
<meta name="msapplication-config" content="/favicon/browserconfig.xml" /> | ||
<meta name="theme-color" content="#000" /> | ||
<link rel="alternate" type="application/rss+xml" href="/feed.xml" /> | ||
<meta | ||
name="description" | ||
content={`A statically generated blog example using Next.js and ${CMS_NAME}.`} | ||
/> | ||
<meta property="og:image" content={HOME_OG_IMAGE_URL} /> | ||
</Head> | ||
) | ||
} |
This file contains 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 PostPreview from '../components/post-preview' | ||
|
||
export default function MoreStories({ title, posts }) { | ||
return ( | ||
<section> | ||
<h2 className="mb-8 text-6xl md:text-7xl font-bold tracking-tighter leading-tight"> | ||
{title} | ||
</h2> | ||
<div className="grid grid-cols-1 md:grid-cols-2 md:col-gap-16 lg:col-gap-32 row-gap-20 md:row-gap-32 mb-32"> | ||
{posts.map((post) => ( | ||
<PostPreview | ||
key={post.slug} | ||
title={post.title} | ||
coverImage={post.coverImage} | ||
date={post.date} | ||
author={post.author} | ||
slug={post.slug} | ||
excerpt={post.excerpt} | ||
/> | ||
))} | ||
</div> | ||
</section> | ||
) | ||
} | ||
|
||
// The data returned here will be send as `props` to the component | ||
MoreStories.getCustomInitialProps = async function ({ | ||
client, | ||
item, | ||
pageInSitemap, | ||
}) { | ||
const postToExcludeContentID = pageInSitemap.contentID ?? -1 | ||
const posts = await client.getPostsForMoreStories({ postToExcludeContentID }) | ||
|
||
return { | ||
title: item.fields.title, | ||
posts, | ||
} | ||
} |
This file contains 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,12 @@ | ||
import markdownStyles from './markdown-styles.module.css' | ||
|
||
export default function PostBody({ content }) { | ||
return ( | ||
<div className="max-w-2xl mx-auto"> | ||
<div | ||
className={markdownStyles['markdown']} | ||
dangerouslySetInnerHTML={{ __html: content }} | ||
/> | ||
</div> | ||
) | ||
} |
Oops, something went wrong.