@keystatic/templates-nextjs 0.0.0-test-20230817012139

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md ADDED
@@ -0,0 +1,116 @@
1
+ # @keystatic/templates-nextjs
2
+
3
+ ## 0.0.0-test-20230817012139
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [6895c566]
8
+ - Updated dependencies [ca6774b8]
9
+ - @keystatic/core@0.0.0-test-20230817012139
10
+
11
+ ## 0.0.13
12
+
13
+ ### Patch Changes
14
+
15
+ - Updated dependencies [c43d7045]
16
+ - Updated dependencies [21395048]
17
+ - @keystatic/core@0.0.116
18
+
19
+ ## 0.0.12
20
+
21
+ ### Patch Changes
22
+
23
+ - Updated dependencies [ad46c9dd]
24
+ - Updated dependencies [47102969]
25
+ - @keystatic/core@0.0.115
26
+
27
+ ## 0.0.11
28
+
29
+ ### Patch Changes
30
+
31
+ - Updated dependencies [6b4c476c]
32
+ - Updated dependencies [f9f09616]
33
+ - @keystatic/core@0.0.114
34
+
35
+ ## 0.0.10
36
+
37
+ ### Patch Changes
38
+
39
+ - Updated dependencies [07c63bab]
40
+ - Updated dependencies [062ccf49]
41
+ - @keystatic/core@0.0.113
42
+
43
+ ## 0.0.9
44
+
45
+ ### Patch Changes
46
+
47
+ - Updated dependencies [efc83c9c]
48
+ - @keystatic/core@0.0.112
49
+
50
+ ## 0.0.8
51
+
52
+ ### Patch Changes
53
+
54
+ - Updated dependencies [bf6a27bb]
55
+ - @keystatic/core@0.0.111
56
+
57
+ ## 0.0.7
58
+
59
+ ### Patch Changes
60
+
61
+ - Updated dependencies [e667fb9c]
62
+ - Updated dependencies [aec6359b]
63
+ - Updated dependencies [e0c4c37e]
64
+ - Updated dependencies [781884f9]
65
+ - Updated dependencies [cafe3695]
66
+ - @keystatic/core@0.0.110
67
+
68
+ ## 0.0.6
69
+
70
+ ### Patch Changes
71
+
72
+ - Updated dependencies [4e595627]
73
+ - Updated dependencies [477b4e96]
74
+ - Updated dependencies [b832e495]
75
+ - Updated dependencies [b6f4fb12]
76
+ - Updated dependencies [68e3be7c]
77
+ - @keystatic/core@0.0.109
78
+
79
+ ## 0.0.5
80
+
81
+ ### Patch Changes
82
+
83
+ - Updated dependencies [bbbca74f]
84
+ - Updated dependencies [944dbe67]
85
+ - Updated dependencies [91857b9b]
86
+ - Updated dependencies [0bafd9f1]
87
+ - Updated dependencies [9f16e062]
88
+ - @keystatic/core@0.0.108
89
+
90
+ ## 0.0.4
91
+
92
+ ### Patch Changes
93
+
94
+ - 12905059: Moved API routes from pages to app directory.
95
+
96
+ ## 0.0.3
97
+
98
+ ### Patch Changes
99
+
100
+ - Updated dependencies [0327f443]
101
+ - @keystatic/next@0.0.11
102
+
103
+ ## 0.0.2
104
+
105
+ ### Patch Changes
106
+
107
+ - Updated dependencies [0016a2b0]
108
+ - Updated dependencies [cd2d22d7]
109
+ - @keystatic/core@0.0.107
110
+ - @keystatic/next@0.0.10
111
+
112
+ ## 0.0.1
113
+
114
+ ### Patch Changes
115
+
116
+ - 818a4c14: Initial release of the NextJS template package.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) Thinkmill Labs Pty Ltd
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,20 @@
1
+ # Keystatic in Next.js
2
+
3
+ This template shows how you can use Keystatic in a Next.js site that utilises
4
+ the `app` directory.
5
+
6
+ To setup:
7
+
8
+ ```bash
9
+ npm install
10
+ ```
11
+
12
+ To run:
13
+
14
+ ```
15
+ npm run dev
16
+ ```
17
+
18
+ Admin UI: [http://127.0.0.1:3000/keystatic](http://127.0.0.1:3000/keystatic)
19
+
20
+ Homepage: [http://localhost:3000](http://localhost:3000)
@@ -0,0 +1,9 @@
1
+ import '../styles.css';
2
+
3
+ export default function RootLayout({
4
+ children,
5
+ }: {
6
+ children: React.ReactNode;
7
+ }) {
8
+ return <>{children}</>;
9
+ }
@@ -0,0 +1,27 @@
1
+ import { DocumentRenderer } from '@keystatic/core/renderer';
2
+ import { reader } from '../reader';
3
+
4
+ export default async function Post({ params }: { params: { slug: string } }) {
5
+ const { slug } = params;
6
+
7
+ const post = await reader.collections.posts.read(slug);
8
+
9
+ if (!post) return <div>Post not found!</div>;
10
+
11
+ return (
12
+ <div>
13
+ <h1>{post.title}</h1>
14
+ <div>
15
+ <DocumentRenderer document={await post.content()} />
16
+ </div>
17
+ </div>
18
+ );
19
+ }
20
+
21
+ export async function generateStaticParams() {
22
+ const slugs = await reader.collections.posts.list();
23
+
24
+ return slugs.map(slug => ({
25
+ slug,
26
+ }));
27
+ }
@@ -0,0 +1,6 @@
1
+ import { makeRouteHandler } from '@keystatic/next/route-handler';
2
+ import keystaticConfig from '../../../../keystatic.config';
3
+
4
+ export const { POST, GET } = makeRouteHandler({
5
+ config: keystaticConfig,
6
+ });
@@ -0,0 +1,3 @@
1
+ export default function Page() {
2
+ return null;
3
+ }
@@ -0,0 +1,6 @@
1
+ 'use client';
2
+
3
+ import { makePage } from '@keystatic/next/ui/app';
4
+ import config from '../../keystatic.config';
5
+
6
+ export default makePage(config);
@@ -0,0 +1,5 @@
1
+ import KeystaticApp from './keystatic';
2
+
3
+ export default function RootLayout() {
4
+ return <KeystaticApp />;
5
+ }
package/app/layout.tsx ADDED
@@ -0,0 +1,11 @@
1
+ export default function RootLayout({
2
+ children,
3
+ }: {
4
+ children: React.ReactNode;
5
+ }) {
6
+ return (
7
+ <html lang="en">
8
+ <body>{children}</body>
9
+ </html>
10
+ );
11
+ }
package/app/page.tsx ADDED
@@ -0,0 +1,26 @@
1
+ import Link from 'next/link';
2
+ import { reader } from './reader';
3
+ import './styles.css';
4
+
5
+ export default async function Homepage() {
6
+ const posts = await reader.collections.posts.all();
7
+
8
+ return (
9
+ <div>
10
+ <h1>Keystatic ⚡️</h1>
11
+ <p>This homepage shows how to load a collection from the reader API.</p>
12
+ <p>
13
+ <a href="/keystatic">Click here to visit the Admin UI</a>, or the link
14
+ below to view a post in the collection.
15
+ </p>
16
+ <h2>Posts</h2>
17
+ <ul>
18
+ {posts.map(post => (
19
+ <li key={post.slug}>
20
+ <Link href={`/${post.slug}`}>{post.entry.title}</Link>
21
+ </li>
22
+ ))}
23
+ </ul>
24
+ </div>
25
+ );
26
+ }
package/app/reader.ts ADDED
@@ -0,0 +1,4 @@
1
+ import { createReader } from '@keystatic/core/reader';
2
+ import keystaticConfig from '../keystatic.config';
3
+
4
+ export const reader = createReader(process.cwd(), keystaticConfig);
package/app/styles.css ADDED
@@ -0,0 +1,24 @@
1
+ html {
2
+ max-width: 70ch;
3
+ padding: 3rem 1rem;
4
+ margin: auto;
5
+ line-height: 1.75;
6
+ font-size: 1.25rem;
7
+ font-family: sans-serif;
8
+ }
9
+
10
+ h1,
11
+ h2,
12
+ h3,
13
+ h4,
14
+ h5,
15
+ h6 {
16
+ margin: 1rem 0 1rem;
17
+ }
18
+
19
+ p,
20
+ ul,
21
+ ol {
22
+ margin-bottom: 1rem;
23
+ color: #1d1d1d;
24
+ }
@@ -0,0 +1,25 @@
1
+ import { config, collection, fields } from '@keystatic/core';
2
+
3
+ export default config({
4
+ storage: {
5
+ kind: 'local',
6
+ },
7
+ collections: {
8
+ posts: collection({
9
+ label: 'Posts',
10
+ slugField: 'title',
11
+ path: 'posts/*',
12
+ format: { contentField: 'content' },
13
+ schema: {
14
+ title: fields.slug({ name: { label: 'Title' } }),
15
+ content: fields.document({
16
+ label: 'Content',
17
+ formatting: true,
18
+ dividers: true,
19
+ links: true,
20
+ images: true,
21
+ }),
22
+ },
23
+ }),
24
+ },
25
+ });
package/next.config.js ADDED
@@ -0,0 +1,4 @@
1
+ /** @type {import('next').NextConfig} */
2
+ module.exports = {
3
+ reactStrictMode: false,
4
+ };
package/package.json ADDED
@@ -0,0 +1,21 @@
1
+ {
2
+ "name": "@keystatic/templates-nextjs",
3
+ "version": "0.0.0-test-20230817012139",
4
+ "license": "MIT",
5
+ "dependencies": {
6
+ "@keystatic/core": "0.0.0-test-20230817012139",
7
+ "@keystatic/next": "^0.0.11",
8
+ "next": "^13.4.8",
9
+ "react": "^18.2.0",
10
+ "react-dom": "^18.2.0"
11
+ },
12
+ "devDependencies": {
13
+ "@types/react": "^18.2.8",
14
+ "typescript": "^5.1.3"
15
+ },
16
+ "scripts": {
17
+ "build": "next build",
18
+ "dev": "next dev",
19
+ "start": "next start"
20
+ }
21
+ }
@@ -0,0 +1,6 @@
1
+ ---
2
+ title: First post
3
+ ---
4
+ First!
5
+
6
+ You can edit this page in the [Admin UI](/keystatic/collection/posts/item/first-post), or directly in your IDE at `./posts/first-post.mdoc`.
package/tsconfig.json ADDED
@@ -0,0 +1,27 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "esnext",
4
+ "lib": ["dom", "dom.iterable", "esnext"],
5
+ "allowJs": true,
6
+ "skipLibCheck": true,
7
+ "strict": false,
8
+ "forceConsistentCasingInFileNames": true,
9
+ "noEmit": true,
10
+ "incremental": true,
11
+ "esModuleInterop": true,
12
+ "module": "esnext",
13
+ "moduleResolution": "node",
14
+ "resolveJsonModule": true,
15
+ "isolatedModules": true,
16
+ "downlevelIteration": true,
17
+ "jsx": "preserve",
18
+ "plugins": [
19
+ {
20
+ "name": "next"
21
+ }
22
+ ],
23
+ "strictNullChecks": true
24
+ },
25
+ "include": ["next-env.d.ts", ".next/types/**/*.ts", "**/*.ts", "**/*.tsx"],
26
+ "exclude": ["node_modules"]
27
+ }