@pantheon-systems/create-p1-starter-kit 0.4.2 → 0.4.4
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/package.json +1 -1
- package/template/.env.example +4 -2
- package/template/CHANGELOG.md +18 -0
- package/template/app/[...puckPath]/page.tsx +10 -1
- package/template/app/p1/[[...p1]]/editor-client.tsx +59 -4
- package/template/app/p1/[[...p1]]/page.tsx +1 -1
- package/template/app/p1/api/[...p1]/route.ts +1 -1
- package/template/app/p1/auth/[...action]/route.ts +1 -1
- package/template/app/page.tsx +1 -1
- package/template/package.json +3 -3
- package/template/public/favicon.ico +0 -0
package/package.json
CHANGED
package/template/.env.example
CHANGED
|
@@ -2,9 +2,11 @@ PCC_SITE_ID=your-site-id
|
|
|
2
2
|
PCC_TOKEN=your-token
|
|
3
3
|
|
|
4
4
|
# --- P1 backend ---
|
|
5
|
-
NEXT_PUBLIC_CSS_BASE_URL
|
|
5
|
+
# NEXT_PUBLIC_CSS_BASE_URL defaults to https://ccr.p1.pantheon for production.
|
|
6
|
+
# Override for staging, local, or sandbox deployments:
|
|
7
|
+
# NEXT_PUBLIC_CSS_BASE_URL=https://staging.example.com
|
|
6
8
|
NEXT_PUBLIC_CSS_SITE_ID=site-123
|
|
7
|
-
|
|
9
|
+
CSS_API_KEY=your-api-key
|
|
8
10
|
|
|
9
11
|
# --- P1 Admin Dashboard (optional) ---
|
|
10
12
|
# Override the default dashboard URL (https://content.pantheon.io)
|
package/template/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# @pantheon-systems/p1-starter
|
|
2
2
|
|
|
3
|
+
## 1.0.3
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies
|
|
8
|
+
- @pantheon-systems/puck-css@0.4.4
|
|
9
|
+
- @pantheon-systems/p1-next-sdk@0.4.4
|
|
10
|
+
- @pantheon-systems/css-client@0.4.4
|
|
11
|
+
|
|
12
|
+
## 1.0.2
|
|
13
|
+
|
|
14
|
+
### Patch Changes
|
|
15
|
+
|
|
16
|
+
- Updated dependencies
|
|
17
|
+
- @pantheon-systems/puck-css@0.4.3
|
|
18
|
+
- @pantheon-systems/p1-next-sdk@0.4.3
|
|
19
|
+
- @pantheon-systems/css-client@0.4.3
|
|
20
|
+
|
|
3
21
|
## 1.0.1
|
|
4
22
|
|
|
5
23
|
### Patch Changes
|
|
@@ -18,7 +18,7 @@ import { REMOTE_DATASOURCE_FETCHERS } from "../../lib/remote-datasource-fetchers
|
|
|
18
18
|
|
|
19
19
|
const initPromise = ensureInitialized({
|
|
20
20
|
p1BaseUrl: process.env.NEXT_PUBLIC_CSS_BASE_URL,
|
|
21
|
-
p1ApiKey: process.env.
|
|
21
|
+
p1ApiKey: process.env.CSS_API_KEY,
|
|
22
22
|
p1SiteId: process.env.NEXT_PUBLIC_CSS_SITE_ID,
|
|
23
23
|
p1BranchId: process.env.NEXT_PUBLIC_CSS_BRANCH_ID,
|
|
24
24
|
});
|
|
@@ -34,6 +34,10 @@ export async function generateMetadata({
|
|
|
34
34
|
const { puckPath = [] } = await params;
|
|
35
35
|
const path = pagePathFromCatchAllSegments(puckPath);
|
|
36
36
|
|
|
37
|
+
if (path.startsWith("/_registry/") || path === "/_registry") {
|
|
38
|
+
return { title: "Not Found" };
|
|
39
|
+
}
|
|
40
|
+
|
|
37
41
|
const [pageData, sp, routeTemplateKeys] = await Promise.all([
|
|
38
42
|
getPage(path),
|
|
39
43
|
searchParams,
|
|
@@ -70,6 +74,11 @@ export default async function Page({
|
|
|
70
74
|
const { puckPath = [] } = await params;
|
|
71
75
|
const path = pagePathFromCatchAllSegments(puckPath);
|
|
72
76
|
|
|
77
|
+
if (path.startsWith("/_registry/") || path === "/_registry") {
|
|
78
|
+
const { notFound } = await import("next/navigation");
|
|
79
|
+
notFound();
|
|
80
|
+
}
|
|
81
|
+
|
|
73
82
|
const [data, searchParamData, routeTemplateKeys] = await Promise.all([
|
|
74
83
|
getPage(path),
|
|
75
84
|
searchParams,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
|
-
import React, { useCallback } from "react";
|
|
3
|
+
import React, { useCallback, useState } from "react";
|
|
4
4
|
import { useRouter } from "next/navigation";
|
|
5
5
|
import { Puck } from "@puckeditor/core";
|
|
6
6
|
import {
|
|
@@ -10,9 +10,11 @@ import {
|
|
|
10
10
|
useP1Plugins,
|
|
11
11
|
wrapConfigForEditorPreview,
|
|
12
12
|
P1QueryProvider,
|
|
13
|
+
editorPathHref,
|
|
13
14
|
} from "@pantheon-systems/puck-css";
|
|
14
15
|
import { P1NextRouterProvider } from "@pantheon-systems/p1-next-sdk";
|
|
15
16
|
import type { Checkpoint } from "@pantheon-systems/puck-css";
|
|
17
|
+
import type { ContentRole } from "@pantheon-systems/puck-css";
|
|
16
18
|
|
|
17
19
|
import "@pantheon-systems/puck-css/styles.css";
|
|
18
20
|
import "@pantheon-systems/puck-css/pds/styles.css";
|
|
@@ -30,8 +32,10 @@ try {
|
|
|
30
32
|
|
|
31
33
|
const editorConfig = wrapConfigForEditorPreview(config);
|
|
32
34
|
|
|
35
|
+
const ROLES: ContentRole[] = ['admin', 'editor', 'junior-editor'];
|
|
36
|
+
|
|
33
37
|
export function EditorClientWrapper({ path }: { path: string }) {
|
|
34
|
-
|
|
38
|
+
const [userRole, setUserRole] = useState<ContentRole>('editor');
|
|
35
39
|
const lastGoodStateRef = React.useRef<{ puckKey: string; puckProps: any } | null>(null);
|
|
36
40
|
|
|
37
41
|
if (!p1Config) {
|
|
@@ -53,16 +57,67 @@ export function EditorClientWrapper({ path }: { path: string }) {
|
|
|
53
57
|
<P1QueryProvider>
|
|
54
58
|
<P1NextRouterProvider>
|
|
55
59
|
<P1App
|
|
56
|
-
config={p1Config}
|
|
60
|
+
config={{ ...p1Config, userRole }}
|
|
57
61
|
loginPageProps={{ title: "P1 Starter", subtitle: "Sign in to edit" }}
|
|
58
62
|
>
|
|
59
63
|
<EditorContent path={path} lastGoodStateRef={lastGoodStateRef} />
|
|
60
64
|
</P1App>
|
|
65
|
+
<RoleSwitcher currentRole={userRole} onRoleChange={setUserRole} />
|
|
61
66
|
</P1NextRouterProvider>
|
|
62
67
|
</P1QueryProvider>
|
|
63
68
|
);
|
|
64
69
|
}
|
|
65
70
|
|
|
71
|
+
function RoleSwitcher({
|
|
72
|
+
currentRole,
|
|
73
|
+
onRoleChange,
|
|
74
|
+
}: {
|
|
75
|
+
currentRole: ContentRole;
|
|
76
|
+
onRoleChange: (role: ContentRole) => void;
|
|
77
|
+
}) {
|
|
78
|
+
return (
|
|
79
|
+
<div
|
|
80
|
+
style={{
|
|
81
|
+
position: "fixed",
|
|
82
|
+
bottom: 16,
|
|
83
|
+
right: 16,
|
|
84
|
+
zIndex: 99999,
|
|
85
|
+
background: "rgba(0,0,0,0.85)",
|
|
86
|
+
color: "#fff",
|
|
87
|
+
borderRadius: 8,
|
|
88
|
+
padding: "8px 12px",
|
|
89
|
+
fontFamily: "system-ui",
|
|
90
|
+
fontSize: 12,
|
|
91
|
+
display: "flex",
|
|
92
|
+
alignItems: "center",
|
|
93
|
+
gap: 8,
|
|
94
|
+
boxShadow: "0 2px 8px rgba(0,0,0,0.3)",
|
|
95
|
+
}}
|
|
96
|
+
>
|
|
97
|
+
<span style={{ opacity: 0.7 }}>Role:</span>
|
|
98
|
+
<select
|
|
99
|
+
value={currentRole}
|
|
100
|
+
onChange={(e) => onRoleChange(e.target.value as ContentRole)}
|
|
101
|
+
style={{
|
|
102
|
+
background: "rgba(255,255,255,0.15)",
|
|
103
|
+
color: "#fff",
|
|
104
|
+
border: "1px solid rgba(255,255,255,0.3)",
|
|
105
|
+
borderRadius: 4,
|
|
106
|
+
padding: "2px 6px",
|
|
107
|
+
fontSize: 12,
|
|
108
|
+
cursor: "pointer",
|
|
109
|
+
}}
|
|
110
|
+
>
|
|
111
|
+
{ROLES.map((role) => (
|
|
112
|
+
<option key={role} value={role}>
|
|
113
|
+
{role}
|
|
114
|
+
</option>
|
|
115
|
+
))}
|
|
116
|
+
</select>
|
|
117
|
+
</div>
|
|
118
|
+
);
|
|
119
|
+
}
|
|
120
|
+
|
|
66
121
|
function EditorContent({
|
|
67
122
|
path,
|
|
68
123
|
lastGoodStateRef,
|
|
@@ -75,7 +130,7 @@ function EditorContent({
|
|
|
75
130
|
|
|
76
131
|
const handleDocumentSelect = useCallback(
|
|
77
132
|
(docPath: string) => {
|
|
78
|
-
router.push(
|
|
133
|
+
router.push(editorPathHref(docPath));
|
|
79
134
|
},
|
|
80
135
|
[router],
|
|
81
136
|
);
|
|
@@ -7,7 +7,7 @@ import { RenderClientWrapper } from "./render-client";
|
|
|
7
7
|
const pages = createP1Pages({
|
|
8
8
|
config,
|
|
9
9
|
p1BaseUrl: process.env.NEXT_PUBLIC_CSS_BASE_URL,
|
|
10
|
-
p1ApiKey: process.env.
|
|
10
|
+
p1ApiKey: process.env.CSS_API_KEY,
|
|
11
11
|
p1SiteId: process.env.NEXT_PUBLIC_CSS_SITE_ID,
|
|
12
12
|
p1BranchId: process.env.NEXT_PUBLIC_CSS_BRANCH_ID,
|
|
13
13
|
EditorClient: EditorClientWrapper,
|
|
@@ -6,7 +6,7 @@ import { REMOTE_DATASOURCE_REGISTRY } from "../../../../lib/remote-datasources";
|
|
|
6
6
|
const handler = createP1Handler({
|
|
7
7
|
config,
|
|
8
8
|
p1BaseUrl: process.env.NEXT_PUBLIC_CSS_BASE_URL,
|
|
9
|
-
p1ApiKey: process.env.
|
|
9
|
+
p1ApiKey: process.env.CSS_API_KEY,
|
|
10
10
|
p1SiteId: process.env.NEXT_PUBLIC_CSS_SITE_ID,
|
|
11
11
|
p1BranchId: process.env.NEXT_PUBLIC_CSS_BRANCH_ID,
|
|
12
12
|
builtinFetchers: REMOTE_DATASOURCE_FETCHERS,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createP1AuthHandler } from "@pantheon-systems/p1-next-sdk/server";
|
|
2
2
|
|
|
3
3
|
const handler = createP1AuthHandler({
|
|
4
|
-
p1ApiKey: process.env.
|
|
4
|
+
p1ApiKey: process.env.CSS_API_KEY,
|
|
5
5
|
p1BaseUrl: process.env.NEXT_PUBLIC_CSS_BASE_URL,
|
|
6
6
|
prompt: 'login',
|
|
7
7
|
});
|
package/template/app/page.tsx
CHANGED
|
@@ -16,7 +16,7 @@ import { CollectionNav } from "./collection-nav";
|
|
|
16
16
|
|
|
17
17
|
const initPromise = ensureInitialized({
|
|
18
18
|
p1BaseUrl: process.env.NEXT_PUBLIC_CSS_BASE_URL,
|
|
19
|
-
p1ApiKey: process.env.
|
|
19
|
+
p1ApiKey: process.env.CSS_API_KEY,
|
|
20
20
|
p1SiteId: process.env.NEXT_PUBLIC_CSS_SITE_ID,
|
|
21
21
|
p1BranchId: process.env.NEXT_PUBLIC_CSS_BRANCH_ID,
|
|
22
22
|
});
|
package/template/package.json
CHANGED
|
@@ -11,9 +11,9 @@
|
|
|
11
11
|
},
|
|
12
12
|
"dependencies": {
|
|
13
13
|
"@pantheon-systems/cpub-react-sdk": "^5.2.1",
|
|
14
|
-
"@pantheon-systems/css-client": "^0.4.
|
|
15
|
-
"@pantheon-systems/p1-next-sdk": "^0.4.
|
|
16
|
-
"@pantheon-systems/puck-css": "^0.4.
|
|
14
|
+
"@pantheon-systems/css-client": "^0.4.4",
|
|
15
|
+
"@pantheon-systems/p1-next-sdk": "^0.4.4",
|
|
16
|
+
"@pantheon-systems/puck-css": "^0.4.4",
|
|
17
17
|
"@puckeditor/core": "^0.21.1",
|
|
18
18
|
"@tailwindcss/postcss": "^4.2.2",
|
|
19
19
|
"classnames": "^2.5.1",
|
|
Binary file
|