Unverified Commit 88ac118d authored by Kasper Andreassen's avatar Kasper Andreassen Committed by GitHub

Add Enterspeed blog example (#35897)

# Demo: https://next-blog-demo.enterspeed.com/

Added `with-enterspeed` to examples.

Linked to `with-enterspeed` in related documentation:
- docs/advanced-features/preview-mode.md
- docs/basic-features/data-fetching/overview.md
- docs/basic-features/pages.md

Linked to `with-enterspeed` in related examples:
- examples/blog-starter/README.md
- examples/cms-agilitycms/README.md
- examples/cms-builder-io/README.md
- examples/cms-buttercms/README.md
- examples/cms-contentful/README.md
- examples/cms-cosmic/README.md
- examples/cms-datocms/README.md
- examples/cms-drupal/README.md
- examples/cms-ghost/README.md
- examples/cms-graphcms/README.md
- examples/cms-kontent/README.md
- examples/cms-prepr/README.md
- examples/cms-prismic/README.md
- examples/cms-sanity/README.md
- examples/cms-storyblok/README.md
- examples/cms-strapi/README.md
- examples/cms-takeshape/README.md
- examples/cms-tina/README.md
- examples/cms-umbraco-heartcore/README.md
parent c5d2c2d9
...@@ -25,6 +25,7 @@ description: Next.js has the preview mode for statically generated pages. You ca ...@@ -25,6 +25,7 @@ description: Next.js has the preview mode for statically generated pages. You ca
<li><a href="https://github.com/vercel/next.js/tree/canary/examples/cms-kontent">Kontent Example</a> (<a href="https://next-blog-kontent.vercel.app//">Demo</a>)</li> <li><a href="https://github.com/vercel/next.js/tree/canary/examples/cms-kontent">Kontent Example</a> (<a href="https://next-blog-kontent.vercel.app//">Demo</a>)</li>
<li><a href="https://github.com/vercel/next.js/tree/canary/examples/cms-umbraco-heartcore">Umbraco Heartcore Example</a> (<a href="https://next-blog-umbraco-heartcore.vercel.app/">Demo</a>)</li> <li><a href="https://github.com/vercel/next.js/tree/canary/examples/cms-umbraco-heartcore">Umbraco Heartcore Example</a> (<a href="https://next-blog-umbraco-heartcore.vercel.app/">Demo</a>)</li>
<li><a href="https://github.com/vercel/next.js/tree/canary/examples/cms-plasmic">Plasmic Example</a> (<a href="https://nextjs-plasmic-example.vercel.app/">Demo</a>)</li> <li><a href="https://github.com/vercel/next.js/tree/canary/examples/cms-plasmic">Plasmic Example</a> (<a href="https://nextjs-plasmic-example.vercel.app/">Demo</a>)</li>
<li><a href="https://github.com/vercel/next.js/tree/canary/examples/cms-enterspeed">Enterspeed Example</a> (<a href="https://next-blog-demo.enterspeed.com/">Demo</a>)</li>
<li><a href="https://github.com/vercel/next.js/tree/canary/examples/cms-makeswift">Makeswift Example</a> (<a href="https://nextjs-makeswift-example.vercel.app/">Demo</a>)</li> <li><a href="https://github.com/vercel/next.js/tree/canary/examples/cms-makeswift">Makeswift Example</a> (<a href="https://nextjs-makeswift-example.vercel.app/">Demo</a>)</li>
</ul> </ul>
</details> </details>
......
...@@ -23,6 +23,7 @@ description: 'Next.js allows you to fetch data in multiple ways, with pre-render ...@@ -23,6 +23,7 @@ description: 'Next.js allows you to fetch data in multiple ways, with pre-render
<li><a href="https://github.com/vercel/next.js/tree/canary/examples/cms-graphcms">GraphCMS Example</a> (<a href="https://next-blog-graphcms.vercel.app/">Demo</a>)</li> <li><a href="https://github.com/vercel/next.js/tree/canary/examples/cms-graphcms">GraphCMS Example</a> (<a href="https://next-blog-graphcms.vercel.app/">Demo</a>)</li>
<li><a href="https://github.com/vercel/next.js/tree/canary/examples/cms-kontent">Kontent Example</a> (<a href="https://next-blog-kontent.vercel.app/">Demo</a>)</li> <li><a href="https://github.com/vercel/next.js/tree/canary/examples/cms-kontent">Kontent Example</a> (<a href="https://next-blog-kontent.vercel.app/">Demo</a>)</li>
<li><a href="https://static-tweet.vercel.app/">Static Tweet Demo</a></li> <li><a href="https://static-tweet.vercel.app/">Static Tweet Demo</a></li>
<li><a href="https://github.com/vercel/next.js/tree/canary/examples/cms-enterspeed">Enterspeed Example</a> (<a href="https://next-blog-demo.enterspeed.com/">Demo</a>)</li>
</ul> </ul>
</details> </details>
......
...@@ -66,6 +66,7 @@ You can also use **Client-side data fetching** along with Static Generation or S ...@@ -66,6 +66,7 @@ You can also use **Client-side data fetching** along with Static Generation or S
<li><a href="https://github.com/vercel/next.js/tree/canary/examples/cms-builder-io">Builder.io Example</a> (<a href="https://cms-builder-io.vercel.app/">Demo</a>)</li> <li><a href="https://github.com/vercel/next.js/tree/canary/examples/cms-builder-io">Builder.io Example</a> (<a href="https://cms-builder-io.vercel.app/">Demo</a>)</li>
<li><a href="https://github.com/vercel/next.js/tree/canary/examples/cms-tina">TinaCMS Example</a> (<a href="https://cms-tina-example.vercel.app/">Demo</a>)</li> <li><a href="https://github.com/vercel/next.js/tree/canary/examples/cms-tina">TinaCMS Example</a> (<a href="https://cms-tina-example.vercel.app/">Demo</a>)</li>
<li><a href="https://static-tweet.vercel.app/">Static Tweet (Demo)</a></li> <li><a href="https://static-tweet.vercel.app/">Static Tweet (Demo)</a></li>
<li><a href="https://github.com/vercel/next.js/tree/canary/examples/cms-enterspeed">Enterspeed Example</a> (<a href="https://next-blog-demo.enterspeed.com/">Demo</a>)</li>
</ul> </ul>
</details> </details>
......
...@@ -36,6 +36,7 @@ Deploy the example using [Vercel](https://vercel.com?utm_source=github&utm_mediu ...@@ -36,6 +36,7 @@ Deploy the example using [Vercel](https://vercel.com?utm_source=github&utm_mediu
- [Umbraco Heartcore](/examples/cms-umbraco-heartcore) - [Umbraco Heartcore](/examples/cms-umbraco-heartcore)
- [Builder.io](/examples/cms-builder-io) - [Builder.io](/examples/cms-builder-io)
- [TinaCMS](/examples/cms-tina/) - [TinaCMS](/examples/cms-tina/)
- [Enterspeed](/examples/cms-enterspeed)
## How to use ## How to use
......
...@@ -33,6 +33,7 @@ Once you have access to [the environment variables you'll need](#step-15-set-up- ...@@ -33,6 +33,7 @@ Once you have access to [the environment variables you'll need](#step-15-set-up-
- [Umbraco Heartcore](/examples/cms-umbraco-heartcore) - [Umbraco Heartcore](/examples/cms-umbraco-heartcore)
- [Blog Starter](/examples/blog-starter) - [Blog Starter](/examples/blog-starter)
- [Builder.io](/examples/cms-builder-io) - [Builder.io](/examples/cms-builder-io)
- [Enterspeed](/examples/cms-enterspeed)
## How to use ## How to use
......
...@@ -97,3 +97,4 @@ Alternatively, you can deploy using our template by clicking on the Deploy butto ...@@ -97,3 +97,4 @@ Alternatively, you can deploy using our template by clicking on the Deploy butto
- [Kontent](/examples/cms-kontent) - [Kontent](/examples/cms-kontent)
- [Ghost](/examples/cms-ghost) - [Ghost](/examples/cms-ghost)
- [Blog Starter](/examples/blog-starter) - [Blog Starter](/examples/blog-starter)
- [Enterspeed](/examples/cms-enterspeed)
...@@ -34,6 +34,7 @@ Once you have access to your Butter API token, you can deploy your Butterized pr ...@@ -34,6 +34,7 @@ Once you have access to your Butter API token, you can deploy your Butterized pr
- [Umbraco Heartcore](/examples/cms-umbraco-heartcore) - [Umbraco Heartcore](/examples/cms-umbraco-heartcore)
- [Blog Starter](/examples/blog-starter) - [Blog Starter](/examples/blog-starter)
- [Builder.io](/examples/cms-builder-io) - [Builder.io](/examples/cms-builder-io)
- [Enterspeed](/examples/cms-enterspeed)
## How to use ## How to use
......
...@@ -30,6 +30,7 @@ Using the Deploy Button below, you'll deploy the Next.js project as well as conn ...@@ -30,6 +30,7 @@ Using the Deploy Button below, you'll deploy the Next.js project as well as conn
- [Umbraco Heartcore](/examples/cms-umbraco-heartcore) - [Umbraco Heartcore](/examples/cms-umbraco-heartcore)
- [Blog Starter](/examples/blog-starter) - [Blog Starter](/examples/blog-starter)
- [Builder.io](/examples/cms-builder-io) - [Builder.io](/examples/cms-builder-io)
- [Enterspeed](/examples/cms-enterspeed)
## How to use ## How to use
......
...@@ -30,6 +30,7 @@ Once you have access to [the environment variables you'll need](#step-3-set-up-e ...@@ -30,6 +30,7 @@ Once you have access to [the environment variables you'll need](#step-3-set-up-e
- [Umbraco Heartcore](/examples/cms-umbraco-heartcore) - [Umbraco Heartcore](/examples/cms-umbraco-heartcore)
- [Blog Starter](/examples/blog-starter) - [Blog Starter](/examples/blog-starter)
- [Builder.io](/examples/cms-builder-io) - [Builder.io](/examples/cms-builder-io)
- [Enterspeed](/examples/cms-enterspeed)
## How to use ## How to use
......
...@@ -24,6 +24,7 @@ This example showcases Next.js's [Static Generation](https://nextjs.org/docs/bas ...@@ -24,6 +24,7 @@ This example showcases Next.js's [Static Generation](https://nextjs.org/docs/bas
- [Umbraco Heartcore](/examples/cms-umbraco-heartcore) - [Umbraco Heartcore](/examples/cms-umbraco-heartcore)
- [Blog Starter](/examples/blog-starter) - [Blog Starter](/examples/blog-starter)
- [Builder.io](/examples/cms-builder-io) - [Builder.io](/examples/cms-builder-io)
- [Enterspeed](/examples/cms-enterspeed)
## Deploy your own ## Deploy your own
......
...@@ -29,6 +29,7 @@ Once you have [configured the Next.js module for Drupal](https://next-drupal.org ...@@ -29,6 +29,7 @@ Once you have [configured the Next.js module for Drupal](https://next-drupal.org
- [Ghost](/examples/cms-ghost) - [Ghost](/examples/cms-ghost)
- [GraphCMS](/examples/cms-graphcms) - [GraphCMS](/examples/cms-graphcms)
- [Blog Starter](/examples/blog-starter) - [Blog Starter](/examples/blog-starter)
- [Enterspeed](/examples/cms-enterspeed)
## How to use ## How to use
......
ENTERSPEED_PRODUCTION_ENVIRONMENT_API_KEY=
# Only required if you want to enable preview mode
# ENTERSPEED_PREVIEW_ENVIRONMENT_API_KEY=
# ENTERSPEED_PREVIEW_SECRET
\ No newline at end of file
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
# dependencies
/node_modules
/.pnp
.pnp.js
# testing
/coverage
# next.js
/.next/
/out/
# production
/build
# misc
.DS_Store
*.pem
# debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*
# local env files
.env.local
.env.development.local
.env.test.local
.env.production.local
# vercel
.vercel
This diff is collapsed.
import Container from './container'
import cn from 'classnames'
import { EXAMPLE_PATH } from '../lib/constants'
type Props = {
preview?: boolean
}
export default function Alert({ preview }: Props) {
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 a page 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/vercel/next.js/tree/canary/examples/${EXAMPLE_PATH}`}
className="underline hover:text-success duration-200 transition-colors"
>
available on GitHub
</a>
.
</>
)}
</div>
</Container>
</div>
)
}
import Image from 'next/image'
import AuthorType from '../types/authorType'
type Props = {
author: AuthorType
}
export default function Avatar({ author }: Props) {
const name: string = author
? author.firstName && author.lastName
? `${author.firstName} ${author.lastName}`
: author.name
: null
return (
<div className="flex items-center">
<div className="w-12 h-12 relative mr-4">
<Image
src={author.avatar.url}
layout="fill"
className="rounded-full"
alt={name}
/>
</div>
<div className="text-xl font-bold">{name}</div>
</div>
)
}
type Props = {
categories: string[]
}
export default function Categories({ categories }: Props) {
return (
<span className="ml-1">
under
{categories.length > 0 ? (
categories.map((category, index) => (
<span key={index} className="ml-1">
{category}
</span>
))
) : (
<span className="ml-1">{categories}</span>
)}
</span>
)
}
type Props = {
children: React.ReactNode
}
export default function Container({ children }: Props) {
return <div className="container mx-auto px-5">{children}</div>
}
import cn from 'classnames'
import Image from 'next/image'
import Link from 'next/link'
type Props = {
title: string
coverImage: string
slug?: string
}
export default function CoverImage({ title, coverImage, slug }: Props) {
const image = (
<Image
width={2000}
height={1000}
alt={`Cover Image for ${title}`}
src={coverImage}
className={cn('shadow-small', {
'hover:shadow-medium transition-shadow duration-200': slug,
})}
/>
)
return (
<div className="sm:mx-0">
{slug ? (
<Link href={`/posts${slug}`}>
<a aria-label={title}>{image}</a>
</Link>
) : (
image
)}
</div>
)
}
import { parseISO, format } from 'date-fns'
type Props = {
dateString: string
}
export default function Date({ dateString }: Props) {
const date = parseISO(dateString)
return <time dateTime={dateString}>{format(date, 'LLLL d, yyyy')}</time>
}
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/vercel/next.js/tree/canary/examples/${EXAMPLE_PATH}`}
className="mx-3 font-bold hover:underline"
>
View on GitHub
</a>
</div>
</div>
</Container>
</footer>
)
}
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>
)
}
import Avatar from './avatar'
import Date from './date'
import CoverImage from './cover-image'
import Link from 'next/link'
import AuthorType from '../types/authorType'
type Props = {
title: string
coverImage: string
date: string
excerpt: string
author: AuthorType
slug: string
}
export default function HeroPost({
title,
coverImage,
date,
excerpt,
author,
slug,
}: Props) {
return (
<section>
<div className="mb-8 md:mb-16">
{coverImage && (
<CoverImage title={title} coverImage={coverImage} slug={slug} />
)}
</div>
<div className="md:grid md:grid-cols-2 md:gap-x-16 lg:gap-x-8 mb-20 md:mb-28">
<div>
<h3 className="mb-4 text-4xl lg:text-6xl leading-tight">
<Link href={`/posts${slug}`}>
<a
className="hover:underline"
dangerouslySetInnerHTML={{ __html: title }}
/>
</Link>
</h3>
<div className="mb-4 md:mb-0 text-lg">
<Date dateString={date} />
</div>
</div>
<div>
<div
className="text-lg leading-relaxed mb-4"
dangerouslySetInnerHTML={{ __html: excerpt }}
/>
<Avatar author={author} />
</div>
</div>
</section>
)
}
import { EXAMPLE_TOOL_NAME, EXAMPLE_TOOL_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={EXAMPLE_TOOL_URL}
className="underline hover:text-success duration-200 transition-colors"
>
{EXAMPLE_TOOL_NAME}
</a>
.
</h4>
</section>
)
}
import Alert from './alert'
import Footer from './footer'
import Meta from './meta'
type Props = {
preview?: boolean
children: React.ReactNode
}
export default function Layout({ preview, children }: Props) {
return (
<>
<Meta />
<div className="min-h-screen">
<Alert preview={preview} />
<main>{children}</main>
</div>
<Footer />
</>
)
}
import Head from 'next/head'
import { EXAMPLE_TOOL_NAME } 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 ${EXAMPLE_TOOL_NAME}.`}
/>
</Head>
)
}
import PostPreview from './post-preview'
import PostType from '../types/postType'
type Props = {
posts: PostType[]
}
export default function MoreStories({ posts }: Props) {
return (
<section>
<h2 className="mb-8 text-6xl md:text-7xl font-bold tracking-tighter leading-tight">
More Stories
</h2>
<div className="grid grid-cols-1 md:grid-cols-2 md:gap-x-16 lg:gap-x-32 gap-y-20 md:gap-y-32 mb-32">
{posts.map((post) => (
<PostPreview
key={post.url}
title={post.title}
coverImage={post.featuredImage}
date={post.date}
author={post.author}
slug={post.url}
excerpt={post.excerpt}
/>
))}
</div>
</section>
)
}
.content {
@apply text-lg leading-relaxed;
}
.content p,
.content ul,
.content ol,
.content blockquote {
@apply my-6;
}
.content a {
@apply underline;
}
.content ul,
.content ol {
@apply pl-4;
}
.content ul {
@apply list-disc;
}
.content ol {
@apply list-decimal;
}
.content ul > li > ul,
.content ol > li > ol {
@apply my-0 ml-4;
}
.content ul > li > ul {
list-style: circle;
}
.content h2 {
@apply text-3xl mt-12 mb-4 leading-snug;
}
.content h3 {
@apply text-2xl mt-8 mb-4 leading-snug;
}
.content h4 {
@apply text-xl mt-6 mb-4 leading-snug;
}
.content pre {
@apply whitespace-pre overflow-x-auto p-4 text-sm leading-tight border border-gray-400 bg-gray-100;
}
.content code {
@apply text-sm;
}
.content figcaption {
@apply text-center text-sm;
}
.content blockquote {
@apply border-l-4 border-gray-500 bg-gray-200 italic ml-0 py-4 px-6;
}
.content blockquote p {
@apply mt-0;
}
.content blockquote cite {
@apply not-italic;
}
.content audio {
@apply w-full;
}
import styles from './post-body.module.css'
type Props = {
content: string
}
export default function PostBody({ content }: Props) {
return (
<div className="max-w-2xl mx-auto">
<div
className={styles.content}
dangerouslySetInnerHTML={{ __html: content }}
/>
</div>
)
}
import Avatar from './avatar'
import Date from './date'
import CoverImage from './cover-image'
import PostTitle from './post-title'
import Categories from './categories'
import AuthorType from '../types/authorType'
type Props = {
title: string
coverImage: string
date: string
author: AuthorType
categories: string[]
}
export default function PostHeader({
title,
coverImage,
date,
author,
categories,
}: Props) {
return (
<>
<PostTitle>{title}</PostTitle>
<div className="hidden md:block md:mb-12">
<Avatar author={author} />
</div>
<div className="mb-8 md:mb-16 sm:mx-0">
<CoverImage title={title} coverImage={coverImage} />
</div>
<div className="max-w-2xl mx-auto">
<div className="block md:hidden mb-6">
<Avatar author={author} />
</div>
<div className="mb-6 text-lg">
Posted <Date dateString={date} />
<Categories categories={categories} />
</div>
</div>
</>
)
}
import Avatar from './avatar'
import Date from './date'
import CoverImage from './cover-image'
import Link from 'next/link'
import AuthorType from '../types/authorType'
type Props = {
title: string
coverImage: string
date: string
excerpt: string
author: AuthorType
slug: string
}
export default function PostPreview({
title,
coverImage,
date,
excerpt,
author,
slug,
}: Props) {
return (
<div>
<div className="mb-5">
{coverImage && (
<CoverImage title={title} coverImage={coverImage} slug={slug} />
)}
</div>
<h3 className="text-3xl mb-3 leading-snug">
<Link href={`/posts${slug}`}>
<a className="hover:underline">{title}</a>
</Link>
</h3>
<div className="text-lg mb-4">
<Date dateString={date} />
</div>
<div
className="text-lg leading-relaxed mb-4"
dangerouslySetInnerHTML={{ __html: excerpt }}
/>
<Avatar author={author} />
</div>
)
}
type Props = {
children: string
}
export default function PostTitle({ children }: Props) {
return (
<h1
className="text-6xl md:text-7xl lg:text-8xl font-bold tracking-tighter leading-tight md:leading-none mb-12 text-center md:text-left"
dangerouslySetInnerHTML={{ __html: children }}
/>
)
}
export default function SectionSeparator() {
return <hr className="border-accent-2 mt-28 mb-24" />
}
type Props = {
tags: string[]
}
export default function Tags({ tags }: Props) {
return (
<div className="max-w-2xl mx-auto">
<p className="mt-8 text-lg font-bold">
Tagged
{tags.map((tag, index) => (
<span key={index} className="ml-4 font-normal">
{tag}
</span>
))}
</p>
</div>
)
}
const PRODUCTION_API_KEY = process.env.ENTERSPEED_PRODUCTION_ENVIRONMENT_API_KEY
const PREVIEW_API_KEY = process.env.ENTERSPEED_PREVIEW_ENVIRONMENT_API_KEY
const call = async (query: string, preview: boolean) => {
const url = `https://delivery.enterspeed.com/v1?${query}`
const response = await fetch(new Request(url), {
headers: {
'Content-Type': 'application/json',
'X-Api-Key': preview ? PREVIEW_API_KEY : PRODUCTION_API_KEY,
},
})
return response.json()
}
export const getByHandle = async (handle: string, preview: boolean) => {
const response = await call(`handle=${handle}`, preview)
return response.views[handle]
}
export const getByUrl = async (url: string, preview: boolean) => {
const response = await call(`url=${url}`, preview)
return response.route
}
export const EXAMPLE_PATH = 'cms-enterspeed'
export const EXAMPLE_TOOL_NAME = 'Enterspeed'
export const EXAMPLE_TOOL_URL = 'https://www.enterspeed.com/'
/// <reference types="next" />
/// <reference types="next/image-types/global" />
// NOTE: This file should not be edited
// see https://nextjs.org/docs/basic-features/typescript for more information.
module.exports = {
images: {
domains: ['res.cloudinary.com'],
},
}
{
"private": true,
"scripts": {
"dev": "next",
"build": "next build",
"start": "next start"
},
"dependencies": {
"classnames": "2.3.1",
"date-fns": "2.28.0",
"next": "latest",
"react": "^18.2.0",
"react-dom": "^18.2.0"
},
"devDependencies": {
"@types/node": "18.0.0",
"@types/react": "18.0.14",
"autoprefixer": "10.4.2",
"postcss": "8.4.5",
"tailwindcss": "^3.0.15",
"typescript": "4.7.4"
}
}
import { AppProps } from 'next/app'
import '../styles/index.css'
function MyApp({ Component, pageProps }: AppProps) {
return <Component {...pageProps} />
}
export default MyApp
export default async function exit(_, res) {
// Exit the current user from "Preview Mode". This function accepts no args.
res.clearPreviewData()
// Redirect the user back to the index page.
res.writeHead(307, { Location: '/' })
res.end()
}
export default async function preview(req, res) {
// Check the secret and next parameters
// This secret should only be known by this API route
if (req.query.secret === undefined || null) {
return res.status(401).json({ message: 'No token provided' })
}
if (req.query.secret !== process.env.ENTERSPEED_PREVIEW_SECRET) {
return res.status(401).json({ message: 'Invalid token' })
}
res.setPreviewData({})
res.redirect('/')
}
import Head from 'next/head'
import Container from '../components/container'
import MoreStories from '../components/more-stories'
import HeroPost from '../components/hero-post'
import Intro from '../components/intro'
import Layout from '../components/layout'
import { EXAMPLE_TOOL_NAME } from '../lib/constants'
import { getByHandle } from '../lib/api'
import PostType from '../types/postType'
type Props = {
posts: PostType[]
preview: boolean
}
export default function Index({ posts, preview }: Props) {
const heroPost = posts[0]
const morePosts = posts.slice(1)
return (
<>
<Layout preview={preview}>
<Head>
<title>Next.js Blog Example with {EXAMPLE_TOOL_NAME}</title>
</Head>
<Container>
<Intro />
{heroPost && (
<HeroPost
title={heroPost.title}
coverImage={heroPost.featuredImage}
date={heroPost.date}
author={heroPost.author}
slug={heroPost.url}
excerpt={heroPost.excerpt}
/>
)}
{morePosts.length > 0 && <MoreStories posts={morePosts} />}
</Container>
</Layout>
</>
)
}
export async function getStaticProps({ preview }: { preview: boolean }) {
const data = await getByHandle('blogList', preview)
return {
props: {
posts: data.blogListItems,
preview: preview || null,
},
}
}
import { useRouter } from 'next/router'
import ErrorPage from 'next/error'
import Container from '../../components/container'
import PostBody from '../../components/post-body'
import Header from '../../components/header'
import PostHeader from '../../components/post-header'
import SectionSeparator from '../../components/section-separator'
import Layout from '../../components/layout'
import { getByUrl, getByHandle } from '../../lib/api'
import PostTitle from '../../components/post-title'
import Head from 'next/head'
import { EXAMPLE_TOOL_NAME } from '../../lib/constants'
import Tags from '../../components/tags'
import PostType from '../../types/postType'
type Props = {
post: PostType
preview: boolean
}
export default function Post({ post, preview }: Props) {
const router = useRouter()
if (!router.isFallback && !post?.url) {
return <ErrorPage statusCode={404} />
}
return (
<Layout preview={preview}>
<Container>
<Header />
{router.isFallback ? (
<PostTitle>Loading…</PostTitle>
) : (
<>
<article>
<Head>
<title>
{post.title} | Next.js Blog Example with {EXAMPLE_TOOL_NAME}
</title>
<meta property="og:image" content={post.featuredImage} />
</Head>
<PostHeader
title={post.title}
coverImage={post.featuredImage}
date={post.date}
author={post.author}
categories={post.categories}
/>
<PostBody content={post.content} />
<footer>
{post.tags?.length > 0 && <Tags tags={post.tags} />}
</footer>
</article>
<SectionSeparator />
</>
)}
</Container>
</Layout>
)
}
export async function getStaticPaths({ preview }: { preview: boolean }) {
const data = await getByHandle('blogList', preview)
return {
paths: data.blogListItems.map((post) => ({
// Remove starting and ending slash from url
params: { slug: post.url.replace(/^\/|\/$/g, '') },
})),
fallback: false,
}
}
type Params = {
slug: string
}
export async function getStaticProps({
params,
preview,
}: {
params: Params
preview: boolean
}) {
// Adding starting slash to the URL again
const data = await getByUrl(encodeURIComponent(`/${params.slug}`), preview)
return {
props: {
post: data,
preview: preview || null,
},
}
}
// If you want to use other PostCSS plugins, see the following:
// https://tailwindcss.com/docs/using-with-preprocessors
module.exports = {
plugins: {
tailwindcss: {},
autoprefixer: {},
},
}
<?xml version="1.0" encoding="utf-8"?>
<browserconfig>
<msapplication>
<tile>
<square150x150logo src="/favicons/mstile-150x150.png"/>
<TileColor>#000000</TileColor>
</tile>
</msapplication>
</browserconfig>
<?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20010904//EN"
"http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">
<svg version="1.0" xmlns="http://www.w3.org/2000/svg"
width="1024.000000pt" height="1024.000000pt" viewBox="0 0 1024.000000 1024.000000"
preserveAspectRatio="xMidYMid meet">
<metadata>
Created by potrace 1.11, written by Peter Selinger 2001-2013
</metadata>
<g transform="translate(0.000000,1024.000000) scale(0.100000,-0.100000)"
fill="#000000" stroke="none">
<path d="M4785 10234 c-22 -2 -92 -9 -155 -14 -1453 -131 -2814 -915 -3676
-2120 -480 -670 -787 -1430 -903 -2235 -41 -281 -46 -364 -46 -745 0 -381 5
-464 46 -745 278 -1921 1645 -3535 3499 -4133 332 -107 682 -180 1080 -224
155 -17 825 -17 980 0 687 76 1269 246 1843 539 88 45 105 57 93 67 -8 6 -383
509 -833 1117 l-818 1105 -1025 1517 c-564 834 -1028 1516 -1032 1516 -4 1 -8
-673 -10 -1496 -3 -1441 -4 -1499 -22 -1533 -26 -49 -46 -69 -88 -91 -32 -16
-60 -19 -211 -19 l-173 0 -46 29 c-30 19 -52 44 -67 73 l-21 45 2 2005 3 2006
31 39 c16 21 50 48 74 61 41 20 57 22 230 22 204 0 238 -8 291 -66 15 -16 570
-852 1234 -1859 664 -1007 1572 -2382 2018 -3057 l810 -1227 41 27 c363 236
747 572 1051 922 647 743 1064 1649 1204 2615 41 281 46 364 46 745 0 381 -5
464 -46 745 -278 1921 -1645 3535 -3499 4133 -327 106 -675 179 -1065 223 -96
10 -757 21 -840 13z m2094 -3094 c48 -24 87 -70 101 -118 8 -26 10 -582 8
-1835 l-3 -1798 -317 486 -318 486 0 1307 c0 845 4 1320 10 1343 16 56 51 100
99 126 41 21 56 23 213 23 148 0 174 -2 207 -20z"/>
<path d="M7843 789 c-35 -22 -46 -37 -15 -20 22 13 58 40 52 41 -3 0 -20 -10
-37 -21z"/>
<path d="M7774 744 c-18 -14 -18 -15 4 -4 12 6 22 13 22 15 0 8 -5 6 -26 -11z"/>
<path d="M7724 714 c-18 -14 -18 -15 4 -4 12 6 22 13 22 15 0 8 -5 6 -26 -11z"/>
<path d="M7674 684 c-18 -14 -18 -15 4 -4 12 6 22 13 22 15 0 8 -5 6 -26 -11z"/>
<path d="M7598 644 c-38 -20 -36 -28 2 -9 17 9 30 18 30 20 0 7 -1 6 -32 -11z"/>
</g>
</svg>
{
"name": "Next.js",
"short_name": "Next.js",
"icons": [
{
"src": "/favicons/android-chrome-192x192.png",
"sizes": "192x192",
"type": "image/png"
},
{
"src": "/favicons/android-chrome-512x512.png",
"sizes": "512x512",
"type": "image/png"
}
],
"theme_color": "#000000",
"background_color": "#000000",
"display": "standalone"
}
@tailwind base;
/* Write your own custom base styles here */
/* Start purging... */
@tailwind components;
/* Stop purging. */
/* Write you own custom component styles here */
/* Start purging... */
@tailwind utilities;
/* Stop purging. */
/* Your own custom utilities */
.has-text-align-left {
@apply text-left;
}
.has-text-align-center {
@apply text-center;
}
.has-text-align-right {
@apply text-right;
}
.has-large-font-size {
@apply text-4xl;
}
.alignfull {
@apply w-screen relative;
left: 50%;
margin-left: -50vw;
margin-right: -50vw;
max-width: 100vw;
right: 50%;
}
.wp-block-image img {
@apply max-w-full mt-2;
}
.wp-block-image.aligncenter {
@apply text-center;
}
.wp-block-image.alignfull img,
.wp-block-image.alignwide img {
@apply w-full;
}
.wp-block-image .alignleft,
.wp-block-image .alignright,
.wp-block-image .aligncenter,
.wp-block-image.is-resized {
@apply table ml-0 mr-0;
}
.wp-block-image .alignleft > figcaption,
.wp-block-image .alignright > figcaption,
.wp-block-image .aligncenter > figcaption,
.wp-block-image.is-resized > figcaption {
@apply table-caption;
caption-side: bottom;
}
.wp-block-image .alignleft {
@apply float-left mr-4;
}
.wp-block-image .alignright {
@apply float-right ml-4;
}
.wp-block-image .aligncenter {
@apply m-auto;
}
.wp-block-button a,
.wp-block-file a.wp-block-file__button {
@apply bg-blue-500 text-white no-underline py-2 px-4;
}
.wp-block-button a:hover,
.wp-block-file a.wp-block-file__button:hover {
@apply bg-blue-400 cursor-pointer;
}
.wp-block-file a:first-of-type {
@apply mr-4;
}
.wp-block-cover {
@apply flex flex-wrap justify-center items-center bg-cover bg-center overflow-hidden;
min-height: 430px;
}
.wp-block-verse {
@apply font-sans;
}
.wp-block-media-text {
@apply grid grid-cols-2 gap-4;
}
module.exports = {
content: [
'./pages/**/*.{js,ts,jsx,tsx}',
'./components/**/*.{js,ts,jsx,tsx}',
],
theme: {
extend: {
colors: {
'accent-1': '#FAFAFA',
'accent-2': '#EAEAEA',
'accent-7': '#333',
success: '#0070f3',
cyan: '#79FFE1',
},
spacing: {
28: '7rem',
},
letterSpacing: {
tighter: '-.04em',
},
lineHeight: {
tight: 1.2,
},
fontSize: {
'5xl': '2.5rem',
'6xl': '2.75rem',
'7xl': '4.5rem',
'8xl': '6.25rem',
},
boxShadow: {
small: '0 5px 10px rgba(0, 0, 0, 0.12)',
medium: '0 8px 30px rgba(0, 0, 0, 0.12)',
},
},
},
plugins: [],
}
{
"compilerOptions": {
"target": "es5",
"lib": ["dom", "dom.iterable", "esnext"],
"allowJs": true,
"skipLibCheck": true,
"strict": false,
"forceConsistentCasingInFileNames": true,
"noEmit": true,
"incremental": true,
"esModuleInterop": true,
"module": "esnext",
"moduleResolution": "node",
"resolveJsonModule": true,
"isolatedModules": true,
"jsx": "preserve"
},
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx"],
"exclude": ["node_modules"]
}
type AuthorType = {
firstName: string
lastName: string
name: string
avatar: {
url: string
}
}
export default AuthorType
import AuthorType from './authorType'
type PostType = {
url: string
title: string
featuredImage: string
date: string
author: AuthorType
excerpt: string
categories: string[]
content: string
tags: string[]
}
export default PostType
...@@ -28,6 +28,7 @@ Once you have access to [the environment variables you'll need](#step-2-set-up-e ...@@ -28,6 +28,7 @@ Once you have access to [the environment variables you'll need](#step-2-set-up-e
- [Umbraco Heartcore](/examples/cms-umbraco-heartcore) - [Umbraco Heartcore](/examples/cms-umbraco-heartcore)
- [Blog Starter](/examples/blog-starter) - [Blog Starter](/examples/blog-starter)
- [Builder.io](/examples/cms-builder-io) - [Builder.io](/examples/cms-builder-io)
- [Enterspeed](/examples/cms-enterspeed)
## How to use ## How to use
......
...@@ -27,6 +27,7 @@ This example showcases Next.js's [Static Generation](https://nextjs.org/docs/bas ...@@ -27,6 +27,7 @@ This example showcases Next.js's [Static Generation](https://nextjs.org/docs/bas
- [Umbraco Heartcore](/examples/cms-umbraco-heartcore) - [Umbraco Heartcore](/examples/cms-umbraco-heartcore)
- [Blog Starter](/examples/blog-starter) - [Blog Starter](/examples/blog-starter)
- [Builder.io](/examples/cms-builder-io) - [Builder.io](/examples/cms-builder-io)
- [Enterspeed](/examples/cms-enterspeed)
## Deploy your own ## Deploy your own
......
...@@ -30,6 +30,7 @@ Once you have access to [the environment variables you'll need](#step-3-set-up-e ...@@ -30,6 +30,7 @@ Once you have access to [the environment variables you'll need](#step-3-set-up-e
- [Umbraco Heartcore](/examples/cms-umbraco-heartcore) - [Umbraco Heartcore](/examples/cms-umbraco-heartcore)
- [Blog Starter](/examples/blog-starter) - [Blog Starter](/examples/blog-starter)
- [Builder.io](/examples/cms-builder-io) - [Builder.io](/examples/cms-builder-io)
- [Enterspeed](/examples/cms-enterspeed)
## How to use ## How to use
......
...@@ -26,6 +26,7 @@ This example showcases Next.js's [Static Generation](https://nextjs.org/docs/bas ...@@ -26,6 +26,7 @@ This example showcases Next.js's [Static Generation](https://nextjs.org/docs/bas
- [Ghost](/examples/cms-ghost) - [Ghost](/examples/cms-ghost)
- [GraphCMS](/examples/cms-graphcms) - [GraphCMS](/examples/cms-graphcms)
- [Blog Starter](/examples/blog-starter) - [Blog Starter](/examples/blog-starter)
- [Enterspeed](/examples/cms-enterspeed)
## Getting Started ## Getting Started
......
...@@ -29,6 +29,7 @@ Once you have access to [the environment variables you'll need](#step-5-set-up-e ...@@ -29,6 +29,7 @@ Once you have access to [the environment variables you'll need](#step-5-set-up-e
- [Umbraco Heartcore](/examples/cms-umbraco-heartcore) - [Umbraco Heartcore](/examples/cms-umbraco-heartcore)
- [Blog Starter](/examples/blog-starter) - [Blog Starter](/examples/blog-starter)
- [Builder.io](/examples/cms-builder-io) - [Builder.io](/examples/cms-builder-io)
- [Enterspeed](/examples/cms-enterspeed)
## How to use ## How to use
......
...@@ -31,6 +31,7 @@ You'll get: ...@@ -31,6 +31,7 @@ You'll get:
- [Umbraco Heartcore](/examples/cms-umbraco-heartcore) - [Umbraco Heartcore](/examples/cms-umbraco-heartcore)
- [Blog Starter](/examples/blog-starter) - [Blog Starter](/examples/blog-starter)
- [Builder.io](/examples/cms-builder-io) - [Builder.io](/examples/cms-builder-io)
- [Enterspeed](/examples/cms-enterspeed)
# Configuration # Configuration
......
...@@ -30,6 +30,7 @@ Once you have access to [the environment variables you'll need](#step-6-set-up-e ...@@ -30,6 +30,7 @@ Once you have access to [the environment variables you'll need](#step-6-set-up-e
- [Umbraco Heartcore](/examples/cms-umbraco-heartcore) - [Umbraco Heartcore](/examples/cms-umbraco-heartcore)
- [Blog Starter](/examples/blog-starter) - [Blog Starter](/examples/blog-starter)
- [Builder.io](/examples/cms-builder-io) - [Builder.io](/examples/cms-builder-io)
- [Enterspeed](/examples/cms-enterspeed)
## How to use ## How to use
......
...@@ -30,6 +30,7 @@ Once you have access to [the environment variables you'll need](#step-7-set-up-e ...@@ -30,6 +30,7 @@ Once you have access to [the environment variables you'll need](#step-7-set-up-e
- [Umbraco Heartcore](/examples/cms-umbraco-heartcore) - [Umbraco Heartcore](/examples/cms-umbraco-heartcore)
- [Blog Starter](/examples/blog-starter) - [Blog Starter](/examples/blog-starter)
- [Builder.io](/examples/cms-builder-io) - [Builder.io](/examples/cms-builder-io)
- [Enterspeed](/examples/cms-enterspeed)
## How to use ## How to use
......
...@@ -29,6 +29,7 @@ Once you have access to [the environment variables you'll need](#step-5-set-up-e ...@@ -29,6 +29,7 @@ Once you have access to [the environment variables you'll need](#step-5-set-up-e
- [Ghost](/examples/cms-ghost) - [Ghost](/examples/cms-ghost)
- [Blog Starter](/examples/blog-starter) - [Blog Starter](/examples/blog-starter)
- [Builder.io](/examples/cms-builder-io) - [Builder.io](/examples/cms-builder-io)
- [Enterspeed](/examples/cms-enterspeed)
## How to use ## How to use
......
...@@ -26,6 +26,7 @@ This example showcases Next.js's [Static Generation](https://nextjs.org/docs/bas ...@@ -26,6 +26,7 @@ This example showcases Next.js's [Static Generation](https://nextjs.org/docs/bas
- [Umbraco Heartcore](/examples/cms-umbraco-heartcore) - [Umbraco Heartcore](/examples/cms-umbraco-heartcore)
- [Blog Starter](/examples/blog-starter) - [Blog Starter](/examples/blog-starter)
- [Builder.io](/examples/cms-builder-io) - [Builder.io](/examples/cms-builder-io)
- [Enterspeed](/examples/cms-enterspeed)
## How to use ## How to use
......
...@@ -30,6 +30,7 @@ Once you have access to [the environment variables you'll need](#step-3-set-up-e ...@@ -30,6 +30,7 @@ Once you have access to [the environment variables you'll need](#step-3-set-up-e
- [Kontent](/examples/cms-kontent) - [Kontent](/examples/cms-kontent)
- [Ghost](/examples/cms-ghost) - [Ghost](/examples/cms-ghost)
- [Blog Starter](/examples/blog-starter) - [Blog Starter](/examples/blog-starter)
- [Enterspeed](/examples/cms-enterspeed)
## How to use ## How to use
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment