Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/modernize-blog-example.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"notcms": patch
---

Update the Next.js blog example to Next.js 16 and React 19.
2 changes: 2 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,5 @@ jobs:
working-directory: packages/notcms
- run: pnpm run test
working-directory: packages/notcms
- run: pnpm run build:ci
working-directory: examples/nextjs-simple-blog-template
Binary file modified examples/nextjs-simple-blog-template/app/favicon.ico
Binary file not shown.
2 changes: 1 addition & 1 deletion examples/nextjs-simple-blog-template/components/Header.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from "react";

export const Header = (): JSX.Element => {
export const Header = (): React.JSX.Element => {
return (
<div className="flex w-[1440px] h-16 items-center gap-10 px-32 py-0 relative">
<div className="flex items-center gap-2 relative flex-1 grow">
Expand Down
18 changes: 11 additions & 7 deletions examples/nextjs-simple-blog-template/components/blog/list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ export function BlogPagesList({
pages: Pages;
writers: Writers;
}) {
const featuredPage = pages[0];

return (
<main className="container max-w-[1440px] px-4 md:px-32 mx-auto py-8">
<div className="flex flex-col w-full mb-8 items-start gap-5 flex-[0_0_auto]">
Expand Down Expand Up @@ -60,13 +62,15 @@ export function BlogPagesList({
</div>

<div className="grid grid-cols-1 gap-8">
<HeroBlogPostCard
className="hidden md:flex"
page={pages[0]}
writer={writers.find(
(w) => w.id === pages[0].properties.writers?.[0]
)}
/>
{featuredPage && (
<HeroBlogPostCard
className="hidden md:flex"
page={featuredPage}
writer={writers.find(
(writer) => writer.id === featuredPage.properties.writers?.[0]
)}
/>
)}

<div className="grid grid-cols-1 md:grid-cols-3 gap-4 md:first:hidden">
{pages.map((page, i) => {
Expand Down
20 changes: 11 additions & 9 deletions examples/nextjs-simple-blog-template/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,24 @@
"scripts": {
"dev": "next dev",
"build": "next build",
"start": "next start",
"lint": "next lint"
"build:ci": "node scripts/build-ci.mjs",
"start": "next start"
},
"dependencies": {
"clsx": "2.1.1",
"marked": "^14.1.3",
"next": "14.2.32",
"next": "16.2.10",
"notcms": "0.0.12-development",
"react": "^18.3.1",
"react-dom": "^18.3.1"
"react": "^19.2.7",
"react-dom": "^19.2.7",
"tailwind-merge": "3.6.0"
},
"devDependencies": {
"@types/node": "^24",
"@types/react": "^18",
"@types/react-dom": "^18",
"postcss": "^8",
"tailwindcss": "^3",
"@types/react": "^19.2.17",
"@types/react-dom": "^19.2.3",
"postcss": "^8.5.16",
"tailwindcss": "^3.4.19",
"typescript": "^5"
}
}
43 changes: 43 additions & 0 deletions examples/nextjs-simple-blog-template/scripts/build-ci.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import { spawn } from "node:child_process";
import { createServer } from "node:http";

const host = "127.0.0.1";
const server = createServer((_request, response) => {
response.writeHead(200, { "Content-Type": "application/json" });
response.end(JSON.stringify({ data: [] }));
});

await new Promise((resolve, reject) => {
server.once("error", reject);
server.listen(0, host, resolve);
});

const address = server.address();
if (!address || typeof address === "string") {
throw new Error("Failed to start the NotCMS mock server.");
}

let exitCode = 1;
try {
const command = process.platform === "win32" ? "next.cmd" : "next";
exitCode = await new Promise((resolve, reject) => {
const build = spawn(command, ["build"], {
env: {
...process.env,
NOTCMS_API_HOST: `http://${host}:${address.port}`,
NOTCMS_SECRET_KEY: "ci-build",
NOTCMS_WORKSPACE_ID: "ci-build",
},
stdio: "inherit",
});

build.once("error", reject);
build.once("exit", (code) => resolve(code ?? 1));
});
} finally {
await new Promise((resolve, reject) => {
server.close((error) => (error ? reject(error) : resolve()));
});
}

process.exitCode = exitCode;
13 changes: 10 additions & 3 deletions examples/nextjs-simple-blog-template/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"moduleResolution": "bundler",
"resolveJsonModule": true,
"isolatedModules": true,
"jsx": "preserve",
"jsx": "react-jsx",
"incremental": true,
"plugins": [
{
Expand All @@ -19,8 +19,15 @@
],
"paths": {
"~/*": ["./*"]
}
},
"target": "ES2017"
},
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"],
"include": [
"next-env.d.ts",
"**/*.ts",
"**/*.tsx",
".next/types/**/*.ts",
".next/dev/types/**/*.ts"
],
"exclude": ["node_modules"]
}
Loading
Loading