Skip to content

Commit 0179822

Browse files
committed
test: fixture for dynamic cms results
1 parent 995422b commit 0179822

File tree

15 files changed

+124
-20
lines changed

15 files changed

+124
-20
lines changed

tests/fixtures/dynamic-cms/README.md

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
This fixture is meant to emulate dynamic content responses of a CMS-backed next site
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import { getDeployStore } from '@netlify/blobs'
2+
import { Context } from '@netlify/functions'
3+
4+
// publish or unpublish "cms content" depending on the sent operation
5+
export default async function handler(_request: Request, context: Context) {
6+
const store = getDeployStore({ name: 'cms-content', consistency: 'strong' })
7+
const BLOB_KEY = 'key'
8+
9+
const operation = context.params['operation']
10+
11+
if (operation === 'publish') {
12+
await store.setJSON(BLOB_KEY, { content: true })
13+
}
14+
15+
if (operation === 'unpublish') {
16+
await store.delete(BLOB_KEY)
17+
}
18+
19+
return Response.json({ ok: true })
20+
}
21+
22+
export const config = {
23+
path: '/cms/:operation',
24+
}
+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
/** @type {import('next').NextConfig} */
2+
const nextConfig = {
3+
output: 'standalone',
4+
eslint: {
5+
ignoreDuringBuilds: true,
6+
},
7+
generateBuildId: () => 'build-id',
8+
}
9+
10+
module.exports = nextConfig
+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{
2+
"name": "dynamic-cms",
3+
"version": "0.1.0",
4+
"private": true,
5+
"scripts": {
6+
"postinstall": "next build",
7+
"dev": "next dev",
8+
"build": "next build"
9+
},
10+
"dependencies": {
11+
"@netlify/blobs": "^8.1.0",
12+
"@netlify/functions": "^2.7.0",
13+
"@netlify/plugin-nextjs": "^5.10.1",
14+
"netlify-cli": "^19.0.3",
15+
"next": "latest",
16+
"react": "18.2.0",
17+
"react-dom": "18.2.0"
18+
},
19+
"devDependencies": {
20+
"@types/node": "22.13.13",
21+
"@types/react": "19.0.12",
22+
"typescript": "5.8.2"
23+
}
24+
}
+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export default function NotFound() {
2+
return <p>Custom 404 page</p>
3+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
export default async function handler(req, res) {
2+
try {
3+
const pathToPurge = req.query.path ?? '/static/revalidate-manual'
4+
await res.revalidate(pathToPurge)
5+
return res.json({ code: 200, message: 'success' })
6+
} catch (err) {
7+
return res.status(500).send({ code: 500, message: err.message })
8+
}
9+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import { getDeployStore } from '@netlify/blobs'
2+
3+
const Content = ({ value }) => (
4+
<div>
5+
<p>
6+
<span>{JSON.stringify(value)}</span>
7+
</p>
8+
</div>
9+
)
10+
11+
export async function getStaticProps() {
12+
const store = getDeployStore({ name: 'cms-content', consistency: 'strong' })
13+
const BLOB_KEY = 'key'
14+
15+
const value = await store.get(BLOB_KEY, { type: 'json' })
16+
17+
if (!value) {
18+
return {
19+
notFound: true,
20+
}
21+
}
22+
23+
return {
24+
props: {
25+
value: value,
26+
},
27+
}
28+
}
29+
30+
export const getStaticPaths = () => {
31+
return {
32+
paths: [],
33+
fallback: 'blocking', // false or "blocking"
34+
}
35+
}
36+
37+
export default Content

tests/fixtures/turborepo-npm/apps/docs/app/globals.css

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
:root {
22
--max-width: 1100px;
33
--border-radius: 12px;
4-
--font-mono:
5-
ui-monospace, Menlo, Monaco, 'Cascadia Mono', 'Segoe UI Mono', 'Roboto Mono', 'Oxygen Mono',
6-
'Ubuntu Monospace', 'Source Code Pro', 'Fira Mono', 'Droid Sans Mono', 'Courier New', monospace;
4+
--font-mono: ui-monospace, Menlo, Monaco, 'Cascadia Mono', 'Segoe UI Mono', 'Roboto Mono',
5+
'Oxygen Mono', 'Ubuntu Monospace', 'Source Code Pro', 'Fira Mono', 'Droid Sans Mono',
6+
'Courier New', monospace;
77

88
--foreground-rgb: 255, 255, 255;
99
--background-start-rgb: 0, 0, 0;

tests/fixtures/turborepo-npm/apps/docs/app/page.module.css

+1-2
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,7 @@
5959
justify-content: space-between;
6060
align-items: center;
6161
width: auto;
62-
font-family:
63-
system-ui, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, 'Noto Sans', sans-serif,
62+
font-family: system-ui, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, 'Noto Sans', sans-serif,
6463
'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji';
6564
padding-top: 48px;
6665

tests/fixtures/turborepo-npm/apps/web/app/globals.css

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
:root {
22
--max-width: 1100px;
33
--border-radius: 12px;
4-
--font-mono:
5-
ui-monospace, Menlo, Monaco, 'Cascadia Mono', 'Segoe UI Mono', 'Roboto Mono', 'Oxygen Mono',
6-
'Ubuntu Monospace', 'Source Code Pro', 'Fira Mono', 'Droid Sans Mono', 'Courier New', monospace;
4+
--font-mono: ui-monospace, Menlo, Monaco, 'Cascadia Mono', 'Segoe UI Mono', 'Roboto Mono',
5+
'Oxygen Mono', 'Ubuntu Monospace', 'Source Code Pro', 'Fira Mono', 'Droid Sans Mono',
6+
'Courier New', monospace;
77

88
--foreground-rgb: 255, 255, 255;
99
--background-start-rgb: 0, 0, 0;

tests/fixtures/turborepo-npm/apps/web/app/page.module.css

+1-2
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,7 @@
5959
justify-content: space-between;
6060
align-items: center;
6161
width: auto;
62-
font-family:
63-
system-ui, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, 'Noto Sans', sans-serif,
62+
font-family: system-ui, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, 'Noto Sans', sans-serif,
6463
'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji';
6564
padding-top: 48px;
6665

tests/fixtures/turborepo/apps/docs/app/globals.css

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
:root {
22
--max-width: 1100px;
33
--border-radius: 12px;
4-
--font-mono:
5-
ui-monospace, Menlo, Monaco, 'Cascadia Mono', 'Segoe UI Mono', 'Roboto Mono', 'Oxygen Mono',
6-
'Ubuntu Monospace', 'Source Code Pro', 'Fira Mono', 'Droid Sans Mono', 'Courier New', monospace;
4+
--font-mono: ui-monospace, Menlo, Monaco, 'Cascadia Mono', 'Segoe UI Mono', 'Roboto Mono',
5+
'Oxygen Mono', 'Ubuntu Monospace', 'Source Code Pro', 'Fira Mono', 'Droid Sans Mono',
6+
'Courier New', monospace;
77

88
--foreground-rgb: 255, 255, 255;
99
--background-start-rgb: 0, 0, 0;

tests/fixtures/turborepo/apps/docs/app/page.module.css

+1-2
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,7 @@
5959
justify-content: space-between;
6060
align-items: center;
6161
width: auto;
62-
font-family:
63-
system-ui, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, 'Noto Sans', sans-serif,
62+
font-family: system-ui, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, 'Noto Sans', sans-serif,
6463
'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji';
6564
padding-top: 48px;
6665

tests/fixtures/turborepo/apps/web/app/globals.css

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
:root {
22
--max-width: 1100px;
33
--border-radius: 12px;
4-
--font-mono:
5-
ui-monospace, Menlo, Monaco, 'Cascadia Mono', 'Segoe UI Mono', 'Roboto Mono', 'Oxygen Mono',
6-
'Ubuntu Monospace', 'Source Code Pro', 'Fira Mono', 'Droid Sans Mono', 'Courier New', monospace;
4+
--font-mono: ui-monospace, Menlo, Monaco, 'Cascadia Mono', 'Segoe UI Mono', 'Roboto Mono',
5+
'Oxygen Mono', 'Ubuntu Monospace', 'Source Code Pro', 'Fira Mono', 'Droid Sans Mono',
6+
'Courier New', monospace;
77

88
--foreground-rgb: 255, 255, 255;
99
--background-start-rgb: 0, 0, 0;

tests/fixtures/turborepo/apps/web/app/page.module.css

+1-2
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,7 @@
5959
justify-content: space-between;
6060
align-items: center;
6161
width: auto;
62-
font-family:
63-
system-ui, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, 'Noto Sans', sans-serif,
62+
font-family: system-ui, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, 'Noto Sans', sans-serif,
6463
'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji';
6564
padding-top: 48px;
6665

0 commit comments

Comments
 (0)