Skip to content

Commit 5c626f0

Browse files
committed
feat: upgrade graphql-starter to Next.js v14
Issue #601
1 parent d7ab522 commit 5c626f0

27 files changed

+266
-211
lines changed

.env.example

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
11
# See https://next-drupal.org/docs/environment-variables
2-
NEXT_PUBLIC_DRUPAL_BASE_URL=https://dev.next-drupal.org
3-
NEXT_IMAGE_DOMAIN=dev.next-drupal.org
2+
3+
# Required
4+
NEXT_PUBLIC_DRUPAL_BASE_URL=https://site.example.com
5+
NEXT_IMAGE_DOMAIN=site.example.com
46

57
# Authentication
6-
DRUPAL_CLIENT_ID=
7-
DRUPAL_CLIENT_SECRET=
8+
DRUPAL_CLIENT_ID=Retrieve this from /admin/config/services/consumer
9+
DRUPAL_CLIENT_SECRET=Retrieve this from /admin/config/services/consumer
10+
11+
# Required for Preview Mode
12+
DRUPAL_PREVIEW_SECRET=Retrieve this from /admin/config/services/next
813

914
# Required for On-demand Revalidation
10-
DRUPAL_REVALIDATE_SECRET=secret
15+
DRUPAL_REVALIDATE_SECRET=Retrieve this from /admin/config/services/next

.eslintrc.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{
2-
"extends": "next",
2+
"extends": "next/core-web-vitals",
33
"root": true
44
}

.gitignore

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@
44
/node_modules
55
/.pnp
66
.pnp.js
7+
.yarn/install-state.gz
78

89
# testing
910
/coverage
1011

1112
# next.js
1213
/.next/
1314
/out/
14-
.next
1515

1616
# production
1717
/build
@@ -20,19 +20,21 @@
2020
.DS_Store
2121
*.pem
2222

23+
# IDE files
24+
/.idea
25+
/.vscode
26+
2327
# debug
2428
npm-debug.log*
2529
yarn-debug.log*
2630
yarn-error.log*
27-
lerna-debug.log*
2831

2932
# local env files
30-
.env.local
31-
.env.development.local
32-
.env.test.local
33-
.env.production.local
33+
.env*.local
3434

3535
# vercel
3636
.vercel
3737

38-
/certificates/*
38+
# typescript
39+
*.tsbuildinfo
40+
next-env.d.ts

.nvmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
v20

.prettierignore

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Ignore everything.
2+
/*
3+
4+
# Format most files in the root directory.
5+
!/*.js
6+
!/*.ts
7+
!/*.md
8+
!/*.json
9+
# But ignore some.
10+
/package.json
11+
/package-lock.json
12+
/CHANGELOG.md
13+
14+
# Don't ignore these nested directories.
15+
!/app
16+
!/components
17+
!/lib
18+
!/pages

.prettierrc.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"semi": false,
3+
"trailingComma": "es5"
4+
}

components/PreviewAlert.tsx

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import { useEffect, useState } from "react"
2+
import { useRouter } from "next/router"
3+
4+
export function PreviewAlert() {
5+
const router = useRouter()
6+
const isPreview = router.isPreview
7+
const [showPreviewAlert, setShowPreviewAlert] = useState<boolean>(false)
8+
9+
useEffect(() => {
10+
setShowPreviewAlert(isPreview && window.top === window.self)
11+
}, [isPreview])
12+
13+
if (!showPreviewAlert) {
14+
return null
15+
}
16+
17+
return (
18+
<div className="sticky top-0 left-0 z-50 w-full px-2 py-1 text-center text-white bg-black">
19+
<p className="mb-0">
20+
This page is a preview.{" "}
21+
<button
22+
className="inline-block ml-3 rounded border px-1.5 hover:bg-white hover:text-black active:bg-gray-200 active:text-gray-500"
23+
onClick={() => router.push("/api/exit-preview")}
24+
>
25+
Exit preview mode
26+
</button>
27+
</p>
28+
</div>
29+
)
30+
}

components/node--article.tsx renamed to components/drupal/Article.tsx

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
import Image from "next/image"
2+
import { formatDate } from "@/lib/utils"
3+
import type { NodeArticle } from "@/types"
24

3-
import { formatDate } from "lib/utils"
4-
import { Article } from "types"
5-
6-
interface NodeArticleProps {
7-
node: Article
5+
interface ArticleProps {
6+
node: NodeArticle
87
}
98

10-
export function NodeArticle({ node, ...props }: NodeArticleProps) {
9+
export function Article({ node, ...props }: ArticleProps) {
1110
return (
1211
<article {...props}>
1312
<h1 className="mb-4 text-6xl font-black leading-tight">{node.title}</h1>
@@ -21,18 +20,19 @@ export function NodeArticle({ node, ...props }: NodeArticleProps) {
2120
<span> - {formatDate(node.created)}</span>
2221
</div>
2322
{node.image && (
24-
<figure className="my-4">
23+
<figure>
2524
<Image
2625
src={node.image.url}
2726
width={768}
28-
height={480}
29-
alt={node.title}
27+
height={400}
28+
alt=""
29+
priority
3030
/>
3131
</figure>
3232
)}
3333
{node.body?.processed && (
3434
<div
35-
dangerouslySetInnerHTML={{ __html: node.body.processed }}
35+
dangerouslySetInnerHTML={{ __html: node.body?.processed }}
3636
className="mt-6 font-serif text-xl leading-loose prose"
3737
/>
3838
)}

components/node--article--teaser.tsx renamed to components/drupal/ArticleTeaser.tsx

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,16 @@
11
import Image from "next/image"
22
import Link from "next/link"
3+
import { formatDate } from "@/lib/utils"
4+
import type { NodeArticle } from "@/types"
35

4-
import { formatDate } from "lib/utils"
5-
import { Article } from "types"
6-
7-
interface NodeArticleTeaserProps {
8-
node: Partial<Article>
6+
interface ArticleTeaserProps {
7+
node: Partial<NodeArticle>
98
}
109

11-
export function NodeArticleTeaser({ node, ...props }: NodeArticleTeaserProps) {
10+
export function ArticleTeaser({ node, ...props }: ArticleTeaserProps) {
1211
return (
1312
<article {...props}>
14-
<Link href={node.path} className="no-underline hover:text-blue-600">
13+
<Link href={node.path || ""} className="no-underline hover:text-blue-600">
1514
<h2 className="mb-4 text-4xl font-bold">{node.title}</h2>
1615
</Link>
1716
<div className="mb-4 text-gray-600">
@@ -21,20 +20,15 @@ export function NodeArticleTeaser({ node, ...props }: NodeArticleTeaserProps) {
2120
<span className="font-semibold">{node.author.displayName}</span>
2221
</span>
2322
) : null}
24-
<span> - {formatDate(node.created)}</span>
23+
{node.created && <span> - {formatDate(node.created)}</span>}
2524
</div>
2625
{node.image && (
2726
<figure className="my-4">
28-
<Image
29-
src={node.image.url}
30-
width={768}
31-
height={480}
32-
alt={node.title}
33-
/>
27+
<Image src={node.image.url} width={768} height={480} alt="" />
3428
</figure>
3529
)}
3630
<Link
37-
href={node.path}
31+
href={node.path || ""}
3832
className="inline-flex items-center px-6 py-2 border border-gray-600 rounded-full hover:bg-gray-100"
3933
>
4034
Read article

components/node--basic-page.tsx renamed to components/drupal/BasicPage.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
import { Page } from "types"
1+
import type { NodePage } from "@/types"
22

3-
interface NodeBasicPageProps {
4-
node: Page
3+
interface BasicPageProps {
4+
node: NodePage
55
}
66

7-
export function NodeBasicPage({ node, ...props }: NodeBasicPageProps) {
7+
export function BasicPage({ node, ...props }: BasicPageProps) {
88
return (
99
<article {...props}>
1010
<h1 className="mb-4 text-6xl font-black leading-tight">{node.title}</h1>

0 commit comments

Comments
 (0)