Skip to content
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

Add dotCMS example #38214

Merged
merged 79 commits into from Oct 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
79 commits
Select commit Hold shift + click to select a range
cd8ea4d
feat: init dotCMS example with basic query
danestves Oct 8, 2021
0df52f5
feat: working home with queries from dotCMS
danestves Oct 8, 2021
da88e62
feat: queries for single post
danestves Oct 8, 2021
6b6dac2
fix: removing unused dotcms package
danestves Oct 8, 2021
b73f214
feat: using the errors inside the fetchAPI
danestves Oct 8, 2021
54806ff
feat: document the functions inside api
danestves Oct 8, 2021
45f0c3c
feat: removing docs images
danestves Oct 8, 2021
ab1f6bb
fix: flter for posts and more posts
danestves Oct 8, 2021
6005fc9
Merge branch 'vercel:canary' into canary
danestves Oct 18, 2021
47ba508
feat: adding prose styles for paragraphs
danestves Oct 18, 2021
17e70d2
feat: spacing for more posts and avatar validation
danestves Oct 18, 2021
da48bf8
Merge branch 'vercel:canary' into canary
danestves Oct 22, 2021
a80e2aa
feat: add gradient placeholder for non image
danestves Oct 22, 2021
06ed80b
Merge branch 'vercel:canary' into canary
danestves Nov 15, 2021
16a1de9
Merge branch 'vercel:canary' into canary
wezell Mar 1, 2022
200408d
Merge branch 'vercel:canary' into canary
fmontes Mar 2, 2022
49a5d60
Merge branch 'vercel:canary' into canary
fmontes Mar 3, 2022
a53e88e
Merge branch 'vercel:canary' into canary
fmontes Mar 3, 2022
8ad33b3
Merge branch 'vercel:canary' into canary
fmontes Apr 1, 2022
c91c187
Merge branch 'vercel:canary' into canary
oidacra Apr 6, 2022
9e7cd7c
add example use dotCMS with Next.js
oidacra Apr 19, 2022
1339109
fix comments
oidacra Apr 20, 2022
fb46bd8
Merge branch 'vercel:canary' into canary
fmontes Apr 20, 2022
c3a0696
fix use again Vercel Image component
oidacra Apr 20, 2022
ec63dd2
small fixes
oidacra Apr 20, 2022
6defbc9
Merge pull request #1 from dotCMS/add-example-use-dotcms-nextjs
fmontes Apr 20, 2022
28f972b
fix conflicts
oidacra Apr 21, 2022
453c59a
Merge pull request #2 from dotCMS/add-example-use-dotcms-nextjs
oidacra Apr 21, 2022
5efaac3
Render block field using inline components
fmontes Apr 22, 2022
fac1d5c
Round 2
fmontes Apr 22, 2022
acc9cd3
dotCMS/core#22070 Update the render storyblock field system
fmontes Apr 22, 2022
cc9ffed
Fix code block
fmontes Apr 25, 2022
e7e7d71
Fix code block
fmontes Apr 25, 2022
042dda8
dotCMS/core#22063 Move the content to <PostBody /> component
fmontes Apr 25, 2022
4da7ad0
Merge pull request #7 from dotCMS/issue-22063
oidacra Apr 25, 2022
565f8c1
fix column gap to hero post component
oidacra Apr 22, 2022
66fc8af
fix related query
oidacra Apr 22, 2022
4fd807d
fix image componet
oidacra Apr 26, 2022
e3b179b
Some clean up and fixes
fmontes Apr 28, 2022
5cd0994
Fix the media queries
fmontes Apr 29, 2022
1f17909
dotCMS/core#22062 Fix Visual glitches
fmontes Apr 29, 2022
40735cc
Merge branch 'vercel:canary' into canary
fmontes May 11, 2022
51ba1a9
Merge branch 'vercel:canary' into canary
fmontes Jun 2, 2022
fa16963
Merge branch 'vercel:canary' into canary
fmontes Jun 7, 2022
bc7381c
Merge branch 'vercel:canary' into canary
fmontes Jun 30, 2022
53a22d6
Update to next 12.2
fmontes Jun 30, 2022
dce7c49
Merge branch 'canary' into canary
fmontes Jun 30, 2022
7a1517d
Merge branch 'canary' into canary
fmontes Jun 30, 2022
bc4ba84
Merge branch 'canary' into canary
fmontes Jul 1, 2022
7be6d7f
Merge branch 'canary' into canary
fmontes Jul 4, 2022
a46a79c
Code review feedback
fmontes Jul 6, 2022
a50a2da
Add typescript
fmontes Jul 6, 2022
102b61c
Convert to typescript
fmontes Jul 6, 2022
075c63e
Merge branch 'canary' into canary
fmontes Jul 6, 2022
ce8e415
Merge branch 'canary' into canary
fmontes Jul 6, 2022
b578970
Merge branch 'canary' into canary
fmontes Jul 7, 2022
f256ad6
Merge branch 'canary' into canary
fmontes Jul 8, 2022
3bc5edd
Add typescript related files to .gitignore
fmontes Jul 8, 2022
73c4dae
Remove import react
fmontes Jul 11, 2022
4cffb02
Run lint
fmontes Jul 11, 2022
ef07dfe
Add .env.local doc in the readme
fmontes Jul 11, 2022
8db342a
Merge branch 'canary' into canary
fmontes Jul 11, 2022
c06f9f8
Merge branch 'canary' into canary
fmontes Jul 19, 2022
33bfff2
Merge branch 'canary' into canary
fmontes Jul 20, 2022
e3444b4
Merge branch 'canary' into canary
fmontes Jul 26, 2022
5aacbd4
Merge branch 'canary' into canary
fmontes Aug 7, 2022
7d74cc8
Merge branch 'canary' into canary
fmontes Aug 16, 2022
a87a60c
Merge branch 'canary' into canary
fmontes Aug 25, 2022
9a6bb60
Merge branch 'canary' into canary
fmontes Sep 1, 2022
5d47c53
Merge branch 'canary' into canary
fmontes Sep 14, 2022
8afe0e2
Update to next 12.3.0
fmontes Sep 14, 2022
efefadc
Update to next 12.3.0
fmontes Sep 14, 2022
a2f9d4b
Merge branch 'canary' into canary
fmontes Sep 26, 2022
eb65639
fix dependencies & paths
rjvelazco Sep 26, 2022
d9028f6
Merge branch 'vercel:canary' into canary
fmontes Sep 27, 2022
926cd65
Merge branch 'vercel:canary' into canary
fmontes Sep 27, 2022
e646954
run lint-fix
rjvelazco Sep 27, 2022
e6f899c
clean up
rjvelazco Sep 28, 2022
8bd48f2
Merge branch 'canary' into canary
fmontes Oct 1, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions examples/cms-agilitycms/README.md
Expand 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)
- [Blog Starter](/examples/blog-starter)
- [Builder.io](/examples/cms-builder-io)
- [DotCMS](/examples/cms-dotcms)
- [Enterspeed](/examples/cms-enterspeed)

## How to use
Expand Down
1 change: 1 addition & 0 deletions examples/cms-builder-io/README.md
Expand Up @@ -97,4 +97,5 @@ Alternatively, you can deploy using our template by clicking on the Deploy butto
- [Kontent](/examples/cms-kontent)
- [Ghost](/examples/cms-ghost)
- [Blog Starter](/examples/blog-starter)
- [DotCMS](/examples/cms-dotcms)
- [Enterspeed](/examples/cms-enterspeed)
1 change: 1 addition & 0 deletions examples/cms-buttercms/README.md
Expand Up @@ -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)
- [Blog Starter](/examples/blog-starter)
- [Builder.io](/examples/cms-builder-io)
- [DotCMS](/examples/cms-dotcms)
- [Enterspeed](/examples/cms-enterspeed)

## How to use
Expand Down
1 change: 1 addition & 0 deletions examples/cms-contentful/README.md
Expand Up @@ -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)
- [Blog Starter](/examples/blog-starter)
- [Builder.io](/examples/cms-builder-io)
- [DotCMS](/examples/cms-dotcms)
- [Enterspeed](/examples/cms-enterspeed)

## How to use
Expand Down
1 change: 1 addition & 0 deletions examples/cms-cosmic/README.md
Expand Up @@ -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)
- [Blog Starter](/examples/blog-starter)
- [Builder.io](/examples/cms-builder-io)
- [DotCMS](/examples/cms-dotcms)
- [Enterspeed](/examples/cms-enterspeed)

## How to use
Expand Down
1 change: 1 addition & 0 deletions examples/cms-datocms/README.md
Expand Up @@ -24,6 +24,7 @@ This example showcases Next.js's [Static Generation](https://nextjs.org/docs/bas
- [Umbraco Heartcore](/examples/cms-umbraco-heartcore)
- [Blog Starter](/examples/blog-starter)
- [Builder.io](/examples/cms-builder-io)
- [DotCMS](/examples/cms-dotcms)
- [Enterspeed](/examples/cms-enterspeed)

## Deploy your own
Expand Down
3 changes: 3 additions & 0 deletions examples/cms-dotcms/.env.local.example
@@ -0,0 +1,3 @@
NEXT_PUBLIC_DOTCMS_HOST=""
NEXT_PREVIEW_SECRET_TOKEN=""
DOTCMS_PREVIEW_SECRET=""
4 changes: 4 additions & 0 deletions examples/cms-dotcms/.eslintrc.json
@@ -0,0 +1,4 @@
{
Copy link
Member

Choose a reason for hiding this comment

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

Let's remove this file.

"root": true,
"extends": "next/core-web-vitals"
}
38 changes: 38 additions & 0 deletions examples/cms-dotcms/.gitignore
@@ -0,0 +1,38 @@
# 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
Comment on lines +28 to +31
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
.env.local
.env.development.local
.env.test.local
.env.production.local
.env*.local


# vercel
.vercel
/.env
fmontes marked this conversation as resolved.
Show resolved Hide resolved

# typescript
*.tsbuildinfo
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
*.tsbuildinfo
*.tsbuildinfo
next-env.d.t.s

56 changes: 56 additions & 0 deletions examples/cms-dotcms/README.md
@@ -0,0 +1,56 @@
# A statically generated blog example using Next.js and dotCMS

This example showcases Next.js's [Static Generation](https://nextjs.org/docs/basic-features/pages) feature using [dotCMS](https://dotcms.com/) as the data source.

## Demo

### [https://nextjs-dotcms-blog.vercel.app/](https://nextjs-dotcms-blog.vercel.app/)

## Deploy your own

Using the Deploy Button below, you'll deploy the Next.js project.

[![Deploy with Vercel](https://vercel.com/button)](https://vercel.com/new/git/external?repository-url=https%3A%2F%2Fgithub.com%2FdotCMS%2Fnext.js%2Ftree%2Fcanary%2Fexamples%2Fcms-dotcms&project-name=nextjs-dotcms-blog&repository-name=nextjs-dotcms-blog&demo-title=Next.js+Blog&demo-description=Static+blog+with+multiple+authors+using+Preview+Mode&demo-url=https%3A%2F%2Fnext-blog-dotcms.vercel.app%2F)

### Related examples

- [WordPress](/examples/cms-wordpress)
- [DatoCMS](/examples/cms-datocms)
- [Sanity](/examples/cms-sanity)
- [TakeShape](/examples/cms-takeshape)
- [Prismic](/examples/cms-prismic)
- [Strapi](/examples/cms-strapi)
- [Agility CMS](/examples/cms-agilitycms)
- [Cosmic](/examples/cms-cosmic)
- [ButterCMS](/examples/cms-buttercms)
- [Storyblok](/examples/cms-storyblok)
- [GraphCMS](/examples/cms-graphcms)
- [Kontent](/examples/cms-kontent)
- [Ghost](/examples/cms-ghost)
- [Contentful](/examples/cms-contentful)
- [Blog Starter](/examples/blog-starter)

## How to use

fmontes marked this conversation as resolved.
Show resolved Hide resolved
Rename `.env.local.example` to `.env.local` and complete the variables:

`NEXT_PUBLIC_DOTCMS_HOST` is the dotCMS host, you can use `https://demo.dotcms.com`
`DOTCMS_TOKEN` for the demo site, you can generate the token using:

```
curl -H "Content-Type:application/json" --insecure -X POST -d '
{ "user":"admin@dotcms.com", "password":"admin", "expirationDays": 10 }
' http://demo.dotcms.com:8080/api/v1/authentication/api-token
```

Execute [`create-next-app`](https://github.com/vercel/next.js/tree/canary/packages/create-next-app) with [npm](https://docs.npmjs.com/cli/init), [Yarn](https://yarnpkg.com/lang/en/docs/cli/create/), or [pnpm](https://pnpm.io) to bootstrap the example:

```bash
npx create-next-app --example cms-dotcms cms-dotcms-app
# or
yarn create next-app --example cms-dotcms cms-dotcms-app
# or
pnpm create next-app --example cms-dotcms cms-dotcms-app
```

[![Deploy with Vercel](https://vercel.com/button)](https://vercel.com/new/git/external?repository-url=https%3A%2F%2Fgithub.com%2Fvercel%2Fnext.js%2Ftree%2Fcanary%2Fexamples%2Fcms-dotcms&project-name=nextjs-dotcms-blog&repository-name=nextjs-dotcms-blog&demo-title=Next.js+Blog&demo-description=Static+blog+with+multiple+authors+using+Preview+Mode&demo-url=https%3A%2F%2Fnext-blog-dotcms.vercel.app%2F)
42 changes: 42 additions & 0 deletions examples/cms-dotcms/components/alert.tsx
@@ -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/vercel/next.js/tree/canary/examples/${EXAMPLE_PATH}`}
className="underline hover:text-success duration-200 transition-colors"
>
available on GitHub
</a>
.
</>
)}
</div>
</Container>
</div>
)
}
19 changes: 19 additions & 0 deletions examples/cms-dotcms/components/avatar.tsx
@@ -0,0 +1,19 @@
import DotCmsImage from './dotcms-image'

export default function Avatar({ name, picture }) {
return (
<div className="flex items-center ">
<div className="w-12 h-12 relative mr-4">
{picture?.idPath ? (
<DotCmsImage
src={picture?.idPath}
layout="fill"
className="rounded-full"
alt={name}
/>
) : null}
</div>
<div className="text-xl font-bold">{name}</div>
</div>
)
}
98 changes: 98 additions & 0 deletions examples/cms-dotcms/components/blocks.tsx
@@ -0,0 +1,98 @@
import cn from 'classnames'
import DotCmsImage from './dotcms-image'
import Link from 'next/link'

export const Bold = ({ children }) => <strong>{children}</strong>
export const Italic = ({ children }) => <em>{children}</em>
export const Strike = ({ children }) => <s>{children}</s>
export const Underline = ({ children }) => <u>{children}</u>
export const DotLink = ({ attrs: { href, target }, children }) => {
const regEx = /https?:\/\//

return regEx.test(href) ? (
<a href={href} rel="noopener noreferrer" target="_blank">
{children}
</a>
) : (
<Link href={href} target={target || '_self'}>
{children}
</Link>
)
}

const nodeMarks = {
link: DotLink,
bold: Bold,
underline: Underline,
italic: Italic,
strike: Strike,
}

export const TextNode = (props) => {
const { marks = [], text } = props
const mark = marks[0] || { type: '', attrs: {} }
const newProps = { ...props, marks: marks.slice(1) }
const Component = nodeMarks[mark?.type]

if (!Component) {
return text
}

return (
<Component attrs={mark.attrs}>
<TextNode {...newProps} />
</Component>
)
}

export const DotImage = ({ attrs: { textAlign, data } }) => {
const { asset, title } = data
const [imgTitle] = title.split('.')

return (
<DotCmsImage
objectFit="cover"
style={{ textAlign: textAlign }}
width="800"
height="400"
alt={`Cover Image for ${title}`}
className={cn('shadow-small', {
'hover:shadow-medium transition-shadow duration-200': imgTitle,
})}
src={asset}
/>
)
}

export const ListItem = ({ children }) => {
return <li>{children}</li>
}

export const OrderedList = ({ children }) => {
return <ol>{children}</ol>
}

export const Paragraph = ({ children }) => {
return <p>{children}</p>
}

export const BulletList = ({ children }) => {
return <ul>{children}</ul>
}

export const Heading = ({ level, children }) => {
const Tag = `h${level}` as keyof JSX.IntrinsicElements
return <Tag>{children}</Tag>
}

export const BlockQuote = ({ children }) => {
return <blockquote>{children}</blockquote>
}

export const CodeBlock = ({ language, children }) => {
return (
<pre data-language={language}>
<code>{children}</code>
</pre>
)
}
3 changes: 3 additions & 0 deletions examples/cms-dotcms/components/container.tsx
@@ -0,0 +1,3 @@
export default function Container({ children }) {
return <div className="container mx-auto px-5">{children}</div>
}