Skip to content

Commit 13dac25

Browse files
committed
feat: upgrade basic-starter to Next.js v14
Issue #601
1 parent b723ac5 commit 13dac25

29 files changed

+254
-4544
lines changed

starters/.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Starters should never have a lock file.
2+
package-lock.json
3+
pnpm-lock.yaml
4+
yarn.lock
Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +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
6+
7+
# Authentication
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
413

514
# Required for On-demand Revalidation
6-
DRUPAL_REVALIDATE_SECRET=secret
15+
DRUPAL_REVALIDATE_SECRET=Retrieve this from /admin/config/services/next
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
}

starters/basic-starter/.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

starters/basic-starter/.nvmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
v20
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
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+
}

starters/basic-starter/components/layout.tsx renamed to starters/basic-starter/components/Layout.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import Link from "next/link"
2+
import { PreviewAlert } from "@/components/PreviewAlert"
3+
import type { ReactNode } from "react"
24

3-
import { PreviewAlert } from "components/preview-alert"
4-
5-
export function Layout({ children }) {
5+
export function Layout({ children }: { children: ReactNode }) {
66
return (
77
<>
88
<PreviewAlert />
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+
}

starters/basic-starter/components/node--article.tsx renamed to starters/basic-starter/components/drupal/Article.tsx

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
import Image from "next/image"
2-
import { DrupalNode } from "next-drupal"
2+
import { absoluteUrl, formatDate } from "@/lib/utils"
3+
import type { DrupalNode } from "next-drupal"
34

4-
import { absoluteUrl, formatDate } from "lib/utils"
5-
6-
interface NodeArticleProps {
5+
interface ArticleProps {
76
node: DrupalNode
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>
@@ -26,7 +25,7 @@ export function NodeArticle({ node, ...props }: NodeArticleProps) {
2625
src={absoluteUrl(node.field_image.uri.url)}
2726
width={768}
2827
height={400}
29-
alt={node.field_image.resourceIdObjMeta.alt}
28+
alt={node.field_image.resourceIdObjMeta.alt || ""}
3029
priority
3130
/>
3231
{node.field_image.resourceIdObjMeta.title && (

0 commit comments

Comments
 (0)