create-puck-app 0.22.4 → 0.23.0-canary.026f0300

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-puck-app",
3
- "version": "0.22.4",
3
+ "version": "0.23.0-canary.026f0300",
4
4
  "author": "Chris Villa <chris@puckeditor.com>",
5
5
  "repository": "puckeditor/puck",
6
6
  "bugs": "https://github.com/puckeditor/puck/issues",
@@ -4,7 +4,7 @@ import type { Data } from "@puckeditor/core";
4
4
  import { Puck } from "@puckeditor/core";
5
5
  import config from "../../../puck.config";
6
6
 
7
- export function Client({ path, data }: { path: string; data: Partial<Data> }) {
7
+ export function Client({ path, data }: { path: string; data: Data }) {
8
8
  return (
9
9
  <Puck
10
10
  config={config}
@@ -12,10 +12,21 @@
12
12
  */
13
13
 
14
14
  import "@puckeditor/core/puck.css";
15
- import { Client } from "./client";
15
+ import type { Data } from "@puckeditor/core";
16
16
  import { Metadata } from "next";
17
+ import { Client } from "./client";
17
18
  import { getPage } from "../../../lib/get-page";
18
19
 
20
+ // Empty data for new pages.
21
+ const EMPTY_PAGE_DATA: Data = {
22
+ content: [],
23
+ root: {
24
+ props: {
25
+ title: "",
26
+ },
27
+ },
28
+ };
29
+
19
30
  export async function generateMetadata({
20
31
  params,
21
32
  }: {
@@ -38,7 +49,7 @@ export default async function Page({
38
49
  const path = `/${puckPath.join("/")}`;
39
50
  const data = getPage(path);
40
51
 
41
- return <Client path={path} data={data || {}} />;
52
+ return <Client path={path} data={data || EMPTY_PAGE_DATA} />;
42
53
  }
43
54
 
44
55
  export const dynamic = "force-dynamic";
@@ -19,7 +19,7 @@ const aiPlugin = createAiPlugin({
19
19
  // Place the ai plugin in the first position in the side nav.
20
20
  const plugins = [aiPlugin, blocksPlugin(), outlinePlugin()];
21
21
 
22
- export function Client({ path, data }: { path: string; data: Partial<Data> }) {
22
+ export function Client({ path, data }: { path: string; data: Data }) {
23
23
  const configWithDesignedComponents = withDynamicConfig(config, data);
24
24
 
25
25
  return (
@@ -13,10 +13,21 @@
13
13
 
14
14
  import "@puckeditor/core/puck.css";
15
15
  import "@puckeditor/plugin-ai/styles.css";
16
- import { Client } from "./client";
16
+ import type { Data } from "@puckeditor/core";
17
17
  import { Metadata } from "next";
18
+ import { Client } from "./client";
18
19
  import { getPage } from "../../../lib/get-page";
19
20
 
21
+ // Empty data for new pages
22
+ const EMPTY_PAGE_DATA: Data = {
23
+ content: [],
24
+ root: {
25
+ props: {
26
+ title: "",
27
+ },
28
+ },
29
+ };
30
+
20
31
  export async function generateMetadata({
21
32
  params,
22
33
  }: {
@@ -37,9 +48,10 @@ export default async function Page({
37
48
  }) {
38
49
  const { puckPath = [] } = await params;
39
50
  const path = `/${puckPath.join("/")}`;
51
+
40
52
  const data = getPage(path);
41
53
 
42
- return <Client path={path} data={data || {}} />;
54
+ return <Client path={path} data={data || EMPTY_PAGE_DATA} />;
43
55
  }
44
56
 
45
57
  export const dynamic = "force-dynamic";
@@ -8,8 +8,8 @@
8
8
  "start": "next start"
9
9
  },
10
10
  "dependencies": {
11
- "@puckeditor/core": "{{puckVersion}}",
12
11
  "@puckeditor/cloud-client": "^0",
12
+ "@puckeditor/core": "{{puckVersion}}",
13
13
  "@puckeditor/plugin-ai": "^0",
14
14
  "classnames": "^2.3.2",
15
15
  "next": "^16.0.8",
@@ -6,6 +6,7 @@ import { createAiPlugin, withDynamicConfig } from "@puckeditor/plugin-ai";
6
6
 
7
7
  import type { Route } from "./+types/puck-splat";
8
8
  import { config } from "../../puck.config";
9
+ import type { UserData } from "../../puck.config";
9
10
  import { resolvePuckPath } from "~/lib/resolve-puck-path.server";
10
11
  import { getPage, savePage } from "~/lib/pages.server";
11
12
  import { PuckRender } from "~/components/puck-render";
@@ -92,9 +93,7 @@ function Editor() {
92
93
  data={loaderData.data}
93
94
  onPublish={async (data) => {
94
95
  await fetcher.submit(
95
- {
96
- data,
97
- },
96
+ { data: data as UserData },
98
97
  {
99
98
  action: "",
100
99
  method: "post",
@@ -10,8 +10,8 @@
10
10
  "typecheck": "react-router typegen && tsc"
11
11
  },
12
12
  "dependencies": {
13
- "@puckeditor/core": "{{puckVersion}}",
14
13
  "@puckeditor/cloud-client": "^0",
14
+ "@puckeditor/core": "{{puckVersion}}",
15
15
  "@puckeditor/plugin-ai": "^0",
16
16
  "@react-router/node": "^7.5.3",
17
17
  "@react-router/serve": "^7.5.3",
@@ -1,9 +1,11 @@
1
- import type { Config } from "@puckeditor/core";
1
+ import type { Config, Data } from "@puckeditor/core";
2
2
 
3
- type Props = {
3
+ export type Props = {
4
4
  HeadingBlock: { title: string };
5
5
  };
6
6
 
7
+ export type UserData = Data<Props>;
8
+
7
9
  export const config: Config<Props> = {
8
10
  components: {
9
11
  HeadingBlock: {