@slicemachine/adapter-sveltekit 0.3.18-dev-next-release.3 → 0.3.18-dev-next-release.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/dist/hooks/documentation-read.cjs +114 -0
- package/dist/hooks/documentation-read.cjs.map +1 -0
- package/dist/hooks/documentation-read.d.ts +3 -0
- package/dist/hooks/documentation-read.js +114 -0
- package/dist/hooks/documentation-read.js.map +1 -0
- package/dist/plugin.cjs +2 -3
- package/dist/plugin.cjs.map +1 -1
- package/dist/plugin.js +2 -3
- package/dist/plugin.js.map +1 -1
- package/package.json +3 -3
- package/src/hooks/documentation-read.ts +141 -0
- package/src/plugin.ts +2 -4
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const commonTags = require("common-tags");
|
|
4
|
+
const getJSFileExtension = require("../lib/getJSFileExtension.cjs");
|
|
5
|
+
var __freeze = Object.freeze;
|
|
6
|
+
var __defProp = Object.defineProperty;
|
|
7
|
+
var __template = (cooked, raw) => __freeze(__defProp(cooked, "raw", { value: __freeze(raw || cooked.slice()) }));
|
|
8
|
+
var _a;
|
|
9
|
+
const nestRouteFilePath = (filePath, nesting) => {
|
|
10
|
+
return [
|
|
11
|
+
...filePath.split("/").slice(0, 2),
|
|
12
|
+
nesting,
|
|
13
|
+
...filePath.split("/").slice(2)
|
|
14
|
+
].join("/");
|
|
15
|
+
};
|
|
16
|
+
const documentationRead = async (data, { options, helpers }) => {
|
|
17
|
+
if (data.kind === "PageSnippet") {
|
|
18
|
+
const { model } = data.data;
|
|
19
|
+
const pageDataExtension = await getJSFileExtension.getJSFileExtension({ helpers, options });
|
|
20
|
+
const routePath = `src/routes/${model.repeatable ? "[uid]" : model.id}`;
|
|
21
|
+
const dataFilePath = `${routePath}/+page.server.${pageDataExtension}`;
|
|
22
|
+
const componentFilePath = `${routePath}/+page.svelte`;
|
|
23
|
+
let dataFileContent;
|
|
24
|
+
if (model.repeatable) {
|
|
25
|
+
dataFileContent = commonTags.source`
|
|
26
|
+
import { createClient } from "$lib/prismicio";
|
|
27
|
+
|
|
28
|
+
export const prerender = true;
|
|
29
|
+
|
|
30
|
+
export async function load({ params, fetch }) {
|
|
31
|
+
const client = createClient({ fetch });
|
|
32
|
+
|
|
33
|
+
const page = await client.getByUID("${model.id}", params.uid);
|
|
34
|
+
|
|
35
|
+
return {
|
|
36
|
+
page,
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export async function entries() {
|
|
41
|
+
const client = createClient();
|
|
42
|
+
|
|
43
|
+
const pages = await client.getAllByType("${model.id}");
|
|
44
|
+
|
|
45
|
+
return pages.map((page) => {
|
|
46
|
+
return { uid: page.uid };
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
`;
|
|
50
|
+
} else {
|
|
51
|
+
dataFileContent = commonTags.source`
|
|
52
|
+
import { createClient } from "$lib/prismicio";
|
|
53
|
+
|
|
54
|
+
export const prerender = true;
|
|
55
|
+
|
|
56
|
+
export async function load({ params, fetch }) {
|
|
57
|
+
const client = createClient({ fetch });
|
|
58
|
+
|
|
59
|
+
const page = await client.getSingle("${model.id}");
|
|
60
|
+
|
|
61
|
+
return {
|
|
62
|
+
page,
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
`;
|
|
66
|
+
}
|
|
67
|
+
let componentFileContent = commonTags.source(_a || (_a = __template(['\n <script>\n import { SliceZone } from "@prismicio/svelte";\n\n import { components } from "$lib/slices";\n\n export let data;\n <\/script>\n\n <SliceZone slices={data.page.data.slices} {components} />\n '])));
|
|
68
|
+
if (options.format) {
|
|
69
|
+
dataFileContent = await helpers.format(dataFileContent, helpers.joinPathFromRoot(dataFilePath), {
|
|
70
|
+
includeNewlineAtEnd: false
|
|
71
|
+
});
|
|
72
|
+
componentFileContent = await helpers.format(componentFileContent, helpers.joinPathFromRoot(componentFilePath), {
|
|
73
|
+
prettier: {
|
|
74
|
+
plugins: ["prettier-plugin-svelte"],
|
|
75
|
+
parser: "svelte"
|
|
76
|
+
},
|
|
77
|
+
includeNewlineAtEnd: false
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
const nestedDataFilePath = nestRouteFilePath(dataFilePath, "marketing");
|
|
81
|
+
const nestedComponentFilePath = nestRouteFilePath(componentFilePath, "marketing");
|
|
82
|
+
return [
|
|
83
|
+
{
|
|
84
|
+
label: "Default",
|
|
85
|
+
content: commonTags.source`
|
|
86
|
+
## Create your ${model.label}'s page data fetcher
|
|
87
|
+
|
|
88
|
+
Add a new route by creating a \`${dataFilePath}\` file. (If the route should be nested in a child directory, you can create the file in a directory, like \`${nestedDataFilePath}\`.)
|
|
89
|
+
|
|
90
|
+
Paste in this code:
|
|
91
|
+
|
|
92
|
+
${`~~~${pageDataExtension} [${dataFilePath}]
|
|
93
|
+
${dataFileContent}
|
|
94
|
+
~~~`}
|
|
95
|
+
|
|
96
|
+
## Create your ${model.label}'s page component
|
|
97
|
+
|
|
98
|
+
In the route's directory, create a \`${componentFilePath}\` file. (If the route should be nested in a child directory, you can create the file in a directory, like \`${nestedComponentFilePath}\`.)
|
|
99
|
+
|
|
100
|
+
Paste in this code:
|
|
101
|
+
|
|
102
|
+
${`~~~svelte [${componentFilePath}]
|
|
103
|
+
${componentFileContent}
|
|
104
|
+
~~~`}
|
|
105
|
+
|
|
106
|
+
Make sure all of your import paths are correct. See the [install guide](https://prismic.io/docs/svelte-install) for more information.
|
|
107
|
+
`
|
|
108
|
+
}
|
|
109
|
+
];
|
|
110
|
+
}
|
|
111
|
+
return [];
|
|
112
|
+
};
|
|
113
|
+
exports.documentationRead = documentationRead;
|
|
114
|
+
//# sourceMappingURL=documentation-read.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"documentation-read.cjs","sources":["../../../src/hooks/documentation-read.ts"],"sourcesContent":["import { source } from \"common-tags\";\n\nimport type { DocumentationReadHook } from \"@slicemachine/plugin-kit\";\n\nimport { getJSFileExtension } from \"../lib/getJSFileExtension\";\n\nimport type { PluginOptions } from \"../types\";\n\nconst nestRouteFilePath = (filePath: string, nesting: string): string => {\n\treturn [\n\t\t...filePath.split(\"/\").slice(0, 2),\n\t\tnesting,\n\t\t...filePath.split(\"/\").slice(2),\n\t].join(\"/\");\n};\n\nexport const documentationRead: DocumentationReadHook<PluginOptions> = async (\n\tdata,\n\t{ options, helpers },\n) => {\n\tif (data.kind === \"PageSnippet\") {\n\t\tconst { model } = data.data;\n\n\t\tconst pageDataExtension = await getJSFileExtension({ helpers, options });\n\n\t\tconst routePath = `src/routes/${model.repeatable ? \"[uid]\" : model.id}`;\n\t\tconst dataFilePath = `${routePath}/+page.server.${pageDataExtension}`;\n\t\tconst componentFilePath = `${routePath}/+page.svelte`;\n\n\t\tlet dataFileContent: string;\n\t\tif (model.repeatable) {\n\t\t\tdataFileContent = source`\n\t\t\t\timport { createClient } from \"$lib/prismicio\";\n\n\t\t\t\texport const prerender = true;\n\n\t\t\t\texport async function load({ params, fetch }) {\n\t\t\t\t\tconst client = createClient({ fetch });\n\n\t\t\t\t\tconst page = await client.getByUID(\"${model.id}\", params.uid);\n\n\t\t\t\t\treturn {\n\t\t\t\t\t\tpage,\n\t\t\t\t\t};\n\t\t\t\t}\n\n\t\t\t\texport async function entries() {\n\t\t\t\t\tconst client = createClient();\n\n\t\t\t\t\tconst pages = await client.getAllByType(\"${model.id}\");\n\n\t\t\t\t\treturn pages.map((page) => {\n\t\t\t\t\t\treturn { uid: page.uid };\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t`;\n\t\t} else {\n\t\t\tdataFileContent = source`\n\t\t\t\timport { createClient } from \"$lib/prismicio\";\n\n\t\t\t\texport const prerender = true;\n\n\t\t\t\texport async function load({ params, fetch }) {\n\t\t\t\t\tconst client = createClient({ fetch });\n\n\t\t\t\t\tconst page = await client.getSingle(\"${model.id}\");\n\n\t\t\t\t\treturn {\n\t\t\t\t\t\tpage,\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t`;\n\t\t}\n\n\t\tlet componentFileContent = source`\n\t\t\t<script>\n\t\t\t\timport { SliceZone } from \"@prismicio/svelte\";\n\n\t\t\t\timport { components } from \"$lib/slices\";\n\n\t\t\t\texport let data;\n\t\t\t</script>\n\n\t\t\t<SliceZone slices={data.page.data.slices} {components} />\n\t\t`;\n\n\t\tif (options.format) {\n\t\t\tdataFileContent = await helpers.format(\n\t\t\t\tdataFileContent,\n\t\t\t\thelpers.joinPathFromRoot(dataFilePath),\n\t\t\t\t{\n\t\t\t\t\tincludeNewlineAtEnd: false,\n\t\t\t\t},\n\t\t\t);\n\t\t\tcomponentFileContent = await helpers.format(\n\t\t\t\tcomponentFileContent,\n\t\t\t\thelpers.joinPathFromRoot(componentFilePath),\n\t\t\t\t{\n\t\t\t\t\tprettier: {\n\t\t\t\t\t\tplugins: [\"prettier-plugin-svelte\"],\n\t\t\t\t\t\tparser: \"svelte\",\n\t\t\t\t\t},\n\t\t\t\t\tincludeNewlineAtEnd: false,\n\t\t\t\t},\n\t\t\t);\n\t\t}\n\n\t\tconst nestedDataFilePath = nestRouteFilePath(dataFilePath, \"marketing\");\n\t\tconst nestedComponentFilePath = nestRouteFilePath(\n\t\t\tcomponentFilePath,\n\t\t\t\"marketing\",\n\t\t);\n\n\t\treturn [\n\t\t\t{\n\t\t\t\tlabel: \"Default\",\n\t\t\t\tcontent: source`\n\t\t\t\t\t## Create your ${model.label}'s page data fetcher\n\n\t\t\t\t\tAdd a new route by creating a \\`${dataFilePath}\\` file. (If the route should be nested in a child directory, you can create the file in a directory, like \\`${nestedDataFilePath}\\`.)\n\n\t\t\t\t\tPaste in this code:\n\n\t\t\t\t\t${`~~~${pageDataExtension} [${dataFilePath}]\\n${dataFileContent}\\n~~~`}\n\n\t\t\t\t\t## Create your ${model.label}'s page component\n\n\t\t\t\t\tIn the route's directory, create a \\`${componentFilePath}\\` file. (If the route should be nested in a child directory, you can create the file in a directory, like \\`${nestedComponentFilePath}\\`.)\n\n\t\t\t\t\tPaste in this code:\n\n\t\t\t\t\t${`~~~svelte [${componentFilePath}]\\n${componentFileContent}\\n~~~`}\n\n\t\t\t\t\tMake sure all of your import paths are correct. See the [install guide](https://prismic.io/docs/svelte-install) for more information.\n\t\t\t\t`,\n\t\t\t},\n\t\t];\n\t}\n\n\treturn [];\n};\n"],"names":["getJSFileExtension","source"],"mappings":";;;;;;;AAAA,IAAA;AAQA,MAAM,oBAAoB,CAAC,UAAkB,YAA2B;AAChE,SAAA;AAAA,IACN,GAAG,SAAS,MAAM,GAAG,EAAE,MAAM,GAAG,CAAC;AAAA,IACjC;AAAA,IACA,GAAG,SAAS,MAAM,GAAG,EAAE,MAAM,CAAC;AAAA,EAAA,EAC7B,KAAK,GAAG;AACX;AAEO,MAAM,oBAA0D,OACtE,MACA,EAAE,SAAS,cACR;AACC,MAAA,KAAK,SAAS,eAAe;AAC1B,UAAA,EAAE,MAAK,IAAK,KAAK;AAEvB,UAAM,oBAAoB,MAAMA,mBAAA,mBAAmB,EAAE,SAAS,QAAS,CAAA;AAEvE,UAAM,YAAY,cAAc,MAAM,aAAa,UAAU,MAAM;AAC7D,UAAA,eAAe,GAAG,0BAA0B;AAClD,UAAM,oBAAoB,GAAG;AAEzB,QAAA;AACJ,QAAI,MAAM,YAAY;AACH,wBAAAC,WAAAA;AAAAA;AAAAA;AAAAA;AAAAA;AAAAA;AAAAA;AAAAA;AAAAA,2CAQsB,MAAM;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,gDAUD,MAAM;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAAA,OAO7C;AACY,wBAAAA,WAAAA;AAAAA;AAAAA;AAAAA;AAAAA;AAAAA;AAAAA;AAAAA;AAAAA,4CAQuB,MAAM;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAO/C;AAED,QAAI,uBAAuBA,WAAM,OAAA,OAAA,KAAA,WAAA,CAAA,+NAAA,CAAA,EAAA;AAYjC,QAAI,QAAQ,QAAQ;AACnB,wBAAkB,MAAM,QAAQ,OAC/B,iBACA,QAAQ,iBAAiB,YAAY,GACrC;AAAA,QACC,qBAAqB;AAAA,MAAA,CACrB;AAEF,6BAAuB,MAAM,QAAQ,OACpC,sBACA,QAAQ,iBAAiB,iBAAiB,GAC1C;AAAA,QACC,UAAU;AAAA,UACT,SAAS,CAAC,wBAAwB;AAAA,UAClC,QAAQ;AAAA,QACR;AAAA,QACD,qBAAqB;AAAA,MAAA,CACrB;AAAA,IAEF;AAEK,UAAA,qBAAqB,kBAAkB,cAAc,WAAW;AAChE,UAAA,0BAA0B,kBAC/B,mBACA,WAAW;AAGL,WAAA;AAAA,MACN;AAAA,QACC,OAAO;AAAA,QACP,SAASA,WAAAA;AAAAA,sBACS,MAAM;AAAA;AAAA,uCAEW,4HAA4H;AAAA;AAAA;AAAA;AAAA,OAI5J,MAAM,sBAAsB;AAAA,EAAkB;AAAA;AAAA;AAAA,sBAE/B,MAAM;AAAA;AAAA,4CAEgB,iIAAiI;AAAA;AAAA;AAAA;AAAA,OAItK,cAAc;AAAA,EAAuB;AAAA;AAAA;AAAA;AAAA;AAAA,MAIxC;AAAA,IAAA;AAAA,EAEF;AAED,SAAO;AACR;;"}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import { source } from "common-tags";
|
|
2
|
+
import { getJSFileExtension } from "../lib/getJSFileExtension.js";
|
|
3
|
+
var __freeze = Object.freeze;
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __template = (cooked, raw) => __freeze(__defProp(cooked, "raw", { value: __freeze(raw || cooked.slice()) }));
|
|
6
|
+
var _a;
|
|
7
|
+
const nestRouteFilePath = (filePath, nesting) => {
|
|
8
|
+
return [
|
|
9
|
+
...filePath.split("/").slice(0, 2),
|
|
10
|
+
nesting,
|
|
11
|
+
...filePath.split("/").slice(2)
|
|
12
|
+
].join("/");
|
|
13
|
+
};
|
|
14
|
+
const documentationRead = async (data, { options, helpers }) => {
|
|
15
|
+
if (data.kind === "PageSnippet") {
|
|
16
|
+
const { model } = data.data;
|
|
17
|
+
const pageDataExtension = await getJSFileExtension({ helpers, options });
|
|
18
|
+
const routePath = `src/routes/${model.repeatable ? "[uid]" : model.id}`;
|
|
19
|
+
const dataFilePath = `${routePath}/+page.server.${pageDataExtension}`;
|
|
20
|
+
const componentFilePath = `${routePath}/+page.svelte`;
|
|
21
|
+
let dataFileContent;
|
|
22
|
+
if (model.repeatable) {
|
|
23
|
+
dataFileContent = source`
|
|
24
|
+
import { createClient } from "$lib/prismicio";
|
|
25
|
+
|
|
26
|
+
export const prerender = true;
|
|
27
|
+
|
|
28
|
+
export async function load({ params, fetch }) {
|
|
29
|
+
const client = createClient({ fetch });
|
|
30
|
+
|
|
31
|
+
const page = await client.getByUID("${model.id}", params.uid);
|
|
32
|
+
|
|
33
|
+
return {
|
|
34
|
+
page,
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export async function entries() {
|
|
39
|
+
const client = createClient();
|
|
40
|
+
|
|
41
|
+
const pages = await client.getAllByType("${model.id}");
|
|
42
|
+
|
|
43
|
+
return pages.map((page) => {
|
|
44
|
+
return { uid: page.uid };
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
`;
|
|
48
|
+
} else {
|
|
49
|
+
dataFileContent = source`
|
|
50
|
+
import { createClient } from "$lib/prismicio";
|
|
51
|
+
|
|
52
|
+
export const prerender = true;
|
|
53
|
+
|
|
54
|
+
export async function load({ params, fetch }) {
|
|
55
|
+
const client = createClient({ fetch });
|
|
56
|
+
|
|
57
|
+
const page = await client.getSingle("${model.id}");
|
|
58
|
+
|
|
59
|
+
return {
|
|
60
|
+
page,
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
`;
|
|
64
|
+
}
|
|
65
|
+
let componentFileContent = source(_a || (_a = __template(['\n <script>\n import { SliceZone } from "@prismicio/svelte";\n\n import { components } from "$lib/slices";\n\n export let data;\n <\/script>\n\n <SliceZone slices={data.page.data.slices} {components} />\n '])));
|
|
66
|
+
if (options.format) {
|
|
67
|
+
dataFileContent = await helpers.format(dataFileContent, helpers.joinPathFromRoot(dataFilePath), {
|
|
68
|
+
includeNewlineAtEnd: false
|
|
69
|
+
});
|
|
70
|
+
componentFileContent = await helpers.format(componentFileContent, helpers.joinPathFromRoot(componentFilePath), {
|
|
71
|
+
prettier: {
|
|
72
|
+
plugins: ["prettier-plugin-svelte"],
|
|
73
|
+
parser: "svelte"
|
|
74
|
+
},
|
|
75
|
+
includeNewlineAtEnd: false
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
const nestedDataFilePath = nestRouteFilePath(dataFilePath, "marketing");
|
|
79
|
+
const nestedComponentFilePath = nestRouteFilePath(componentFilePath, "marketing");
|
|
80
|
+
return [
|
|
81
|
+
{
|
|
82
|
+
label: "Default",
|
|
83
|
+
content: source`
|
|
84
|
+
## Create your ${model.label}'s page data fetcher
|
|
85
|
+
|
|
86
|
+
Add a new route by creating a \`${dataFilePath}\` file. (If the route should be nested in a child directory, you can create the file in a directory, like \`${nestedDataFilePath}\`.)
|
|
87
|
+
|
|
88
|
+
Paste in this code:
|
|
89
|
+
|
|
90
|
+
${`~~~${pageDataExtension} [${dataFilePath}]
|
|
91
|
+
${dataFileContent}
|
|
92
|
+
~~~`}
|
|
93
|
+
|
|
94
|
+
## Create your ${model.label}'s page component
|
|
95
|
+
|
|
96
|
+
In the route's directory, create a \`${componentFilePath}\` file. (If the route should be nested in a child directory, you can create the file in a directory, like \`${nestedComponentFilePath}\`.)
|
|
97
|
+
|
|
98
|
+
Paste in this code:
|
|
99
|
+
|
|
100
|
+
${`~~~svelte [${componentFilePath}]
|
|
101
|
+
${componentFileContent}
|
|
102
|
+
~~~`}
|
|
103
|
+
|
|
104
|
+
Make sure all of your import paths are correct. See the [install guide](https://prismic.io/docs/svelte-install) for more information.
|
|
105
|
+
`
|
|
106
|
+
}
|
|
107
|
+
];
|
|
108
|
+
}
|
|
109
|
+
return [];
|
|
110
|
+
};
|
|
111
|
+
export {
|
|
112
|
+
documentationRead
|
|
113
|
+
};
|
|
114
|
+
//# sourceMappingURL=documentation-read.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"documentation-read.js","sources":["../../../src/hooks/documentation-read.ts"],"sourcesContent":["import { source } from \"common-tags\";\n\nimport type { DocumentationReadHook } from \"@slicemachine/plugin-kit\";\n\nimport { getJSFileExtension } from \"../lib/getJSFileExtension\";\n\nimport type { PluginOptions } from \"../types\";\n\nconst nestRouteFilePath = (filePath: string, nesting: string): string => {\n\treturn [\n\t\t...filePath.split(\"/\").slice(0, 2),\n\t\tnesting,\n\t\t...filePath.split(\"/\").slice(2),\n\t].join(\"/\");\n};\n\nexport const documentationRead: DocumentationReadHook<PluginOptions> = async (\n\tdata,\n\t{ options, helpers },\n) => {\n\tif (data.kind === \"PageSnippet\") {\n\t\tconst { model } = data.data;\n\n\t\tconst pageDataExtension = await getJSFileExtension({ helpers, options });\n\n\t\tconst routePath = `src/routes/${model.repeatable ? \"[uid]\" : model.id}`;\n\t\tconst dataFilePath = `${routePath}/+page.server.${pageDataExtension}`;\n\t\tconst componentFilePath = `${routePath}/+page.svelte`;\n\n\t\tlet dataFileContent: string;\n\t\tif (model.repeatable) {\n\t\t\tdataFileContent = source`\n\t\t\t\timport { createClient } from \"$lib/prismicio\";\n\n\t\t\t\texport const prerender = true;\n\n\t\t\t\texport async function load({ params, fetch }) {\n\t\t\t\t\tconst client = createClient({ fetch });\n\n\t\t\t\t\tconst page = await client.getByUID(\"${model.id}\", params.uid);\n\n\t\t\t\t\treturn {\n\t\t\t\t\t\tpage,\n\t\t\t\t\t};\n\t\t\t\t}\n\n\t\t\t\texport async function entries() {\n\t\t\t\t\tconst client = createClient();\n\n\t\t\t\t\tconst pages = await client.getAllByType(\"${model.id}\");\n\n\t\t\t\t\treturn pages.map((page) => {\n\t\t\t\t\t\treturn { uid: page.uid };\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t`;\n\t\t} else {\n\t\t\tdataFileContent = source`\n\t\t\t\timport { createClient } from \"$lib/prismicio\";\n\n\t\t\t\texport const prerender = true;\n\n\t\t\t\texport async function load({ params, fetch }) {\n\t\t\t\t\tconst client = createClient({ fetch });\n\n\t\t\t\t\tconst page = await client.getSingle(\"${model.id}\");\n\n\t\t\t\t\treturn {\n\t\t\t\t\t\tpage,\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t`;\n\t\t}\n\n\t\tlet componentFileContent = source`\n\t\t\t<script>\n\t\t\t\timport { SliceZone } from \"@prismicio/svelte\";\n\n\t\t\t\timport { components } from \"$lib/slices\";\n\n\t\t\t\texport let data;\n\t\t\t</script>\n\n\t\t\t<SliceZone slices={data.page.data.slices} {components} />\n\t\t`;\n\n\t\tif (options.format) {\n\t\t\tdataFileContent = await helpers.format(\n\t\t\t\tdataFileContent,\n\t\t\t\thelpers.joinPathFromRoot(dataFilePath),\n\t\t\t\t{\n\t\t\t\t\tincludeNewlineAtEnd: false,\n\t\t\t\t},\n\t\t\t);\n\t\t\tcomponentFileContent = await helpers.format(\n\t\t\t\tcomponentFileContent,\n\t\t\t\thelpers.joinPathFromRoot(componentFilePath),\n\t\t\t\t{\n\t\t\t\t\tprettier: {\n\t\t\t\t\t\tplugins: [\"prettier-plugin-svelte\"],\n\t\t\t\t\t\tparser: \"svelte\",\n\t\t\t\t\t},\n\t\t\t\t\tincludeNewlineAtEnd: false,\n\t\t\t\t},\n\t\t\t);\n\t\t}\n\n\t\tconst nestedDataFilePath = nestRouteFilePath(dataFilePath, \"marketing\");\n\t\tconst nestedComponentFilePath = nestRouteFilePath(\n\t\t\tcomponentFilePath,\n\t\t\t\"marketing\",\n\t\t);\n\n\t\treturn [\n\t\t\t{\n\t\t\t\tlabel: \"Default\",\n\t\t\t\tcontent: source`\n\t\t\t\t\t## Create your ${model.label}'s page data fetcher\n\n\t\t\t\t\tAdd a new route by creating a \\`${dataFilePath}\\` file. (If the route should be nested in a child directory, you can create the file in a directory, like \\`${nestedDataFilePath}\\`.)\n\n\t\t\t\t\tPaste in this code:\n\n\t\t\t\t\t${`~~~${pageDataExtension} [${dataFilePath}]\\n${dataFileContent}\\n~~~`}\n\n\t\t\t\t\t## Create your ${model.label}'s page component\n\n\t\t\t\t\tIn the route's directory, create a \\`${componentFilePath}\\` file. (If the route should be nested in a child directory, you can create the file in a directory, like \\`${nestedComponentFilePath}\\`.)\n\n\t\t\t\t\tPaste in this code:\n\n\t\t\t\t\t${`~~~svelte [${componentFilePath}]\\n${componentFileContent}\\n~~~`}\n\n\t\t\t\t\tMake sure all of your import paths are correct. See the [install guide](https://prismic.io/docs/svelte-install) for more information.\n\t\t\t\t`,\n\t\t\t},\n\t\t];\n\t}\n\n\treturn [];\n};\n"],"names":[],"mappings":";;;;;AAAA,IAAA;AAQA,MAAM,oBAAoB,CAAC,UAAkB,YAA2B;AAChE,SAAA;AAAA,IACN,GAAG,SAAS,MAAM,GAAG,EAAE,MAAM,GAAG,CAAC;AAAA,IACjC;AAAA,IACA,GAAG,SAAS,MAAM,GAAG,EAAE,MAAM,CAAC;AAAA,EAAA,EAC7B,KAAK,GAAG;AACX;AAEO,MAAM,oBAA0D,OACtE,MACA,EAAE,SAAS,cACR;AACC,MAAA,KAAK,SAAS,eAAe;AAC1B,UAAA,EAAE,MAAK,IAAK,KAAK;AAEvB,UAAM,oBAAoB,MAAM,mBAAmB,EAAE,SAAS,QAAS,CAAA;AAEvE,UAAM,YAAY,cAAc,MAAM,aAAa,UAAU,MAAM;AAC7D,UAAA,eAAe,GAAG,0BAA0B;AAClD,UAAM,oBAAoB,GAAG;AAEzB,QAAA;AACJ,QAAI,MAAM,YAAY;AACH,wBAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,2CAQsB,MAAM;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,gDAUD,MAAM;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAAA,OAO7C;AACY,wBAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,4CAQuB,MAAM;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAO/C;AAED,QAAI,uBAAuB,OAAM,OAAA,KAAA,WAAA,CAAA,+NAAA,CAAA,EAAA;AAYjC,QAAI,QAAQ,QAAQ;AACnB,wBAAkB,MAAM,QAAQ,OAC/B,iBACA,QAAQ,iBAAiB,YAAY,GACrC;AAAA,QACC,qBAAqB;AAAA,MAAA,CACrB;AAEF,6BAAuB,MAAM,QAAQ,OACpC,sBACA,QAAQ,iBAAiB,iBAAiB,GAC1C;AAAA,QACC,UAAU;AAAA,UACT,SAAS,CAAC,wBAAwB;AAAA,UAClC,QAAQ;AAAA,QACR;AAAA,QACD,qBAAqB;AAAA,MAAA,CACrB;AAAA,IAEF;AAEK,UAAA,qBAAqB,kBAAkB,cAAc,WAAW;AAChE,UAAA,0BAA0B,kBAC/B,mBACA,WAAW;AAGL,WAAA;AAAA,MACN;AAAA,QACC,OAAO;AAAA,QACP,SAAS;AAAA,sBACS,MAAM;AAAA;AAAA,uCAEW,4HAA4H;AAAA;AAAA;AAAA;AAAA,OAI5J,MAAM,sBAAsB;AAAA,EAAkB;AAAA;AAAA;AAAA,sBAE/B,MAAM;AAAA;AAAA,4CAEgB,iIAAiI;AAAA;AAAA;AAAA;AAAA,OAItK,cAAc;AAAA,EAAuB;AAAA;AAAA;AAAA;AAAA;AAAA,MAIxC;AAAA,IAAA;AAAA,EAEF;AAED,SAAO;AACR;"}
|
package/dist/plugin.cjs
CHANGED
|
@@ -7,6 +7,7 @@ const fs = require("@slicemachine/plugin-kit/fs");
|
|
|
7
7
|
const rejectIfNecessary = require("./lib/rejectIfNecessary.cjs");
|
|
8
8
|
const upsertSliceLibraryIndexFile = require("./lib/upsertSliceLibraryIndexFile.cjs");
|
|
9
9
|
const _package = require("./packages/adapter-sveltekit/package.json.cjs");
|
|
10
|
+
const documentationRead = require("./hooks/documentation-read.cjs");
|
|
10
11
|
const projectInit = require("./hooks/project-init.cjs");
|
|
11
12
|
const sliceCreate = require("./hooks/slice-create.cjs");
|
|
12
13
|
const sliceSimulatorSetupRead = require("./hooks/sliceSimulator-setup-read.cjs");
|
|
@@ -209,9 +210,7 @@ const plugin = pluginKit.defineSliceMachinePlugin({
|
|
|
209
210
|
});
|
|
210
211
|
});
|
|
211
212
|
hook("snippet:read", snippetRead.snippetRead);
|
|
212
|
-
hook("documentation:read",
|
|
213
|
-
return [];
|
|
214
|
-
});
|
|
213
|
+
hook("documentation:read", documentationRead.documentationRead);
|
|
215
214
|
hook("slice-simulator:setup:read", sliceSimulatorSetupRead.sliceSimulatorSetupRead);
|
|
216
215
|
}
|
|
217
216
|
});
|
package/dist/plugin.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.cjs","sources":["../../src/plugin.ts"],"sourcesContent":["import path from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\n\nimport { defineSliceMachinePlugin } from \"@slicemachine/plugin-kit\";\nimport {\n\tdeleteCustomTypeDirectory,\n\tdeleteCustomTypeFile,\n\tdeleteSliceDirectory,\n\tdeleteSliceFile,\n\treadCustomTypeFile,\n\treadCustomTypeLibrary,\n\treadCustomTypeModel,\n\treadSliceFile,\n\treadSliceLibrary,\n\treadSliceModel,\n\treadSliceTemplateLibrary,\n\trenameSlice,\n\tupsertGlobalTypeScriptTypes,\n\twriteCustomTypeFile,\n\twriteCustomTypeModel,\n\twriteSliceFile,\n\twriteSliceModel,\n} from \"@slicemachine/plugin-kit/fs\";\n\nimport { rejectIfNecessary } from \"./lib/rejectIfNecessary\";\nimport { upsertSliceLibraryIndexFile } from \"./lib/upsertSliceLibraryIndexFile\";\n\nimport { name as pkgName } from \"../package.json\";\nimport { PluginOptions } from \"./types\";\n\nimport { projectInit } from \"./hooks/project-init\";\nimport { sliceCreate } from \"./hooks/slice-create\";\nimport { sliceSimulatorSetupRead } from \"./hooks/sliceSimulator-setup-read\";\nimport { snippetRead } from \"./hooks/snippet-read\";\n\nimport * as Hero from \"./sliceTemplates/Hero\";\n\nexport const plugin = defineSliceMachinePlugin<PluginOptions>({\n\tmeta: {\n\t\tname: pkgName,\n\t},\n\tdefaultOptions: {\n\t\tformat: true,\n\t\tgeneratedTypesFilePath: \"./src/prismicio-types.d.ts\",\n\t},\n\tsetup({ hook }) {\n\t\t////////////////////////////////////////////////////////////////\n\t\t// project:*\n\t\t////////////////////////////////////////////////////////////////\n\n\t\thook(\"project:init\", projectInit);\n\n\t\t////////////////////////////////////////////////////////////////\n\t\t// slice:*\n\t\t////////////////////////////////////////////////////////////////\n\n\t\thook(\"slice:create\", sliceCreate);\n\t\thook(\"slice:update\", async (data, context) => {\n\t\t\tawait writeSliceModel({\n\t\t\t\tlibraryID: data.libraryID,\n\t\t\t\tmodel: data.model,\n\t\t\t\t...context,\n\t\t\t});\n\n\t\t\tawait upsertGlobalTypeScriptTypes({\n\t\t\t\tfilename: context.options.generatedTypesFilePath,\n\t\t\t\tformat: context.options.format,\n\t\t\t\t...context,\n\t\t\t});\n\t\t});\n\t\thook(\"slice:rename\", async (data, context) => {\n\t\t\tawait renameSlice({\n\t\t\t\tlibraryID: data.libraryID,\n\t\t\t\tmodel: data.model,\n\t\t\t\tformat: context.options.format,\n\t\t\t\t...context,\n\t\t\t});\n\n\t\t\trejectIfNecessary(\n\t\t\t\tawait Promise.allSettled([\n\t\t\t\t\tupsertSliceLibraryIndexFile({\n\t\t\t\t\t\tlibraryID: data.libraryID,\n\t\t\t\t\t\t...context,\n\t\t\t\t\t}),\n\t\t\t\t\tupsertGlobalTypeScriptTypes({\n\t\t\t\t\t\tfilename: context.options.generatedTypesFilePath,\n\t\t\t\t\t\tformat: context.options.format,\n\t\t\t\t\t\t...context,\n\t\t\t\t\t}),\n\t\t\t\t]),\n\t\t\t);\n\t\t});\n\t\thook(\"slice:delete\", async (data, context) => {\n\t\t\tawait deleteSliceDirectory({\n\t\t\t\tlibraryID: data.libraryID,\n\t\t\t\tmodel: data.model,\n\t\t\t\t...context,\n\t\t\t});\n\n\t\t\trejectIfNecessary(\n\t\t\t\tawait Promise.allSettled([\n\t\t\t\t\tupsertSliceLibraryIndexFile({\n\t\t\t\t\t\tlibraryID: data.libraryID,\n\t\t\t\t\t\t...context,\n\t\t\t\t\t}),\n\t\t\t\t\tupsertGlobalTypeScriptTypes({\n\t\t\t\t\t\tfilename: context.options.generatedTypesFilePath,\n\t\t\t\t\t\tformat: context.options.format,\n\t\t\t\t\t\t...context,\n\t\t\t\t\t}),\n\t\t\t\t]),\n\t\t\t);\n\t\t});\n\t\thook(\"slice:read\", async (data, context) => {\n\t\t\treturn await readSliceModel({\n\t\t\t\tlibraryID: data.libraryID,\n\t\t\t\tsliceID: data.sliceID,\n\t\t\t\t...context,\n\t\t\t});\n\t\t});\n\t\thook(\"slice:asset:update\", async (data, context) => {\n\t\t\tawait writeSliceFile({\n\t\t\t\tlibraryID: data.libraryID,\n\t\t\t\tsliceID: data.sliceID,\n\t\t\t\tfilename: data.asset.id,\n\t\t\t\tcontents: data.asset.data,\n\t\t\t\t...context,\n\t\t\t});\n\t\t});\n\t\thook(\"slice:asset:delete\", async (data, context) => {\n\t\t\tawait deleteSliceFile({\n\t\t\t\tlibraryID: data.libraryID,\n\t\t\t\tsliceID: data.sliceID,\n\t\t\t\tfilename: data.assetID,\n\t\t\t\t...context,\n\t\t\t});\n\t\t});\n\t\thook(\"slice:asset:read\", async (data, context) => {\n\t\t\tconst file = await readSliceFile({\n\t\t\t\tlibraryID: data.libraryID,\n\t\t\t\tsliceID: data.sliceID,\n\t\t\t\tfilename: data.assetID,\n\t\t\t\t...context,\n\t\t\t});\n\n\t\t\treturn {\n\t\t\t\tdata: file,\n\t\t\t};\n\t\t});\n\n\t\t////////////////////////////////////////////////////////////////\n\t\t// slice-library:*\n\t\t////////////////////////////////////////////////////////////////\n\n\t\thook(\"slice-library:read\", async (data, context) => {\n\t\t\treturn await readSliceLibrary({\n\t\t\t\tlibraryID: data.libraryID,\n\t\t\t\t...context,\n\t\t\t});\n\t\t});\n\n\t\t////////////////////////////////////////////////////////////////\n\t\t// slice-template-library:*\n\t\t////////////////////////////////////////////////////////////////\n\n\t\thook(\"slice-template-library:read\", async (data, context) => {\n\t\t\treturn await readSliceTemplateLibrary({\n\t\t\t\t...data,\n\t\t\t\t...context,\n\t\t\t\tdirName: path.dirname(fileURLToPath(new URL(import.meta.url))),\n\t\t\t\ttemplates: [Hero],\n\t\t\t\tcomponentFileNames: {\n\t\t\t\t\tjs: \"javascript.svelte\",\n\t\t\t\t\tts: \"typescript.svelte\",\n\t\t\t\t},\n\t\t\t});\n\t\t});\n\n\t\t////////////////////////////////////////////////////////////////\n\t\t// custom-type:*\n\t\t////////////////////////////////////////////////////////////////\n\n\t\thook(\"custom-type:create\", async (data, context) => {\n\t\t\tawait writeCustomTypeModel({\n\t\t\t\tmodel: data.model,\n\t\t\t\tformat: context.options.format,\n\t\t\t\t...context,\n\t\t\t});\n\n\t\t\tawait upsertGlobalTypeScriptTypes({\n\t\t\t\tfilename: context.options.generatedTypesFilePath,\n\t\t\t\tformat: context.options.format,\n\t\t\t\t...context,\n\t\t\t});\n\t\t});\n\t\thook(\"custom-type:update\", async (data, context) => {\n\t\t\tawait writeCustomTypeModel({\n\t\t\t\tmodel: data.model,\n\t\t\t\tformat: context.options.format,\n\t\t\t\t...context,\n\t\t\t});\n\n\t\t\tawait upsertGlobalTypeScriptTypes({\n\t\t\t\tfilename: context.options.generatedTypesFilePath,\n\t\t\t\tformat: context.options.format,\n\t\t\t\t...context,\n\t\t\t});\n\t\t});\n\t\thook(\"custom-type:rename\", async (data, context) => {\n\t\t\tawait writeCustomTypeModel({\n\t\t\t\tmodel: data.model,\n\t\t\t\tformat: context.options.format,\n\t\t\t\t...context,\n\t\t\t});\n\n\t\t\tawait upsertGlobalTypeScriptTypes({\n\t\t\t\tfilename: context.options.generatedTypesFilePath,\n\t\t\t\tformat: context.options.format,\n\t\t\t\t...context,\n\t\t\t});\n\t\t});\n\t\thook(\"custom-type:delete\", async (data, context) => {\n\t\t\tawait deleteCustomTypeDirectory({\n\t\t\t\tcustomTypeID: data.model.id,\n\t\t\t\t...context,\n\t\t\t});\n\n\t\t\tawait upsertGlobalTypeScriptTypes({\n\t\t\t\tfilename: context.options.generatedTypesFilePath,\n\t\t\t\tformat: context.options.format,\n\t\t\t\t...context,\n\t\t\t});\n\t\t});\n\t\thook(\"custom-type:read\", async (data, context) => {\n\t\t\treturn await readCustomTypeModel({\n\t\t\t\tcustomTypeID: data.id,\n\t\t\t\t...context,\n\t\t\t});\n\t\t});\n\t\thook(\"custom-type:asset:update\", async (data, context) => {\n\t\t\tawait writeCustomTypeFile({\n\t\t\t\tcustomTypeID: data.customTypeID,\n\t\t\t\tfilename: data.asset.id,\n\t\t\t\tcontents: data.asset.data,\n\t\t\t\t...context,\n\t\t\t});\n\t\t});\n\t\thook(\"custom-type:asset:delete\", async (data, context) => {\n\t\t\tawait deleteCustomTypeFile({\n\t\t\t\tcustomTypeID: data.customTypeID,\n\t\t\t\tfilename: data.assetID,\n\t\t\t\t...context,\n\t\t\t});\n\t\t});\n\t\thook(\"custom-type:asset:read\", async (data, context) => {\n\t\t\tconst file = await readCustomTypeFile({\n\t\t\t\tcustomTypeID: data.customTypeID,\n\t\t\t\tfilename: data.assetID,\n\t\t\t\t...context,\n\t\t\t});\n\n\t\t\treturn {\n\t\t\t\tdata: file,\n\t\t\t};\n\t\t});\n\n\t\t////////////////////////////////////////////////////////////////\n\t\t// custom-type-library:*\n\t\t////////////////////////////////////////////////////////////////\n\n\t\thook(\"custom-type-library:read\", async (_data, context) => {\n\t\t\treturn await readCustomTypeLibrary({\n\t\t\t\thelpers: context.helpers,\n\t\t\t});\n\t\t});\n\n\t\t////////////////////////////////////////////////////////////////\n\t\t// snippet:*\n\t\t////////////////////////////////////////////////////////////////\n\n\t\thook(\"snippet:read\", snippetRead);\n\n\t\t////////////////////////////////////////////////////////////////\n\t\t// documentation:*\n\t\t////////////////////////////////////////////////////////////////\n\n\t\thook(\"documentation:read\", async (_data, _context) => {\n\t\t\t// TODO\n\t\t\treturn [];\n\t\t});\n\n\t\t////////////////////////////////////////////////////////////////\n\t\t// slice-simulator:*\n\t\t////////////////////////////////////////////////////////////////\n\n\t\thook(\"slice-simulator:setup:read\", sliceSimulatorSetupRead);\n\t},\n});\n"],"names":["defineSliceMachinePlugin","pkgName","projectInit","sliceCreate","writeSliceModel","upsertGlobalTypeScriptTypes","renameSlice","rejectIfNecessary","upsertSliceLibraryIndexFile","deleteSliceDirectory","readSliceModel","writeSliceFile","deleteSliceFile","readSliceFile","readSliceLibrary","readSliceTemplateLibrary","fileURLToPath","Hero","writeCustomTypeModel","deleteCustomTypeDirectory","readCustomTypeModel","writeCustomTypeFile","deleteCustomTypeFile","readCustomTypeFile","readCustomTypeLibrary","snippetRead","sliceSimulatorSetupRead"],"mappings":";;;;;;;;;;;;;;AAqCO,MAAM,SAASA,UAAAA,yBAAwC;AAAA,EAC7D,MAAM;AAAA,IACL,MAAMC,SAAA;AAAA,EACN;AAAA,EACD,gBAAgB;AAAA,IACf,QAAQ;AAAA,IACR,wBAAwB;AAAA,EACxB;AAAA,EACD,MAAM,EAAE,QAAM;AAKb,SAAK,gBAAgBC,YAAAA,WAAW;AAMhC,SAAK,gBAAgBC,YAAAA,WAAW;AAC3B,SAAA,gBAAgB,OAAO,MAAM,YAAW;AAC5C,YAAMC,mBAAgB;AAAA,QACrB,WAAW,KAAK;AAAA,QAChB,OAAO,KAAK;AAAA,QACZ,GAAG;AAAA,MAAA,CACH;AAED,YAAMC,+BAA4B;AAAA,QACjC,UAAU,QAAQ,QAAQ;AAAA,QAC1B,QAAQ,QAAQ,QAAQ;AAAA,QACxB,GAAG;AAAA,MAAA,CACH;AAAA,IAAA,CACD;AACI,SAAA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AA,QACrB,GAAG;AAAA,MAAA,CACH;AAAA,IAAA,CACD;AACI,SAAA,4BAA4B,OAAO,MAAM,YAAW;AACxD,YAAMC,wBAAqB;AAAA,QAC1B,cAAc,KAAK;AAAA,QACnB,UAAU,KAAK;AAAA,QACf,GAAG;AAAA,MAAA,CACH;AAAA,IAAA,CACD;AACI,SAAA,0BAA0B,OAAO,MAAM,YAAW;AAChD,YAAA,OAAO,MAAMC,sBAAmB;AAAA,QACrC,cAAc,KAAK;AAAA,QACnB,UAAU,KAAK;AAAA,QACf,GAAG;AAAA,MAAA,CACH;AAEM,aAAA;AAAA,QACN,MAAM;AAAA,MAAA;AAAA,KAEP;AAMI,SAAA,4BAA4B,OAAO,OAAO,YAAW;AACzD,aAAO,MAAMC,GAAAA,sBAAsB;AAAA,QAClC,SAAS,QAAQ;AAAA,MAAA,CACjB;AAAA,IAAA,CACD;AAMD,SAAK,gBAAgBC,YAAAA,WAAW;AAM3B,SAAA,sBAAsB,OAAO,OAAO,aAAY;AAEpD,aAAO;KACP;AAMD,SAAK,8BAA8BC,wBAAAA,uBAAuB;AAAA,EAC3D;AACA,CAAA;;"}
|
|
1
|
+
{"version":3,"file":"plugin.cjs","sources":["../../src/plugin.ts"],"sourcesContent":["import path from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\n\nimport { defineSliceMachinePlugin } from \"@slicemachine/plugin-kit\";\nimport {\n\tdeleteCustomTypeDirectory,\n\tdeleteCustomTypeFile,\n\tdeleteSliceDirectory,\n\tdeleteSliceFile,\n\treadCustomTypeFile,\n\treadCustomTypeLibrary,\n\treadCustomTypeModel,\n\treadSliceFile,\n\treadSliceLibrary,\n\treadSliceModel,\n\treadSliceTemplateLibrary,\n\trenameSlice,\n\tupsertGlobalTypeScriptTypes,\n\twriteCustomTypeFile,\n\twriteCustomTypeModel,\n\twriteSliceFile,\n\twriteSliceModel,\n} from \"@slicemachine/plugin-kit/fs\";\n\nimport { rejectIfNecessary } from \"./lib/rejectIfNecessary\";\nimport { upsertSliceLibraryIndexFile } from \"./lib/upsertSliceLibraryIndexFile\";\n\nimport { name as pkgName } from \"../package.json\";\nimport { PluginOptions } from \"./types\";\n\nimport { documentationRead } from \"./hooks/documentation-read\";\nimport { projectInit } from \"./hooks/project-init\";\nimport { sliceCreate } from \"./hooks/slice-create\";\nimport { sliceSimulatorSetupRead } from \"./hooks/sliceSimulator-setup-read\";\nimport { snippetRead } from \"./hooks/snippet-read\";\n\nimport * as Hero from \"./sliceTemplates/Hero\";\n\nexport const plugin = defineSliceMachinePlugin<PluginOptions>({\n\tmeta: {\n\t\tname: pkgName,\n\t},\n\tdefaultOptions: {\n\t\tformat: true,\n\t\tgeneratedTypesFilePath: \"./src/prismicio-types.d.ts\",\n\t},\n\tsetup({ hook }) {\n\t\t////////////////////////////////////////////////////////////////\n\t\t// project:*\n\t\t////////////////////////////////////////////////////////////////\n\n\t\thook(\"project:init\", projectInit);\n\n\t\t////////////////////////////////////////////////////////////////\n\t\t// slice:*\n\t\t////////////////////////////////////////////////////////////////\n\n\t\thook(\"slice:create\", sliceCreate);\n\t\thook(\"slice:update\", async (data, context) => {\n\t\t\tawait writeSliceModel({\n\t\t\t\tlibraryID: data.libraryID,\n\t\t\t\tmodel: data.model,\n\t\t\t\t...context,\n\t\t\t});\n\n\t\t\tawait upsertGlobalTypeScriptTypes({\n\t\t\t\tfilename: context.options.generatedTypesFilePath,\n\t\t\t\tformat: context.options.format,\n\t\t\t\t...context,\n\t\t\t});\n\t\t});\n\t\thook(\"slice:rename\", async (data, context) => {\n\t\t\tawait renameSlice({\n\t\t\t\tlibraryID: data.libraryID,\n\t\t\t\tmodel: data.model,\n\t\t\t\tformat: context.options.format,\n\t\t\t\t...context,\n\t\t\t});\n\n\t\t\trejectIfNecessary(\n\t\t\t\tawait Promise.allSettled([\n\t\t\t\t\tupsertSliceLibraryIndexFile({\n\t\t\t\t\t\tlibraryID: data.libraryID,\n\t\t\t\t\t\t...context,\n\t\t\t\t\t}),\n\t\t\t\t\tupsertGlobalTypeScriptTypes({\n\t\t\t\t\t\tfilename: context.options.generatedTypesFilePath,\n\t\t\t\t\t\tformat: context.options.format,\n\t\t\t\t\t\t...context,\n\t\t\t\t\t}),\n\t\t\t\t]),\n\t\t\t);\n\t\t});\n\t\thook(\"slice:delete\", async (data, context) => {\n\t\t\tawait deleteSliceDirectory({\n\t\t\t\tlibraryID: data.libraryID,\n\t\t\t\tmodel: data.model,\n\t\t\t\t...context,\n\t\t\t});\n\n\t\t\trejectIfNecessary(\n\t\t\t\tawait Promise.allSettled([\n\t\t\t\t\tupsertSliceLibraryIndexFile({\n\t\t\t\t\t\tlibraryID: data.libraryID,\n\t\t\t\t\t\t...context,\n\t\t\t\t\t}),\n\t\t\t\t\tupsertGlobalTypeScriptTypes({\n\t\t\t\t\t\tfilename: context.options.generatedTypesFilePath,\n\t\t\t\t\t\tformat: context.options.format,\n\t\t\t\t\t\t...context,\n\t\t\t\t\t}),\n\t\t\t\t]),\n\t\t\t);\n\t\t});\n\t\thook(\"slice:read\", async (data, context) => {\n\t\t\treturn await readSliceModel({\n\t\t\t\tlibraryID: data.libraryID,\n\t\t\t\tsliceID: data.sliceID,\n\t\t\t\t...context,\n\t\t\t});\n\t\t});\n\t\thook(\"slice:asset:update\", async (data, context) => {\n\t\t\tawait writeSliceFile({\n\t\t\t\tlibraryID: data.libraryID,\n\t\t\t\tsliceID: data.sliceID,\n\t\t\t\tfilename: data.asset.id,\n\t\t\t\tcontents: data.asset.data,\n\t\t\t\t...context,\n\t\t\t});\n\t\t});\n\t\thook(\"slice:asset:delete\", async (data, context) => {\n\t\t\tawait deleteSliceFile({\n\t\t\t\tlibraryID: data.libraryID,\n\t\t\t\tsliceID: data.sliceID,\n\t\t\t\tfilename: data.assetID,\n\t\t\t\t...context,\n\t\t\t});\n\t\t});\n\t\thook(\"slice:asset:read\", async (data, context) => {\n\t\t\tconst file = await readSliceFile({\n\t\t\t\tlibraryID: data.libraryID,\n\t\t\t\tsliceID: data.sliceID,\n\t\t\t\tfilename: data.assetID,\n\t\t\t\t...context,\n\t\t\t});\n\n\t\t\treturn {\n\t\t\t\tdata: file,\n\t\t\t};\n\t\t});\n\n\t\t////////////////////////////////////////////////////////////////\n\t\t// slice-library:*\n\t\t////////////////////////////////////////////////////////////////\n\n\t\thook(\"slice-library:read\", async (data, context) => {\n\t\t\treturn await readSliceLibrary({\n\t\t\t\tlibraryID: data.libraryID,\n\t\t\t\t...context,\n\t\t\t});\n\t\t});\n\n\t\t////////////////////////////////////////////////////////////////\n\t\t// slice-template-library:*\n\t\t////////////////////////////////////////////////////////////////\n\n\t\thook(\"slice-template-library:read\", async (data, context) => {\n\t\t\treturn await readSliceTemplateLibrary({\n\t\t\t\t...data,\n\t\t\t\t...context,\n\t\t\t\tdirName: path.dirname(fileURLToPath(new URL(import.meta.url))),\n\t\t\t\ttemplates: [Hero],\n\t\t\t\tcomponentFileNames: {\n\t\t\t\t\tjs: \"javascript.svelte\",\n\t\t\t\t\tts: \"typescript.svelte\",\n\t\t\t\t},\n\t\t\t});\n\t\t});\n\n\t\t////////////////////////////////////////////////////////////////\n\t\t// custom-type:*\n\t\t////////////////////////////////////////////////////////////////\n\n\t\thook(\"custom-type:create\", async (data, context) => {\n\t\t\tawait writeCustomTypeModel({\n\t\t\t\tmodel: data.model,\n\t\t\t\tformat: context.options.format,\n\t\t\t\t...context,\n\t\t\t});\n\n\t\t\tawait upsertGlobalTypeScriptTypes({\n\t\t\t\tfilename: context.options.generatedTypesFilePath,\n\t\t\t\tformat: context.options.format,\n\t\t\t\t...context,\n\t\t\t});\n\t\t});\n\t\thook(\"custom-type:update\", async (data, context) => {\n\t\t\tawait writeCustomTypeModel({\n\t\t\t\tmodel: data.model,\n\t\t\t\tformat: context.options.format,\n\t\t\t\t...context,\n\t\t\t});\n\n\t\t\tawait upsertGlobalTypeScriptTypes({\n\t\t\t\tfilename: context.options.generatedTypesFilePath,\n\t\t\t\tformat: context.options.format,\n\t\t\t\t...context,\n\t\t\t});\n\t\t});\n\t\thook(\"custom-type:rename\", async (data, context) => {\n\t\t\tawait writeCustomTypeModel({\n\t\t\t\tmodel: data.model,\n\t\t\t\tformat: context.options.format,\n\t\t\t\t...context,\n\t\t\t});\n\n\t\t\tawait upsertGlobalTypeScriptTypes({\n\t\t\t\tfilename: context.options.generatedTypesFilePath,\n\t\t\t\tformat: context.options.format,\n\t\t\t\t...context,\n\t\t\t});\n\t\t});\n\t\thook(\"custom-type:delete\", async (data, context) => {\n\t\t\tawait deleteCustomTypeDirectory({\n\t\t\t\tcustomTypeID: data.model.id,\n\t\t\t\t...context,\n\t\t\t});\n\n\t\t\tawait upsertGlobalTypeScriptTypes({\n\t\t\t\tfilename: context.options.generatedTypesFilePath,\n\t\t\t\tformat: context.options.format,\n\t\t\t\t...context,\n\t\t\t});\n\t\t});\n\t\thook(\"custom-type:read\", async (data, context) => {\n\t\t\treturn await readCustomTypeModel({\n\t\t\t\tcustomTypeID: data.id,\n\t\t\t\t...context,\n\t\t\t});\n\t\t});\n\t\thook(\"custom-type:asset:update\", async (data, context) => {\n\t\t\tawait writeCustomTypeFile({\n\t\t\t\tcustomTypeID: data.customTypeID,\n\t\t\t\tfilename: data.asset.id,\n\t\t\t\tcontents: data.asset.data,\n\t\t\t\t...context,\n\t\t\t});\n\t\t});\n\t\thook(\"custom-type:asset:delete\", async (data, context) => {\n\t\t\tawait deleteCustomTypeFile({\n\t\t\t\tcustomTypeID: data.customTypeID,\n\t\t\t\tfilename: data.assetID,\n\t\t\t\t...context,\n\t\t\t});\n\t\t});\n\t\thook(\"custom-type:asset:read\", async (data, context) => {\n\t\t\tconst file = await readCustomTypeFile({\n\t\t\t\tcustomTypeID: data.customTypeID,\n\t\t\t\tfilename: data.assetID,\n\t\t\t\t...context,\n\t\t\t});\n\n\t\t\treturn {\n\t\t\t\tdata: file,\n\t\t\t};\n\t\t});\n\n\t\t////////////////////////////////////////////////////////////////\n\t\t// custom-type-library:*\n\t\t////////////////////////////////////////////////////////////////\n\n\t\thook(\"custom-type-library:read\", async (_data, context) => {\n\t\t\treturn await readCustomTypeLibrary({\n\t\t\t\thelpers: context.helpers,\n\t\t\t});\n\t\t});\n\n\t\t////////////////////////////////////////////////////////////////\n\t\t// snippet:*\n\t\t////////////////////////////////////////////////////////////////\n\n\t\thook(\"snippet:read\", snippetRead);\n\n\t\t////////////////////////////////////////////////////////////////\n\t\t// documentation:*\n\t\t////////////////////////////////////////////////////////////////\n\n\t\thook(\"documentation:read\", documentationRead);\n\n\t\t////////////////////////////////////////////////////////////////\n\t\t// slice-simulator:*\n\t\t////////////////////////////////////////////////////////////////\n\n\t\thook(\"slice-simulator:setup:read\", sliceSimulatorSetupRead);\n\t},\n});\n"],"names":["defineSliceMachinePlugin","pkgName","projectInit","sliceCreate","writeSliceModel","upsertGlobalTypeScriptTypes","renameSlice","rejectIfNecessary","upsertSliceLibraryIndexFile","deleteSliceDirectory","readSliceModel","writeSliceFile","deleteSliceFile","readSliceFile","readSliceLibrary","readSliceTemplateLibrary","fileURLToPath","Hero","writeCustomTypeModel","deleteCustomTypeDirectory","readCustomTypeModel","writeCustomTypeFile","deleteCustomTypeFile","readCustomTypeFile","readCustomTypeLibrary","snippetRead","documentationRead","sliceSimulatorSetupRead"],"mappings":";;;;;;;;;;;;;;;AAsCO,MAAM,SAASA,UAAAA,yBAAwC;AAAA,EAC7D,MAAM;AAAA,IACL,MAAMC,SAAA;AAAA,EACN;AAAA,EACD,gBAAgB;AAAA,IACf,QAAQ;AAAA,IACR,wBAAwB;AAAA,EACxB;AAAA,EACD,MAAM,EAAE,QAAM;AAKb,SAAK,gBAAgBC,YAAAA,WAAW;AAMhC,SAAK,gBAAgBC,YAAAA,WAAW;AAC3B,SAAA,gBAAgB,OAAO,MAAM,YAAW;AAC5C,YAAMC,mBAAgB;AAAA,QACrB,WAAW,KAAK;AAAA,QAChB,OAAO,KAAK;AAAA,QACZ,GAAG;AAAA,MAAA,CACH;AAED,YAAMC,+BAA4B;AAAA,QACjC,UAAU,QAA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ACxD,YAAMC,uBAAoB;AAAA,QACzB,cAAc,KAAK;AAAA,QACnB,UAAU,KAAK,MAAM;AAAA,QACrB,UAAU,KAAK,MAAM;AAAA,QACrB,GAAG;AAAA,MAAA,CACH;AAAA,IAAA,CACD;AACI,SAAA,4BAA4B,OAAO,MAAM,YAAW;AACxD,YAAMC,wBAAqB;AAAA,QAC1B,cAAc,KAAK;AAAA,QACnB,UAAU,KAAK;AAAA,QACf,GAAG;AAAA,MAAA,CACH;AAAA,IAAA,CACD;AACI,SAAA,0BAA0B,OAAO,MAAM,YAAW;AAChD,YAAA,OAAO,MAAMC,sBAAmB;AAAA,QACrC,cAAc,KAAK;AAAA,QACnB,UAAU,KAAK;AAAA,QACf,GAAG;AAAA,MAAA,CACH;AAEM,aAAA;AAAA,QACN,MAAM;AAAA,MAAA;AAAA,KAEP;AAMI,SAAA,4BAA4B,OAAO,OAAO,YAAW;AACzD,aAAO,MAAMC,GAAAA,sBAAsB;AAAA,QAClC,SAAS,QAAQ;AAAA,MAAA,CACjB;AAAA,IAAA,CACD;AAMD,SAAK,gBAAgBC,YAAAA,WAAW;AAMhC,SAAK,sBAAsBC,kBAAAA,iBAAiB;AAM5C,SAAK,8BAA8BC,wBAAAA,uBAAuB;AAAA,EAC3D;AACA,CAAA;;"}
|
package/dist/plugin.js
CHANGED
|
@@ -5,6 +5,7 @@ import { writeSliceModel, upsertGlobalTypeScriptTypes, renameSlice, deleteSliceD
|
|
|
5
5
|
import { rejectIfNecessary } from "./lib/rejectIfNecessary.js";
|
|
6
6
|
import { upsertSliceLibraryIndexFile } from "./lib/upsertSliceLibraryIndexFile.js";
|
|
7
7
|
import { name } from "./packages/adapter-sveltekit/package.json.js";
|
|
8
|
+
import { documentationRead } from "./hooks/documentation-read.js";
|
|
8
9
|
import { projectInit } from "./hooks/project-init.js";
|
|
9
10
|
import { sliceCreate } from "./hooks/slice-create.js";
|
|
10
11
|
import { sliceSimulatorSetupRead } from "./hooks/sliceSimulator-setup-read.js";
|
|
@@ -207,9 +208,7 @@ const plugin = defineSliceMachinePlugin({
|
|
|
207
208
|
});
|
|
208
209
|
});
|
|
209
210
|
hook("snippet:read", snippetRead);
|
|
210
|
-
hook("documentation:read",
|
|
211
|
-
return [];
|
|
212
|
-
});
|
|
211
|
+
hook("documentation:read", documentationRead);
|
|
213
212
|
hook("slice-simulator:setup:read", sliceSimulatorSetupRead);
|
|
214
213
|
}
|
|
215
214
|
});
|
package/dist/plugin.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.js","sources":["../../src/plugin.ts"],"sourcesContent":["import path from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\n\nimport { defineSliceMachinePlugin } from \"@slicemachine/plugin-kit\";\nimport {\n\tdeleteCustomTypeDirectory,\n\tdeleteCustomTypeFile,\n\tdeleteSliceDirectory,\n\tdeleteSliceFile,\n\treadCustomTypeFile,\n\treadCustomTypeLibrary,\n\treadCustomTypeModel,\n\treadSliceFile,\n\treadSliceLibrary,\n\treadSliceModel,\n\treadSliceTemplateLibrary,\n\trenameSlice,\n\tupsertGlobalTypeScriptTypes,\n\twriteCustomTypeFile,\n\twriteCustomTypeModel,\n\twriteSliceFile,\n\twriteSliceModel,\n} from \"@slicemachine/plugin-kit/fs\";\n\nimport { rejectIfNecessary } from \"./lib/rejectIfNecessary\";\nimport { upsertSliceLibraryIndexFile } from \"./lib/upsertSliceLibraryIndexFile\";\n\nimport { name as pkgName } from \"../package.json\";\nimport { PluginOptions } from \"./types\";\n\nimport { projectInit } from \"./hooks/project-init\";\nimport { sliceCreate } from \"./hooks/slice-create\";\nimport { sliceSimulatorSetupRead } from \"./hooks/sliceSimulator-setup-read\";\nimport { snippetRead } from \"./hooks/snippet-read\";\n\nimport * as Hero from \"./sliceTemplates/Hero\";\n\nexport const plugin = defineSliceMachinePlugin<PluginOptions>({\n\tmeta: {\n\t\tname: pkgName,\n\t},\n\tdefaultOptions: {\n\t\tformat: true,\n\t\tgeneratedTypesFilePath: \"./src/prismicio-types.d.ts\",\n\t},\n\tsetup({ hook }) {\n\t\t////////////////////////////////////////////////////////////////\n\t\t// project:*\n\t\t////////////////////////////////////////////////////////////////\n\n\t\thook(\"project:init\", projectInit);\n\n\t\t////////////////////////////////////////////////////////////////\n\t\t// slice:*\n\t\t////////////////////////////////////////////////////////////////\n\n\t\thook(\"slice:create\", sliceCreate);\n\t\thook(\"slice:update\", async (data, context) => {\n\t\t\tawait writeSliceModel({\n\t\t\t\tlibraryID: data.libraryID,\n\t\t\t\tmodel: data.model,\n\t\t\t\t...context,\n\t\t\t});\n\n\t\t\tawait upsertGlobalTypeScriptTypes({\n\t\t\t\tfilename: context.options.generatedTypesFilePath,\n\t\t\t\tformat: context.options.format,\n\t\t\t\t...context,\n\t\t\t});\n\t\t});\n\t\thook(\"slice:rename\", async (data, context) => {\n\t\t\tawait renameSlice({\n\t\t\t\tlibraryID: data.libraryID,\n\t\t\t\tmodel: data.model,\n\t\t\t\tformat: context.options.format,\n\t\t\t\t...context,\n\t\t\t});\n\n\t\t\trejectIfNecessary(\n\t\t\t\tawait Promise.allSettled([\n\t\t\t\t\tupsertSliceLibraryIndexFile({\n\t\t\t\t\t\tlibraryID: data.libraryID,\n\t\t\t\t\t\t...context,\n\t\t\t\t\t}),\n\t\t\t\t\tupsertGlobalTypeScriptTypes({\n\t\t\t\t\t\tfilename: context.options.generatedTypesFilePath,\n\t\t\t\t\t\tformat: context.options.format,\n\t\t\t\t\t\t...context,\n\t\t\t\t\t}),\n\t\t\t\t]),\n\t\t\t);\n\t\t});\n\t\thook(\"slice:delete\", async (data, context) => {\n\t\t\tawait deleteSliceDirectory({\n\t\t\t\tlibraryID: data.libraryID,\n\t\t\t\tmodel: data.model,\n\t\t\t\t...context,\n\t\t\t});\n\n\t\t\trejectIfNecessary(\n\t\t\t\tawait Promise.allSettled([\n\t\t\t\t\tupsertSliceLibraryIndexFile({\n\t\t\t\t\t\tlibraryID: data.libraryID,\n\t\t\t\t\t\t...context,\n\t\t\t\t\t}),\n\t\t\t\t\tupsertGlobalTypeScriptTypes({\n\t\t\t\t\t\tfilename: context.options.generatedTypesFilePath,\n\t\t\t\t\t\tformat: context.options.format,\n\t\t\t\t\t\t...context,\n\t\t\t\t\t}),\n\t\t\t\t]),\n\t\t\t);\n\t\t});\n\t\thook(\"slice:read\", async (data, context) => {\n\t\t\treturn await readSliceModel({\n\t\t\t\tlibraryID: data.libraryID,\n\t\t\t\tsliceID: data.sliceID,\n\t\t\t\t...context,\n\t\t\t});\n\t\t});\n\t\thook(\"slice:asset:update\", async (data, context) => {\n\t\t\tawait writeSliceFile({\n\t\t\t\tlibraryID: data.libraryID,\n\t\t\t\tsliceID: data.sliceID,\n\t\t\t\tfilename: data.asset.id,\n\t\t\t\tcontents: data.asset.data,\n\t\t\t\t...context,\n\t\t\t});\n\t\t});\n\t\thook(\"slice:asset:delete\", async (data, context) => {\n\t\t\tawait deleteSliceFile({\n\t\t\t\tlibraryID: data.libraryID,\n\t\t\t\tsliceID: data.sliceID,\n\t\t\t\tfilename: data.assetID,\n\t\t\t\t...context,\n\t\t\t});\n\t\t});\n\t\thook(\"slice:asset:read\", async (data, context) => {\n\t\t\tconst file = await readSliceFile({\n\t\t\t\tlibraryID: data.libraryID,\n\t\t\t\tsliceID: data.sliceID,\n\t\t\t\tfilename: data.assetID,\n\t\t\t\t...context,\n\t\t\t});\n\n\t\t\treturn {\n\t\t\t\tdata: file,\n\t\t\t};\n\t\t});\n\n\t\t////////////////////////////////////////////////////////////////\n\t\t// slice-library:*\n\t\t////////////////////////////////////////////////////////////////\n\n\t\thook(\"slice-library:read\", async (data, context) => {\n\t\t\treturn await readSliceLibrary({\n\t\t\t\tlibraryID: data.libraryID,\n\t\t\t\t...context,\n\t\t\t});\n\t\t});\n\n\t\t////////////////////////////////////////////////////////////////\n\t\t// slice-template-library:*\n\t\t////////////////////////////////////////////////////////////////\n\n\t\thook(\"slice-template-library:read\", async (data, context) => {\n\t\t\treturn await readSliceTemplateLibrary({\n\t\t\t\t...data,\n\t\t\t\t...context,\n\t\t\t\tdirName: path.dirname(fileURLToPath(new URL(import.meta.url))),\n\t\t\t\ttemplates: [Hero],\n\t\t\t\tcomponentFileNames: {\n\t\t\t\t\tjs: \"javascript.svelte\",\n\t\t\t\t\tts: \"typescript.svelte\",\n\t\t\t\t},\n\t\t\t});\n\t\t});\n\n\t\t////////////////////////////////////////////////////////////////\n\t\t// custom-type:*\n\t\t////////////////////////////////////////////////////////////////\n\n\t\thook(\"custom-type:create\", async (data, context) => {\n\t\t\tawait writeCustomTypeModel({\n\t\t\t\tmodel: data.model,\n\t\t\t\tformat: context.options.format,\n\t\t\t\t...context,\n\t\t\t});\n\n\t\t\tawait upsertGlobalTypeScriptTypes({\n\t\t\t\tfilename: context.options.generatedTypesFilePath,\n\t\t\t\tformat: context.options.format,\n\t\t\t\t...context,\n\t\t\t});\n\t\t});\n\t\thook(\"custom-type:update\", async (data, context) => {\n\t\t\tawait writeCustomTypeModel({\n\t\t\t\tmodel: data.model,\n\t\t\t\tformat: context.options.format,\n\t\t\t\t...context,\n\t\t\t});\n\n\t\t\tawait upsertGlobalTypeScriptTypes({\n\t\t\t\tfilename: context.options.generatedTypesFilePath,\n\t\t\t\tformat: context.options.format,\n\t\t\t\t...context,\n\t\t\t});\n\t\t});\n\t\thook(\"custom-type:rename\", async (data, context) => {\n\t\t\tawait writeCustomTypeModel({\n\t\t\t\tmodel: data.model,\n\t\t\t\tformat: context.options.format,\n\t\t\t\t...context,\n\t\t\t});\n\n\t\t\tawait upsertGlobalTypeScriptTypes({\n\t\t\t\tfilename: context.options.generatedTypesFilePath,\n\t\t\t\tformat: context.options.format,\n\t\t\t\t...context,\n\t\t\t});\n\t\t});\n\t\thook(\"custom-type:delete\", async (data, context) => {\n\t\t\tawait deleteCustomTypeDirectory({\n\t\t\t\tcustomTypeID: data.model.id,\n\t\t\t\t...context,\n\t\t\t});\n\n\t\t\tawait upsertGlobalTypeScriptTypes({\n\t\t\t\tfilename: context.options.generatedTypesFilePath,\n\t\t\t\tformat: context.options.format,\n\t\t\t\t...context,\n\t\t\t});\n\t\t});\n\t\thook(\"custom-type:read\", async (data, context) => {\n\t\t\treturn await readCustomTypeModel({\n\t\t\t\tcustomTypeID: data.id,\n\t\t\t\t...context,\n\t\t\t});\n\t\t});\n\t\thook(\"custom-type:asset:update\", async (data, context) => {\n\t\t\tawait writeCustomTypeFile({\n\t\t\t\tcustomTypeID: data.customTypeID,\n\t\t\t\tfilename: data.asset.id,\n\t\t\t\tcontents: data.asset.data,\n\t\t\t\t...context,\n\t\t\t});\n\t\t});\n\t\thook(\"custom-type:asset:delete\", async (data, context) => {\n\t\t\tawait deleteCustomTypeFile({\n\t\t\t\tcustomTypeID: data.customTypeID,\n\t\t\t\tfilename: data.assetID,\n\t\t\t\t...context,\n\t\t\t});\n\t\t});\n\t\thook(\"custom-type:asset:read\", async (data, context) => {\n\t\t\tconst file = await readCustomTypeFile({\n\t\t\t\tcustomTypeID: data.customTypeID,\n\t\t\t\tfilename: data.assetID,\n\t\t\t\t...context,\n\t\t\t});\n\n\t\t\treturn {\n\t\t\t\tdata: file,\n\t\t\t};\n\t\t});\n\n\t\t////////////////////////////////////////////////////////////////\n\t\t// custom-type-library:*\n\t\t////////////////////////////////////////////////////////////////\n\n\t\thook(\"custom-type-library:read\", async (_data, context) => {\n\t\t\treturn await readCustomTypeLibrary({\n\t\t\t\thelpers: context.helpers,\n\t\t\t});\n\t\t});\n\n\t\t////////////////////////////////////////////////////////////////\n\t\t// snippet:*\n\t\t////////////////////////////////////////////////////////////////\n\n\t\thook(\"snippet:read\", snippetRead);\n\n\t\t////////////////////////////////////////////////////////////////\n\t\t// documentation:*\n\t\t////////////////////////////////////////////////////////////////\n\n\t\thook(\"documentation:read\", async (_data, _context) => {\n\t\t\t// TODO\n\t\t\treturn [];\n\t\t});\n\n\t\t////////////////////////////////////////////////////////////////\n\t\t// slice-simulator:*\n\t\t////////////////////////////////////////////////////////////////\n\n\t\thook(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B;AAAA,QACjC,UAAU,QAAQ,QAAQ;AAAA,QAC1B,QAAQ,QAAQ,QAAQ;AAAA,QACxB,GAAG;AAAA,MAAA,CACH;AAAA,IAAA,CACD;AACI,SAAA,oBAAoB,OAAO,MAAM,YAAW;AAChD,aAAO,MAAM,oBAAoB;AAAA,QAChC,cAAc,KAAK;AAAA,QACnB,GAAG;AAAA,MAAA,CACH;AAAA,IAAA,CACD;AACI,SAAA,4BAA4B,OAAO,MAAM,YAAW;AACxD,YAAM,oBAAoB;AAAA,QACzB,cAAc,KAAK;AAAA,QACnB,UAAU,KAAK,MAAM;AAAA,QACrB,UAAU,KAAK,MAAM;AAAA,QACrB,GAAG;AAAA,MAAA,CACH;AAAA,IAAA,CACD;AACI,SAAA,4BAA4B,OAAO,MAAM,YAAW;AACxD,YAAM,qBAAqB;AAAA,QAC1B,cAAc,KAAK;AAAA,QACnB,UAAU,KAAK;AAAA,QACf,GAAG;AAAA,MAAA,CACH;AAAA,IAAA,CACD;AACI,SAAA,0BAA0B,OAAO,MAAM,YAAW;AAChD,YAAA,OAAO,MAAM,mBAAmB;AAAA,QACrC,cAAc,KAAK;AAAA,QACnB,UAAU,KAAK;AAAA,QACf,GAAG;AAAA,MAAA,CACH;AAEM,aAAA;AAAA,QACN,MAAM;AAAA,MAAA;AAAA,KAEP;AAMI,SAAA,4BAA4B,OAAO,OAAO,YAAW;AACzD,aAAO,MAAM,sBAAsB;AAAA,QAClC,SAAS,QAAQ;AAAA,MAAA,CACjB;AAAA,IAAA,CACD;AAMD,SAAK,gBAAgB,WAAW;AAM3B,SAAA,sBAAsB,OAAO,OAAO,aAAY;AAEpD,aAAO;KACP;AAMD,SAAK,8BAA8B,uBAAuB;AAAA,EAC3D;AACA,CAAA;"}
|
|
1
|
+
{"version":3,"file":"plugin.js","sources":["../../src/plugin.ts"],"sourcesContent":["import path from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\n\nimport { defineSliceMachinePlugin } from \"@slicemachine/plugin-kit\";\nimport {\n\tdeleteCustomTypeDirectory,\n\tdeleteCustomTypeFile,\n\tdeleteSliceDirectory,\n\tdeleteSliceFile,\n\treadCustomTypeFile,\n\treadCustomTypeLibrary,\n\treadCustomTypeModel,\n\treadSliceFile,\n\treadSliceLibrary,\n\treadSliceModel,\n\treadSliceTemplateLibrary,\n\trenameSlice,\n\tupsertGlobalTypeScriptTypes,\n\twriteCustomTypeFile,\n\twriteCustomTypeModel,\n\twriteSliceFile,\n\twriteSliceModel,\n} from \"@slicemachine/plugin-kit/fs\";\n\nimport { rejectIfNecessary } from \"./lib/rejectIfNecessary\";\nimport { upsertSliceLibraryIndexFile } from \"./lib/upsertSliceLibraryIndexFile\";\n\nimport { name as pkgName } from \"../package.json\";\nimport { PluginOptions } from \"./types\";\n\nimport { documentationRead } from \"./hooks/documentation-read\";\nimport { projectInit } from \"./hooks/project-init\";\nimport { sliceCreate } from \"./hooks/slice-create\";\nimport { sliceSimulatorSetupRead } from \"./hooks/sliceSimulator-setup-read\";\nimport { snippetRead } from \"./hooks/snippet-read\";\n\nimport * as Hero from \"./sliceTemplates/Hero\";\n\nexport const plugin = defineSliceMachinePlugin<PluginOptions>({\n\tmeta: {\n\t\tname: pkgName,\n\t},\n\tdefaultOptions: {\n\t\tformat: true,\n\t\tgeneratedTypesFilePath: \"./src/prismicio-types.d.ts\",\n\t},\n\tsetup({ hook }) {\n\t\t////////////////////////////////////////////////////////////////\n\t\t// project:*\n\t\t////////////////////////////////////////////////////////////////\n\n\t\thook(\"project:init\", projectInit);\n\n\t\t////////////////////////////////////////////////////////////////\n\t\t// slice:*\n\t\t////////////////////////////////////////////////////////////////\n\n\t\thook(\"slice:create\", sliceCreate);\n\t\thook(\"slice:update\", async (data, context) => {\n\t\t\tawait writeSliceModel({\n\t\t\t\tlibraryID: data.libraryID,\n\t\t\t\tmodel: data.model,\n\t\t\t\t...context,\n\t\t\t});\n\n\t\t\tawait upsertGlobalTypeScriptTypes({\n\t\t\t\tfilename: context.options.generatedTypesFilePath,\n\t\t\t\tformat: context.options.format,\n\t\t\t\t...context,\n\t\t\t});\n\t\t});\n\t\thook(\"slice:rename\", async (data, context) => {\n\t\t\tawait renameSlice({\n\t\t\t\tlibraryID: data.libraryID,\n\t\t\t\tmodel: data.model,\n\t\t\t\tformat: context.options.format,\n\t\t\t\t...context,\n\t\t\t});\n\n\t\t\trejectIfNecessary(\n\t\t\t\tawait Promise.allSettled([\n\t\t\t\t\tupsertSliceLibraryIndexFile({\n\t\t\t\t\t\tlibraryID: data.libraryID,\n\t\t\t\t\t\t...context,\n\t\t\t\t\t}),\n\t\t\t\t\tupsertGlobalTypeScriptTypes({\n\t\t\t\t\t\tfilename: context.options.generatedTypesFilePath,\n\t\t\t\t\t\tformat: context.options.format,\n\t\t\t\t\t\t...context,\n\t\t\t\t\t}),\n\t\t\t\t]),\n\t\t\t);\n\t\t});\n\t\thook(\"slice:delete\", async (data, context) => {\n\t\t\tawait deleteSliceDirectory({\n\t\t\t\tlibraryID: data.libraryID,\n\t\t\t\tmodel: data.model,\n\t\t\t\t...context,\n\t\t\t});\n\n\t\t\trejectIfNecessary(\n\t\t\t\tawait Promise.allSettled([\n\t\t\t\t\tupsertSliceLibraryIndexFile({\n\t\t\t\t\t\tlibraryID: data.libraryID,\n\t\t\t\t\t\t...context,\n\t\t\t\t\t}),\n\t\t\t\t\tupsertGlobalTypeScriptTypes({\n\t\t\t\t\t\tfilename: context.options.generatedTypesFilePath,\n\t\t\t\t\t\tformat: context.options.format,\n\t\t\t\t\t\t...context,\n\t\t\t\t\t}),\n\t\t\t\t]),\n\t\t\t);\n\t\t});\n\t\thook(\"slice:read\", async (data, context) => {\n\t\t\treturn await readSliceModel({\n\t\t\t\tlibraryID: data.libraryID,\n\t\t\t\tsliceID: data.sliceID,\n\t\t\t\t...context,\n\t\t\t});\n\t\t});\n\t\thook(\"slice:asset:update\", async (data, context) => {\n\t\t\tawait writeSliceFile({\n\t\t\t\tlibraryID: data.libraryID,\n\t\t\t\tsliceID: data.sliceID,\n\t\t\t\tfilename: data.asset.id,\n\t\t\t\tcontents: data.asset.data,\n\t\t\t\t...context,\n\t\t\t});\n\t\t});\n\t\thook(\"slice:asset:delete\", async (data, context) => {\n\t\t\tawait deleteSliceFile({\n\t\t\t\tlibraryID: data.libraryID,\n\t\t\t\tsliceID: data.sliceID,\n\t\t\t\tfilename: data.assetID,\n\t\t\t\t...context,\n\t\t\t});\n\t\t});\n\t\thook(\"slice:asset:read\", async (data, context) => {\n\t\t\tconst file = await readSliceFile({\n\t\t\t\tlibraryID: data.libraryID,\n\t\t\t\tsliceID: data.sliceID,\n\t\t\t\tfilename: data.assetID,\n\t\t\t\t...context,\n\t\t\t});\n\n\t\t\treturn {\n\t\t\t\tdata: file,\n\t\t\t};\n\t\t});\n\n\t\t////////////////////////////////////////////////////////////////\n\t\t// slice-library:*\n\t\t////////////////////////////////////////////////////////////////\n\n\t\thook(\"slice-library:read\", async (data, context) => {\n\t\t\treturn await readSliceLibrary({\n\t\t\t\tlibraryID: data.libraryID,\n\t\t\t\t...context,\n\t\t\t});\n\t\t});\n\n\t\t////////////////////////////////////////////////////////////////\n\t\t// slice-template-library:*\n\t\t////////////////////////////////////////////////////////////////\n\n\t\thook(\"slice-template-library:read\", async (data, context) => {\n\t\t\treturn await readSliceTemplateLibrary({\n\t\t\t\t...data,\n\t\t\t\t...context,\n\t\t\t\tdirName: path.dirname(fileURLToPath(new URL(import.meta.url))),\n\t\t\t\ttemplates: [Hero],\n\t\t\t\tcomponentFileNames: {\n\t\t\t\t\tjs: \"javascript.svelte\",\n\t\t\t\t\tts: \"typescript.svelte\",\n\t\t\t\t},\n\t\t\t});\n\t\t});\n\n\t\t////////////////////////////////////////////////////////////////\n\t\t// custom-type:*\n\t\t////////////////////////////////////////////////////////////////\n\n\t\thook(\"custom-type:create\", async (data, context) => {\n\t\t\tawait writeCustomTypeModel({\n\t\t\t\tmodel: data.model,\n\t\t\t\tformat: context.options.format,\n\t\t\t\t...context,\n\t\t\t});\n\n\t\t\tawait upsertGlobalTypeScriptTypes({\n\t\t\t\tfilename: context.options.generatedTypesFilePath,\n\t\t\t\tformat: context.options.format,\n\t\t\t\t...context,\n\t\t\t});\n\t\t});\n\t\thook(\"custom-type:update\", async (data, context) => {\n\t\t\tawait writeCustomTypeModel({\n\t\t\t\tmodel: data.model,\n\t\t\t\tformat: context.options.format,\n\t\t\t\t...context,\n\t\t\t});\n\n\t\t\tawait upsertGlobalTypeScriptTypes({\n\t\t\t\tfilename: context.options.generatedTypesFilePath,\n\t\t\t\tformat: context.options.format,\n\t\t\t\t...context,\n\t\t\t});\n\t\t});\n\t\thook(\"custom-type:rename\", async (data, context) => {\n\t\t\tawait writeCustomTypeModel({\n\t\t\t\tmodel: data.model,\n\t\t\t\tformat: context.options.format,\n\t\t\t\t...context,\n\t\t\t});\n\n\t\t\tawait upsertGlobalTypeScriptTypes({\n\t\t\t\tfilename: context.options.generatedTypesFilePath,\n\t\t\t\tformat: context.options.format,\n\t\t\t\t...context,\n\t\t\t});\n\t\t});\n\t\thook(\"custom-type:delete\", async (data, context) => {\n\t\t\tawait deleteCustomTypeDirectory({\n\t\t\t\tcustomTypeID: data.model.id,\n\t\t\t\t...context,\n\t\t\t});\n\n\t\t\tawait upsertGlobalTypeScriptTypes({\n\t\t\t\tfilename: context.options.generatedTypesFilePath,\n\t\t\t\tformat: context.options.format,\n\t\t\t\t...context,\n\t\t\t});\n\t\t});\n\t\thook(\"custom-type:read\", async (data, context) => {\n\t\t\treturn await readCustomTypeModel({\n\t\t\t\tcustomTypeID: data.id,\n\t\t\t\t...context,\n\t\t\t});\n\t\t});\n\t\thook(\"custom-type:asset:update\", async (data, context) => {\n\t\t\tawait writeCustomTypeFile({\n\t\t\t\tcustomTypeID: data.customTypeID,\n\t\t\t\tfilename: data.asset.id,\n\t\t\t\tcontents: data.asset.data,\n\t\t\t\t...context,\n\t\t\t});\n\t\t});\n\t\thook(\"custom-type:asset:delete\", async (data, context) => {\n\t\t\tawait deleteCustomTypeFile({\n\t\t\t\tcustomTypeID: data.customTypeID,\n\t\t\t\tfilename: data.assetID,\n\t\t\t\t...context,\n\t\t\t});\n\t\t});\n\t\thook(\"custom-type:asset:read\", async (data, context) => {\n\t\t\tconst file = await readCustomTypeFile({\n\t\t\t\tcustomTypeID: data.customTypeID,\n\t\t\t\tfilename: data.assetID,\n\t\t\t\t...context,\n\t\t\t});\n\n\t\t\treturn {\n\t\t\t\tdata: file,\n\t\t\t};\n\t\t});\n\n\t\t////////////////////////////////////////////////////////////////\n\t\t// custom-type-library:*\n\t\t////////////////////////////////////////////////////////////////\n\n\t\thook(\"custom-type-library:read\", async (_data, context) => {\n\t\t\treturn await readCustomTypeLibrary({\n\t\t\t\thelpers: context.helpers,\n\t\t\t});\n\t\t});\n\n\t\t////////////////////////////////////////////////////////////////\n\t\t// snippet:*\n\t\t////////////////////////////////////////////////////////////////\n\n\t\thook(\"snippet:read\", snippetRead);\n\n\t\t////////////////////////////////////////////////////////////////\n\t\t// documentation:*\n\t\t////////////////////////////////////////////////////////////////\n\n\t\thook(\"documentation:read\", documentationRead);\n\n\t\t////////////////////////////////////////////////////////////////\n\t\t// slice-simulator:*\n\t\t////////////////////////////////////////////////////////////////\n\n\t\thook(\"slice-simulator:setup:read\", sliceSimulatorSetupRead);\n\t},\n});\n"],"names":["path","Hero"],"mappings":";;;;;;;;;;;;;AAsCO,MAAM,SAAS,yBAAwC;AAAA,EAC7D,MAAM;AAAA,IACL;AAAA,EACA;AAAA,EACD,gBAAgB;AAAA,IACf,QAAQ;AAAA,IACR,wBAAwB;AAAA,EACxB;AAAA,EACD,MAAM,EAAE,QAAM;AAKb,SAAK,gBAAgB,WAAW;AAMhC,SAAK,gBAAgB,WAAW;AAC3B,SAAA,gBAAgB,OAAO,MAAM,YAAW;AAC5C,YAAM,gBAAgB;AAAA,QACrB,WAAW,KAAK;AAAA,QAChB,OAAO,KAAK;AAAA,QACZ,GAAG;AAAA,MAAA,CACH;AAED,YAAM,4BAA4B;AAAA,Q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OAAO,MAAM,YAAW;AACxD,YAAM,qBAAqB;AAAA,QAC1B,cAAc,KAAK;AAAA,QACnB,UAAU,KAAK;AAAA,QACf,GAAG;AAAA,MAAA,CACH;AAAA,IAAA,CACD;AACI,SAAA,0BAA0B,OAAO,MAAM,YAAW;AAChD,YAAA,OAAO,MAAM,mBAAmB;AAAA,QACrC,cAAc,KAAK;AAAA,QACnB,UAAU,KAAK;AAAA,QACf,GAAG;AAAA,MAAA,CACH;AAEM,aAAA;AAAA,QACN,MAAM;AAAA,MAAA;AAAA,KAEP;AAMI,SAAA,4BAA4B,OAAO,OAAO,YAAW;AACzD,aAAO,MAAM,sBAAsB;AAAA,QAClC,SAAS,QAAQ;AAAA,MAAA,CACjB;AAAA,IAAA,CACD;AAMD,SAAK,gBAAgB,WAAW;AAMhC,SAAK,sBAAsB,iBAAiB;AAM5C,SAAK,8BAA8B,uBAAuB;AAAA,EAC3D;AACA,CAAA;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@slicemachine/adapter-sveltekit",
|
|
3
|
-
"version": "0.3.18-dev-next-release.
|
|
3
|
+
"version": "0.3.18-dev-next-release.4",
|
|
4
4
|
"description": "Slice Machine adapter for SvelteKit.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"typescript",
|
|
@@ -64,7 +64,7 @@
|
|
|
64
64
|
"dependencies": {
|
|
65
65
|
"@prismicio/simulator": "^0.1.4",
|
|
66
66
|
"@prismicio/types-internal": "^2.0.0",
|
|
67
|
-
"@slicemachine/plugin-kit": "^0.4.18-dev-next-release.
|
|
67
|
+
"@slicemachine/plugin-kit": "^0.4.18-dev-next-release.4",
|
|
68
68
|
"common-tags": "^1.8.2",
|
|
69
69
|
"fp-ts": "^2.13.1",
|
|
70
70
|
"io-ts": "^2.2.20",
|
|
@@ -109,5 +109,5 @@
|
|
|
109
109
|
"engines": {
|
|
110
110
|
"node": ">=14.15.0"
|
|
111
111
|
},
|
|
112
|
-
"gitHead": "
|
|
112
|
+
"gitHead": "2b827ed877c339e06cac157c6be0fc70f6a284f0"
|
|
113
113
|
}
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import { source } from "common-tags";
|
|
2
|
+
|
|
3
|
+
import type { DocumentationReadHook } from "@slicemachine/plugin-kit";
|
|
4
|
+
|
|
5
|
+
import { getJSFileExtension } from "../lib/getJSFileExtension";
|
|
6
|
+
|
|
7
|
+
import type { PluginOptions } from "../types";
|
|
8
|
+
|
|
9
|
+
const nestRouteFilePath = (filePath: string, nesting: string): string => {
|
|
10
|
+
return [
|
|
11
|
+
...filePath.split("/").slice(0, 2),
|
|
12
|
+
nesting,
|
|
13
|
+
...filePath.split("/").slice(2),
|
|
14
|
+
].join("/");
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export const documentationRead: DocumentationReadHook<PluginOptions> = async (
|
|
18
|
+
data,
|
|
19
|
+
{ options, helpers },
|
|
20
|
+
) => {
|
|
21
|
+
if (data.kind === "PageSnippet") {
|
|
22
|
+
const { model } = data.data;
|
|
23
|
+
|
|
24
|
+
const pageDataExtension = await getJSFileExtension({ helpers, options });
|
|
25
|
+
|
|
26
|
+
const routePath = `src/routes/${model.repeatable ? "[uid]" : model.id}`;
|
|
27
|
+
const dataFilePath = `${routePath}/+page.server.${pageDataExtension}`;
|
|
28
|
+
const componentFilePath = `${routePath}/+page.svelte`;
|
|
29
|
+
|
|
30
|
+
let dataFileContent: string;
|
|
31
|
+
if (model.repeatable) {
|
|
32
|
+
dataFileContent = source`
|
|
33
|
+
import { createClient } from "$lib/prismicio";
|
|
34
|
+
|
|
35
|
+
export const prerender = true;
|
|
36
|
+
|
|
37
|
+
export async function load({ params, fetch }) {
|
|
38
|
+
const client = createClient({ fetch });
|
|
39
|
+
|
|
40
|
+
const page = await client.getByUID("${model.id}", params.uid);
|
|
41
|
+
|
|
42
|
+
return {
|
|
43
|
+
page,
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export async function entries() {
|
|
48
|
+
const client = createClient();
|
|
49
|
+
|
|
50
|
+
const pages = await client.getAllByType("${model.id}");
|
|
51
|
+
|
|
52
|
+
return pages.map((page) => {
|
|
53
|
+
return { uid: page.uid };
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
`;
|
|
57
|
+
} else {
|
|
58
|
+
dataFileContent = source`
|
|
59
|
+
import { createClient } from "$lib/prismicio";
|
|
60
|
+
|
|
61
|
+
export const prerender = true;
|
|
62
|
+
|
|
63
|
+
export async function load({ params, fetch }) {
|
|
64
|
+
const client = createClient({ fetch });
|
|
65
|
+
|
|
66
|
+
const page = await client.getSingle("${model.id}");
|
|
67
|
+
|
|
68
|
+
return {
|
|
69
|
+
page,
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
`;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
let componentFileContent = source`
|
|
76
|
+
<script>
|
|
77
|
+
import { SliceZone } from "@prismicio/svelte";
|
|
78
|
+
|
|
79
|
+
import { components } from "$lib/slices";
|
|
80
|
+
|
|
81
|
+
export let data;
|
|
82
|
+
</script>
|
|
83
|
+
|
|
84
|
+
<SliceZone slices={data.page.data.slices} {components} />
|
|
85
|
+
`;
|
|
86
|
+
|
|
87
|
+
if (options.format) {
|
|
88
|
+
dataFileContent = await helpers.format(
|
|
89
|
+
dataFileContent,
|
|
90
|
+
helpers.joinPathFromRoot(dataFilePath),
|
|
91
|
+
{
|
|
92
|
+
includeNewlineAtEnd: false,
|
|
93
|
+
},
|
|
94
|
+
);
|
|
95
|
+
componentFileContent = await helpers.format(
|
|
96
|
+
componentFileContent,
|
|
97
|
+
helpers.joinPathFromRoot(componentFilePath),
|
|
98
|
+
{
|
|
99
|
+
prettier: {
|
|
100
|
+
plugins: ["prettier-plugin-svelte"],
|
|
101
|
+
parser: "svelte",
|
|
102
|
+
},
|
|
103
|
+
includeNewlineAtEnd: false,
|
|
104
|
+
},
|
|
105
|
+
);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
const nestedDataFilePath = nestRouteFilePath(dataFilePath, "marketing");
|
|
109
|
+
const nestedComponentFilePath = nestRouteFilePath(
|
|
110
|
+
componentFilePath,
|
|
111
|
+
"marketing",
|
|
112
|
+
);
|
|
113
|
+
|
|
114
|
+
return [
|
|
115
|
+
{
|
|
116
|
+
label: "Default",
|
|
117
|
+
content: source`
|
|
118
|
+
## Create your ${model.label}'s page data fetcher
|
|
119
|
+
|
|
120
|
+
Add a new route by creating a \`${dataFilePath}\` file. (If the route should be nested in a child directory, you can create the file in a directory, like \`${nestedDataFilePath}\`.)
|
|
121
|
+
|
|
122
|
+
Paste in this code:
|
|
123
|
+
|
|
124
|
+
${`~~~${pageDataExtension} [${dataFilePath}]\n${dataFileContent}\n~~~`}
|
|
125
|
+
|
|
126
|
+
## Create your ${model.label}'s page component
|
|
127
|
+
|
|
128
|
+
In the route's directory, create a \`${componentFilePath}\` file. (If the route should be nested in a child directory, you can create the file in a directory, like \`${nestedComponentFilePath}\`.)
|
|
129
|
+
|
|
130
|
+
Paste in this code:
|
|
131
|
+
|
|
132
|
+
${`~~~svelte [${componentFilePath}]\n${componentFileContent}\n~~~`}
|
|
133
|
+
|
|
134
|
+
Make sure all of your import paths are correct. See the [install guide](https://prismic.io/docs/svelte-install) for more information.
|
|
135
|
+
`,
|
|
136
|
+
},
|
|
137
|
+
];
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
return [];
|
|
141
|
+
};
|
package/src/plugin.ts
CHANGED
|
@@ -28,6 +28,7 @@ import { upsertSliceLibraryIndexFile } from "./lib/upsertSliceLibraryIndexFile";
|
|
|
28
28
|
import { name as pkgName } from "../package.json";
|
|
29
29
|
import { PluginOptions } from "./types";
|
|
30
30
|
|
|
31
|
+
import { documentationRead } from "./hooks/documentation-read";
|
|
31
32
|
import { projectInit } from "./hooks/project-init";
|
|
32
33
|
import { sliceCreate } from "./hooks/slice-create";
|
|
33
34
|
import { sliceSimulatorSetupRead } from "./hooks/sliceSimulator-setup-read";
|
|
@@ -284,10 +285,7 @@ export const plugin = defineSliceMachinePlugin<PluginOptions>({
|
|
|
284
285
|
// documentation:*
|
|
285
286
|
////////////////////////////////////////////////////////////////
|
|
286
287
|
|
|
287
|
-
hook("documentation:read",
|
|
288
|
-
// TODO
|
|
289
|
-
return [];
|
|
290
|
-
});
|
|
288
|
+
hook("documentation:read", documentationRead);
|
|
291
289
|
|
|
292
290
|
////////////////////////////////////////////////////////////////
|
|
293
291
|
// slice-simulator:*
|