@justanarthur/payload-www 0.3.5 → 1.2.0
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/README.md +317 -307
- package/dist/access.d.ts +2 -2
- package/dist/access.js +3 -17
- package/dist/blocks.d.ts +7 -12
- package/dist/blocks.js +24 -43
- package/dist/cli.js +201 -0
- package/dist/collections.d.ts +33 -225
- package/dist/collections.js +185 -639
- package/dist/config.d.ts +19 -105
- package/dist/config.js +257 -855
- package/dist/fields.d.ts +4 -46
- package/dist/fields.js +177 -53
- package/dist/imagehash.js +0 -15
- package/dist/import-map-provider.d.ts +0 -16
- package/dist/import-map-provider.js +0 -15
- package/dist/metadata.d.ts +24 -89
- package/dist/metadata.js +123 -255
- package/dist/pages.d.ts +37 -319
- package/dist/pages.js +349 -964
- package/dist/render-pages.d.ts +70 -565
- package/dist/render-pages.js +464 -1477
- package/dist/sitemap.d.ts +10 -0
- package/dist/sitemap.js +337 -0
- package/dist/translator.js +0 -15
- package/dist/utils.d.ts +10 -12
- package/dist/utils.js +18 -41
- package/package.json +81 -178
- package/dist/components.d.ts +0 -6
- package/dist/components.js +0 -39
- package/dist/core-access.d.ts +0 -11
- package/dist/core-access.js +0 -34
- package/dist/core-blocks.d.ts +0 -24
- package/dist/core-blocks.js +0 -79
- package/dist/core-fields.d.ts +0 -73
- package/dist/core-fields.js +0 -167
- package/dist/core-utils.d.ts +0 -16
- package/dist/core-utils.js +0 -63
- package/dist/data-collections.d.ts +0 -229
- package/dist/data-collections.js +0 -676
- package/dist/data-seed.d.ts +0 -76
- package/dist/data-seed.js +0 -212
- package/dist/data-test.d.ts +0 -30
- package/dist/data-test.js +0 -1110
- package/dist/globals.d.ts +0 -69
- package/dist/globals.js +0 -251
- package/dist/hooks.d.ts +0 -108
- package/dist/hooks.js +0 -228
- package/dist/index.d.ts +0 -6
- package/dist/index.js +0 -39
- package/dist/render-components.d.ts +0 -42
- package/dist/render-components.js +0 -154
- package/dist/render-metadata.d.ts +0 -122
- package/dist/render-metadata.js +0 -390
- package/dist/render-utils.d.ts +0 -166
- package/dist/render-utils.js +0 -398
- package/dist/seed.d.ts +0 -76
- package/dist/seed.js +0 -212
- package/dist/server.d.ts +0 -980
- package/dist/server.js +0 -2231
- package/dist/test.d.ts +0 -30
- package/dist/test.js +0 -1110
- package/dist/with-www-config.d.ts +0 -108
- package/dist/with-www-config.js +0 -1006
package/dist/access.d.ts
CHANGED
|
@@ -3,9 +3,9 @@ declare const anyone: Access;
|
|
|
3
3
|
declare const authenticated: Access;
|
|
4
4
|
declare const authenticatedOrPublished: Access;
|
|
5
5
|
import { Access as Access_wc6ft0 } from "payload";
|
|
6
|
-
declare const
|
|
6
|
+
declare const access: {
|
|
7
7
|
anyone: Access_wc6ft0;
|
|
8
8
|
authenticated: Access_wc6ft0;
|
|
9
9
|
authenticatedOrPublished: Access_wc6ft0;
|
|
10
10
|
};
|
|
11
|
-
export {
|
|
11
|
+
export { access as default, authenticatedOrPublished, authenticated, anyone };
|
package/dist/access.js
CHANGED
|
@@ -1,21 +1,6 @@
|
|
|
1
1
|
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __returnValue = (v) => v;
|
|
4
|
-
function __exportSetter(name, newValue) {
|
|
5
|
-
this[name] = __returnValue.bind(null, newValue);
|
|
6
|
-
}
|
|
7
|
-
var __export = (target, all) => {
|
|
8
|
-
for (var name in all)
|
|
9
|
-
__defProp(target, name, {
|
|
10
|
-
get: all[name],
|
|
11
|
-
enumerable: true,
|
|
12
|
-
configurable: true,
|
|
13
|
-
set: __exportSetter.bind(all, name)
|
|
14
|
-
});
|
|
15
|
-
};
|
|
16
|
-
var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
|
|
17
2
|
|
|
18
|
-
// src/
|
|
3
|
+
// src/collections/access/index.ts
|
|
19
4
|
var anyone = () => true;
|
|
20
5
|
var authenticated = ({ req: { user } }) => Boolean(user);
|
|
21
6
|
var authenticatedOrPublished = ({ req: { user } }) => {
|
|
@@ -25,7 +10,8 @@ var authenticatedOrPublished = ({ req: { user } }) => {
|
|
|
25
10
|
};
|
|
26
11
|
|
|
27
12
|
// src/exports/access.ts
|
|
28
|
-
var
|
|
13
|
+
var access = { anyone, authenticated, authenticatedOrPublished };
|
|
14
|
+
var access_default = access;
|
|
29
15
|
export {
|
|
30
16
|
access_default as default,
|
|
31
17
|
authenticatedOrPublished,
|
package/dist/blocks.d.ts
CHANGED
|
@@ -1,24 +1,19 @@
|
|
|
1
1
|
import { FC } from "react";
|
|
2
|
-
import { ImportMap, SanitizedConfig } from "payload";
|
|
2
|
+
import { ImportMap as ImportMap2, SanitizedConfig } from "payload";
|
|
3
|
+
import { ComponentType } from "react";
|
|
4
|
+
type AsyncImportMapEntry<T = ComponentType> = T | (() => Promise<{
|
|
5
|
+
default: T;
|
|
6
|
+
} | T>);
|
|
7
|
+
type AsyncImportMap = Record<string, AsyncImportMapEntry>;
|
|
3
8
|
type RenderBlocksProps = {
|
|
4
9
|
blocks: Array<{
|
|
5
10
|
blockType: string;
|
|
6
11
|
} & Record<string, unknown>>;
|
|
7
12
|
blockProps?: Record<string, unknown>;
|
|
8
|
-
importMap:
|
|
13
|
+
importMap: ImportMap2 | AsyncImportMap;
|
|
9
14
|
config: SanitizedConfig;
|
|
10
15
|
locale: string;
|
|
11
16
|
searchParams?: Record<string, string | string[] | undefined>;
|
|
12
17
|
};
|
|
13
|
-
/**
|
|
14
|
-
* Render a page's `blocks` array to React. Each block's render module
|
|
15
|
-
* is resolved via Payload's generated importMap. The host registers
|
|
16
|
-
* each block in the importMap with a key like `BlockCta#default` (use
|
|
17
|
-
* `generateImportName('block', 'cta')` to build the key).
|
|
18
|
-
*
|
|
19
|
-
* Falls back gracefully: if a block's importMap path is missing or
|
|
20
|
-
* the component is not registered, the block is skipped and a
|
|
21
|
-
* `console.warn` is logged (in dev).
|
|
22
|
-
*/
|
|
23
18
|
declare const RenderBlocks: FC<RenderBlocksProps>;
|
|
24
19
|
export { RenderBlocks as default, RenderBlocksProps, RenderBlocks };
|
package/dist/blocks.js
CHANGED
|
@@ -1,63 +1,44 @@
|
|
|
1
1
|
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __returnValue = (v) => v;
|
|
4
|
-
function __exportSetter(name, newValue) {
|
|
5
|
-
this[name] = __returnValue.bind(null, newValue);
|
|
6
|
-
}
|
|
7
|
-
var __export = (target, all) => {
|
|
8
|
-
for (var name in all)
|
|
9
|
-
__defProp(target, name, {
|
|
10
|
-
get: all[name],
|
|
11
|
-
enumerable: true,
|
|
12
|
-
configurable: true,
|
|
13
|
-
set: __exportSetter.bind(all, name)
|
|
14
|
-
});
|
|
15
|
-
};
|
|
16
|
-
var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
|
|
17
2
|
|
|
18
|
-
// src/
|
|
3
|
+
// src/render/getFromImportMap.ts
|
|
19
4
|
function getFromImportMap(key, importMap) {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
5
|
+
if (!key)
|
|
6
|
+
return;
|
|
7
|
+
const entry = importMap[key.includes("#") ? key : `${key}#default`];
|
|
8
|
+
if (entry == null)
|
|
9
|
+
return;
|
|
10
|
+
if (typeof entry === "function") {
|
|
11
|
+
return entry().then((mod) => {
|
|
12
|
+
if (typeof mod === "function")
|
|
13
|
+
return mod;
|
|
14
|
+
const modObj = mod;
|
|
15
|
+
return modObj.default ?? mod;
|
|
16
|
+
});
|
|
32
17
|
}
|
|
18
|
+
return entry;
|
|
33
19
|
}
|
|
34
20
|
|
|
21
|
+
// package.json
|
|
22
|
+
var name = "@justanarthur/payload-www";
|
|
23
|
+
|
|
35
24
|
// src/render/blocks/renderBlocks.tsx
|
|
36
25
|
import { jsx, Fragment } from "react/jsx-runtime";
|
|
37
|
-
var
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
config,
|
|
41
|
-
importMap,
|
|
42
|
-
locale,
|
|
43
|
-
searchParams
|
|
44
|
-
}) => {
|
|
45
|
-
if (!blocks || !Array.isArray(blocks) || blocks.length === 0) {
|
|
46
|
-
console.log("[WWW] render/blocks:RenderBlocks no blocks (locale=", locale, ")");
|
|
26
|
+
var DEFAULT_BLOCK_PATH_PREFIX = "@/components/blocks";
|
|
27
|
+
var RenderBlocks = async ({ blocks, blockProps, config, importMap, locale, searchParams }) => {
|
|
28
|
+
if (!blocks || !Array.isArray(blocks) || blocks.length === 0)
|
|
47
29
|
return null;
|
|
48
|
-
}
|
|
49
|
-
console.log("[WWW] render/blocks:RenderBlocks rendering count=", blocks.length, "locale=", locale);
|
|
50
30
|
const rendered = [];
|
|
51
31
|
for (let i = 0;i < blocks.length; i++) {
|
|
52
32
|
const block = blocks[i];
|
|
53
33
|
const { blockType } = block;
|
|
54
|
-
const
|
|
55
|
-
const
|
|
34
|
+
const blockConfig = (config.blocks ?? []).find((b) => b.slug === blockType);
|
|
35
|
+
const customPath = blockConfig?.custom?.[name]?.path;
|
|
36
|
+
const importMapPath = (typeof customPath === "string" ? customPath : null) ?? `${DEFAULT_BLOCK_PATH_PREFIX}/${blockType}`;
|
|
37
|
+
const Block = await getFromImportMap(importMapPath, importMap);
|
|
56
38
|
if (!Block) {
|
|
57
39
|
console.warn(`[WWW] render/blocks:RenderBlocks no block for type=${blockType} importMapPath=${importMapPath} (locale=${locale})`);
|
|
58
40
|
continue;
|
|
59
41
|
}
|
|
60
|
-
console.log("[WWW] render/blocks:RenderBlocks [", i, "] blockType=", blockType, "importMapPath=", importMapPath);
|
|
61
42
|
rendered.push(/* @__PURE__ */ jsx(Block, {
|
|
62
43
|
index: i,
|
|
63
44
|
...blockProps,
|
package/dist/cli.js
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { createRequire } from "node:module";
|
|
3
|
+
var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
4
|
+
|
|
5
|
+
// src/cli/index.ts
|
|
6
|
+
import { register } from "tsx/esm/api";
|
|
7
|
+
import path from "node:path";
|
|
8
|
+
import { existsSync } from "node:fs";
|
|
9
|
+
import { pathToFileURL } from "node:url";
|
|
10
|
+
|
|
11
|
+
// package.json
|
|
12
|
+
var name = "@justanarthur/payload-www";
|
|
13
|
+
|
|
14
|
+
// src/cli/generateAsyncImportmap.ts
|
|
15
|
+
function getCustomPath(custom, pkg) {
|
|
16
|
+
const v = custom?.[pkg]?.path;
|
|
17
|
+
return typeof v === "string" ? v : undefined;
|
|
18
|
+
}
|
|
19
|
+
function splitKey(key) {
|
|
20
|
+
const hashIdx = key.indexOf("#");
|
|
21
|
+
if (hashIdx >= 0) {
|
|
22
|
+
return {
|
|
23
|
+
filePath: key.slice(0, hashIdx),
|
|
24
|
+
exportName: key.slice(hashIdx + 1) || "default",
|
|
25
|
+
fullKey: key
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
return {
|
|
29
|
+
filePath: key,
|
|
30
|
+
exportName: "default",
|
|
31
|
+
fullKey: `${key}#default`
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
function defaultBlockPath(slug) {
|
|
35
|
+
return `@/components/blocks/${slug}#default`;
|
|
36
|
+
}
|
|
37
|
+
async function generateAsyncImportmap(config, options) {
|
|
38
|
+
const pkg = options.packageName ?? name;
|
|
39
|
+
const blocks = config.blocks ?? [] ?? [];
|
|
40
|
+
const collections = config.collections ?? [] ?? [];
|
|
41
|
+
const globals = config.globals ?? [] ?? [];
|
|
42
|
+
const keys = new Set;
|
|
43
|
+
for (const block of blocks) {
|
|
44
|
+
if (!block.slug)
|
|
45
|
+
continue;
|
|
46
|
+
const explicit = getCustomPath(block.custom, pkg);
|
|
47
|
+
const key = explicit ?? defaultBlockPath(block.slug);
|
|
48
|
+
keys.add(key);
|
|
49
|
+
}
|
|
50
|
+
for (const item of [...collections, ...globals]) {
|
|
51
|
+
const explicit = getCustomPath(item.custom, pkg);
|
|
52
|
+
if (explicit)
|
|
53
|
+
keys.add(explicit);
|
|
54
|
+
}
|
|
55
|
+
const sortedKeys = [...keys].sort();
|
|
56
|
+
const lines = [];
|
|
57
|
+
lines.push("// This file is generated by `payload-www generate:async-importmap`.");
|
|
58
|
+
lines.push("// Do not edit by hand — re-run the generator after Payload config changes.");
|
|
59
|
+
lines.push("");
|
|
60
|
+
lines.push("/** @type import('payload').ImportMap */");
|
|
61
|
+
lines.push("export const asyncImportMap = {");
|
|
62
|
+
for (const key of sortedKeys) {
|
|
63
|
+
const { filePath, exportName, fullKey } = splitKey(key);
|
|
64
|
+
const jsonKey = JSON.stringify(fullKey);
|
|
65
|
+
lines.push(` ${jsonKey}: () => import(${JSON.stringify(filePath)}).then((m) => ({ default: m.${exportName} })),`);
|
|
66
|
+
}
|
|
67
|
+
lines.push("}");
|
|
68
|
+
lines.push("");
|
|
69
|
+
const output = lines.join(`
|
|
70
|
+
`);
|
|
71
|
+
const { writeFile, mkdir } = await import("node:fs/promises");
|
|
72
|
+
const { dirname } = await import("node:path");
|
|
73
|
+
await mkdir(dirname(options.output), { recursive: true });
|
|
74
|
+
await writeFile(options.output, output, "utf-8");
|
|
75
|
+
return {
|
|
76
|
+
entries: sortedKeys.length,
|
|
77
|
+
output: options.output
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
// src/cli/index.ts
|
|
82
|
+
register();
|
|
83
|
+
function printHelp() {
|
|
84
|
+
console.log(`payload-www generate:async-importmap
|
|
85
|
+
|
|
86
|
+
Generate an async-importMap.ts containing only the render-path dependencies
|
|
87
|
+
(blocks + collection/global renderers) used by the public render path.
|
|
88
|
+
|
|
89
|
+
Usage:
|
|
90
|
+
payload-www generate:async-importmap --config-path <path> --output <path>
|
|
91
|
+
|
|
92
|
+
Options:
|
|
93
|
+
--config-path <path> Path to the Payload config file (TS or JS).
|
|
94
|
+
Resolved relative to the current working directory.
|
|
95
|
+
--output <path> Output file path. Created if missing.
|
|
96
|
+
--package-name <name> Custom-package key for the render-dependency lookup.
|
|
97
|
+
Defaults to "@justanarthur/payload-www".
|
|
98
|
+
--help, -h Show this help.
|
|
99
|
+
|
|
100
|
+
Example:
|
|
101
|
+
payload-www generate:async-importmap \\
|
|
102
|
+
--config-path apps/www/payload.config.ts \\
|
|
103
|
+
--output apps/www/app/\\(payload\\)/admin/asyncImportMap.ts
|
|
104
|
+
`);
|
|
105
|
+
}
|
|
106
|
+
function parseArgs(argv) {
|
|
107
|
+
const args = {
|
|
108
|
+
configPath: "",
|
|
109
|
+
output: "",
|
|
110
|
+
help: false
|
|
111
|
+
};
|
|
112
|
+
for (let i = 0;i < argv.length; i++) {
|
|
113
|
+
const a = argv[i];
|
|
114
|
+
if (a === "--help" || a === "-h") {
|
|
115
|
+
args.help = true;
|
|
116
|
+
continue;
|
|
117
|
+
}
|
|
118
|
+
if (a === "--config-path") {
|
|
119
|
+
args.configPath = argv[++i] ?? "";
|
|
120
|
+
continue;
|
|
121
|
+
}
|
|
122
|
+
if (a === "--output") {
|
|
123
|
+
args.output = argv[++i] ?? "";
|
|
124
|
+
continue;
|
|
125
|
+
}
|
|
126
|
+
if (a === "--package-name") {
|
|
127
|
+
args.packageName = argv[++i] ?? "";
|
|
128
|
+
continue;
|
|
129
|
+
}
|
|
130
|
+
if (a?.startsWith("--config-path=")) {
|
|
131
|
+
args.configPath = a.slice("--config-path=".length);
|
|
132
|
+
continue;
|
|
133
|
+
}
|
|
134
|
+
if (a?.startsWith("--output=")) {
|
|
135
|
+
args.output = a.slice("--output=".length);
|
|
136
|
+
continue;
|
|
137
|
+
}
|
|
138
|
+
if (a?.startsWith("--package-name=")) {
|
|
139
|
+
args.packageName = a.slice("--package-name=".length);
|
|
140
|
+
continue;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
return args;
|
|
144
|
+
}
|
|
145
|
+
async function main() {
|
|
146
|
+
const args = parseArgs(process.argv.slice(2));
|
|
147
|
+
if (args.help) {
|
|
148
|
+
printHelp();
|
|
149
|
+
process.exit(0);
|
|
150
|
+
}
|
|
151
|
+
if (!args.configPath || !args.output) {
|
|
152
|
+
console.error(`[payload-www] --config-path and --output are required.
|
|
153
|
+
`);
|
|
154
|
+
printHelp();
|
|
155
|
+
process.exit(1);
|
|
156
|
+
}
|
|
157
|
+
const cwd = process.cwd();
|
|
158
|
+
const absoluteConfigPath = path.isAbsolute(args.configPath) ? args.configPath : path.resolve(cwd, args.configPath);
|
|
159
|
+
if (!existsSync(absoluteConfigPath)) {
|
|
160
|
+
console.error(`[payload-www] config file not found: ${absoluteConfigPath}`);
|
|
161
|
+
process.exit(1);
|
|
162
|
+
}
|
|
163
|
+
let configModule;
|
|
164
|
+
try {
|
|
165
|
+
configModule = await import(pathToFileURL(absoluteConfigPath).href);
|
|
166
|
+
} catch (err) {
|
|
167
|
+
console.error(`[payload-www] failed to load config at ${absoluteConfigPath}:`);
|
|
168
|
+
console.error(err);
|
|
169
|
+
process.exit(1);
|
|
170
|
+
}
|
|
171
|
+
let config = configModule.default ?? configModule;
|
|
172
|
+
config = await config;
|
|
173
|
+
if (!config || typeof config !== "object") {
|
|
174
|
+
console.error("[payload-www] loaded config is empty or not an object.");
|
|
175
|
+
process.exit(1);
|
|
176
|
+
}
|
|
177
|
+
if (process.env.PAYLOAD_WWW_DEBUG === "1") {
|
|
178
|
+
const { writeFileSync } = await import("node:fs");
|
|
179
|
+
writeFileSync("/tmp/payload-config-dump.json", JSON.stringify(config, (k, v) => typeof v === "function" ? "[function]" : v, 2).slice(0, 200000));
|
|
180
|
+
const cfg = config;
|
|
181
|
+
console.error("[payload-www DEBUG] blocks:", cfg.blocks?.length ?? 0);
|
|
182
|
+
console.error("[payload-www DEBUG] collections:", cfg.collections?.length ?? 0);
|
|
183
|
+
console.error("[payload-www DEBUG] globals:", cfg.globals?.length ?? 0);
|
|
184
|
+
console.error("[payload-www DEBUG] keys:", Object.keys(config).slice(0, 30).join(","));
|
|
185
|
+
const firstBlock = cfg.blocks?.[0] ?? null;
|
|
186
|
+
if (firstBlock) {
|
|
187
|
+
console.error("[payload-www DEBUG] first block slug:", firstBlock.slug);
|
|
188
|
+
console.error("[payload-www DEBUG] first block custom:", JSON.stringify(firstBlock.custom));
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
const result = await generateAsyncImportmap(config, {
|
|
192
|
+
output: path.isAbsolute(args.output) ? args.output : path.resolve(cwd, args.output),
|
|
193
|
+
...args.packageName ? { packageName: args.packageName } : {}
|
|
194
|
+
});
|
|
195
|
+
console.log(`[payload-www] wrote ${result.entries} entries to ${result.output}`);
|
|
196
|
+
}
|
|
197
|
+
main().catch((err) => {
|
|
198
|
+
console.error("[payload-www] unhandled error:");
|
|
199
|
+
console.error(err);
|
|
200
|
+
process.exit(1);
|
|
201
|
+
});
|
package/dist/collections.d.ts
CHANGED
|
@@ -1,229 +1,37 @@
|
|
|
1
|
-
import {
|
|
2
|
-
type
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
*/
|
|
8
|
-
collectionSlug: string;
|
|
9
|
-
/**
|
|
10
|
-
* URL path prefix for this collection's rendered URLs. Pages use
|
|
11
|
-
* `''` (mounted at root); Posts use `'/posts'`. Leading slash,
|
|
12
|
-
* no trailing slash — same convention as
|
|
13
|
-
* `createSitemapFile.urlPrefixes`.
|
|
14
|
-
*/
|
|
15
|
-
urlPathPrefix?: string;
|
|
16
|
-
/**
|
|
17
|
-
* Sitemap tag the collection's revalidation hook invalidates on
|
|
18
|
-
* every save. Defaults to `${collectionSlug}-sitemap`. Pass
|
|
19
|
-
* `false` to opt out (collections without a sitemap handler).
|
|
20
|
-
*/
|
|
21
|
-
sitemapTag?: string | false;
|
|
22
|
-
/**
|
|
23
|
-
* Locale prefix mode — mirrors next-intl's `localePrefix`.
|
|
24
|
-
* Defaults to `'always'` (preserves legacy behavior).
|
|
25
|
-
*/
|
|
26
|
-
localePrefix?: LocalePrefixMode;
|
|
27
|
-
/**
|
|
28
|
-
* Default locale for `localePrefix: 'as-needed'`. Falls back to
|
|
29
|
-
* `req.payload.config.localization.defaultLocale` at request time
|
|
30
|
-
* when omitted.
|
|
31
|
-
*/
|
|
32
|
-
defaultLocale?: string;
|
|
33
|
-
/**
|
|
34
|
-
* Path invalidation strategy. Default: `'url'` — fans out
|
|
35
|
-
* `revalidatePath` for every locale × every slug. Set to
|
|
36
|
-
* `'tag-only'` for collections without a URL (e.g. `staticPages`
|
|
37
|
-
* — addressed by a `kind` discriminator, not a slug). Tag-only
|
|
38
|
-
* mode still fires the per-collection tag (via `sitemapTag`) and
|
|
39
|
-
* the per-id tag (`collection_<slug>_<id>`).
|
|
40
|
-
*/
|
|
41
|
-
pathMode?: "url" | "tag-only";
|
|
42
|
-
};
|
|
43
|
-
declare const HOME_PAGE_SLUG = "";
|
|
44
|
-
declare const PAGES_SLUG = "pages";
|
|
45
|
-
type CreatePagesCollectionOptions = {
|
|
46
|
-
/**
|
|
47
|
-
* Blocks the Pages collection accepts.
|
|
48
|
-
*/
|
|
49
|
-
blocks: Block[];
|
|
50
|
-
/**
|
|
51
|
-
* Optional override for the collection slug. Default: `'pages'`.
|
|
52
|
-
* Hosts that want a different slug (e.g. `'site_pages'`) pass
|
|
53
|
-
* it here. The lib's Header / Footer `linkRelationTo` default
|
|
54
|
-
* uses `'pages'` — combine this with a matching
|
|
55
|
-
* `linkRelationTo` to keep nav links targeting the right
|
|
56
|
-
* collection.
|
|
57
|
-
*/
|
|
58
|
-
slug?: string;
|
|
59
|
-
/**
|
|
60
|
-
* Optional override for the `custom.path` Payload uses to resolve
|
|
61
|
-
* the page's render module. Default: the lib's `PAGES_RENDER_PATH`
|
|
62
|
-
* (a Server Component that calls `RenderBlocks`). Use this when
|
|
63
|
-
* you've defined your own Server Component for the collection.
|
|
64
|
-
*/
|
|
65
|
-
renderPath?: string;
|
|
66
|
-
/**
|
|
67
|
-
* Locale prefix mode for path invalidation. Defaults to `'always'`
|
|
68
|
-
* (preserves current behavior). Set to `'as-needed'` when the host
|
|
69
|
-
* uses next-intl `localePrefix: 'as-needed'` — otherwise the hook
|
|
70
|
-
* invalidates paths the public routes don't use.
|
|
71
|
-
*/
|
|
72
|
-
localePrefix?: CreateRevalidateCollectionHookOptions["localePrefix"];
|
|
73
|
-
/**
|
|
74
|
-
* Default locale for prefix skipping. Falls back to
|
|
75
|
-
* `req.payload.config.localization.defaultLocale` at request time
|
|
76
|
-
* when omitted.
|
|
77
|
-
*/
|
|
78
|
-
defaultLocale?: CreateRevalidateCollectionHookOptions["defaultLocale"];
|
|
79
|
-
/**
|
|
80
|
-
* Enable nested (hierarchical) slugs. When `true`, the slug field
|
|
81
|
-
* additionally accepts the `_` nesting divider (so `about_us`
|
|
82
|
-
* renders at `/about/us`) and the admin description documents the
|
|
83
|
-
* convention. Pair with `createCollectionPageExports({ nested: true })`
|
|
84
|
-
* on the matching route. Default: `false` (flat, hyphen-only slugs).
|
|
85
|
-
*/
|
|
86
|
-
nested?: boolean;
|
|
87
|
-
};
|
|
88
|
-
declare const createPagesCollection: (blocks: Block[], options?: Omit<CreatePagesCollectionOptions, "blocks">) => CollectionConfig;
|
|
89
|
-
import { CollectionConfig as CollectionConfig2 } from "payload";
|
|
90
|
-
declare const POSTS_SLUG = "posts";
|
|
91
|
-
type CreatePostsCollectionOptions = {
|
|
92
|
-
/**
|
|
93
|
-
* Optional override for the collection slug. Default: `'posts'`.
|
|
94
|
-
* Hosts that want a different slug (e.g. `'articles'` or `'blog'`)
|
|
95
|
-
* pass it here. Combine with the page route's URL convention and
|
|
96
|
-
* the lib's translator plugin's `collections` list.
|
|
97
|
-
*/
|
|
98
|
-
slug?: string;
|
|
99
|
-
/**
|
|
100
|
-
* Override the `custom.path` Payload uses to resolve the post's
|
|
101
|
-
* render module. Defaults to the lib's `POSTS_RENDER_PATH`
|
|
102
|
-
* (the lib's `<PostsPage>` Server Component, which renders
|
|
103
|
-
* `title` + `excerpt` + Lexical `content`). Hosts that want a
|
|
104
|
-
* custom render pass their own Server Component's import path
|
|
105
|
-
* here (e.g. `'@/blog/Post#default'`).
|
|
106
|
-
*/
|
|
107
|
-
renderPath?: string;
|
|
108
|
-
/**
|
|
109
|
-
* Locale prefix mode for path invalidation. Defaults to `'always'`.
|
|
110
|
-
* Set to `'as-needed'` when the host uses next-intl
|
|
111
|
-
* `localePrefix: 'as-needed'` — otherwise the hook invalidates
|
|
112
|
-
* paths the public routes don't use.
|
|
113
|
-
*/
|
|
114
|
-
localePrefix?: "always" | "as-needed" | "never";
|
|
115
|
-
/**
|
|
116
|
-
* Default locale for prefix skipping. Falls back to
|
|
117
|
-
* `req.payload.config.localization.defaultLocale` at request time
|
|
118
|
-
* when omitted.
|
|
119
|
-
*/
|
|
120
|
-
defaultLocale?: string;
|
|
1
|
+
import { CollectionConfig, Field, GlobalConfig } from "payload";
|
|
2
|
+
type CreateWWWCollectionArgs<IsGlobalConfig extends boolean> = {
|
|
3
|
+
slug: string;
|
|
4
|
+
renderPath: string;
|
|
5
|
+
isGlobalConfig?: IsGlobalConfig;
|
|
6
|
+
isDraft?: boolean;
|
|
121
7
|
};
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
* plugin has a second localized collection to translate.
|
|
131
|
-
*/
|
|
132
|
-
declare const createPostsCollection: (options?: CreatePostsCollectionOptions) => CollectionConfig2;
|
|
133
|
-
import { Block as Block2, CollectionConfig as CollectionConfig3 } from "payload";
|
|
134
|
-
declare const STATIC_PAGES_SLUG = "staticPages";
|
|
135
|
-
type CreateStaticPagesCollectionOptions = {
|
|
136
|
-
/**
|
|
137
|
-
* Blocks the StaticPages collection accepts. Hosts pass the same
|
|
138
|
-
* `blocks` they use for `createPagesCollection` (or a smaller
|
|
139
|
-
* subset — e.g. just `pageHeroBlock` + `ctaBlock` + `featureGridBlock`).
|
|
140
|
-
* The lib does not curate a separate block set for system pages.
|
|
141
|
-
*/
|
|
142
|
-
blocks: Block2[];
|
|
8
|
+
declare function createWWWCollectionGlobal<
|
|
9
|
+
IsGlobalConfig extends boolean = false,
|
|
10
|
+
Config = IsGlobalConfig extends true ? GlobalConfig : CollectionConfig
|
|
11
|
+
>(fields: Field[], { slug: collectionSlug, renderPath, isGlobalConfig, isDraft }: CreateWWWCollectionArgs<IsGlobalConfig>): Config;
|
|
12
|
+
import { CollectionAfterChangeHook, CollectionAfterDeleteHook, GlobalAfterChangeHook } from "payload";
|
|
13
|
+
declare function createRevalidateCollectionGlobalHook(): {
|
|
14
|
+
afterChange: (CollectionAfterChangeHook & CollectionAfterDeleteHook) | GlobalAfterChangeHook;
|
|
15
|
+
afterDelete: (CollectionAfterChangeHook & CollectionAfterDeleteHook) | GlobalAfterChangeHook;
|
|
143
16
|
};
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
renderPath?: string;
|
|
152
|
-
/**
|
|
153
|
-
* Collection slugs the nav's link fields can reference. Required
|
|
154
|
-
* by Payload 3.85 — empty `relationTo` arrays are rejected.
|
|
155
|
-
* Defaults to `['pages']` (the lib's Pages collection). Pass a
|
|
156
|
-
* different list when your host has additional linkable collections.
|
|
157
|
-
*/
|
|
158
|
-
linkRelationTo?: string[];
|
|
159
|
-
/**
|
|
160
|
-
* Extra fields appended to each `navColumn` link — e.g. a
|
|
161
|
-
* `description` text field or a `navHover` group for a mega-menu.
|
|
162
|
-
* Lets hosts enrich the column-link schema without redefining the
|
|
163
|
-
* whole nav.
|
|
164
|
-
*/
|
|
165
|
-
navColumnLinkFields?: Field[];
|
|
166
|
-
/**
|
|
167
|
-
* Extra fields appended to each top-level `navItem` link.
|
|
168
|
-
*/
|
|
169
|
-
navItemLinkFields?: Field[];
|
|
170
|
-
};
|
|
171
|
-
/**
|
|
172
|
-
* Build the Header global. The lib's default shape: a `nav` blocks
|
|
173
|
-
* field with two block types — `navColumn` (a titled group of links)
|
|
174
|
-
* and `navItem` (a single link).
|
|
175
|
-
*/
|
|
176
|
-
declare const createHeaderGlobal: (options?: CreateHeaderGlobalOptions) => GlobalConfig;
|
|
177
|
-
import { Field as Field2, GlobalConfig as GlobalConfig2 } from "payload";
|
|
178
|
-
type CreateFooterGlobalOptions = {
|
|
179
|
-
/**
|
|
180
|
-
* Optional override for the `custom.path` Payload uses to resolve
|
|
181
|
-
* the footer's render module. Default: the lib's `FOOTER_RENDER_PATH`.
|
|
182
|
-
*/
|
|
183
|
-
renderPath?: string;
|
|
184
|
-
/**
|
|
185
|
-
* Collection slugs the nav's link fields can reference. Required
|
|
186
|
-
* by Payload 3.85 — empty `relationTo` arrays are rejected.
|
|
187
|
-
* Defaults to `['pages']` (the lib's Pages collection). Pass a
|
|
188
|
-
* different list when your host has additional linkable collections.
|
|
189
|
-
*/
|
|
190
|
-
linkRelationTo?: string[];
|
|
191
|
-
/**
|
|
192
|
-
* Extra fields appended to each `navColumn` link — e.g. a
|
|
193
|
-
* `description` text field. Lets hosts enrich the column-link
|
|
194
|
-
* schema without redefining the whole nav.
|
|
195
|
-
*/
|
|
196
|
-
navColumnLinkFields?: Field2[];
|
|
197
|
-
/**
|
|
198
|
-
* Extra fields appended to each top-level `navItem` link.
|
|
199
|
-
*/
|
|
200
|
-
navItemLinkFields?: Field2[];
|
|
17
|
+
type CollectionGlobalLocaleIdentifiersArgs = ({
|
|
18
|
+
collectionSlug: string;
|
|
19
|
+
slug: string;
|
|
20
|
+
} | {
|
|
21
|
+
globalSlug: string;
|
|
22
|
+
}) & {
|
|
23
|
+
locale: string;
|
|
201
24
|
};
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
}): string | null;
|
|
214
|
-
import { Block as Block_129qi5 } from "payload";
|
|
215
|
-
import { CollectionConfig as CollectionConfig_j7kwbk } from "payload";
|
|
216
|
-
import { GlobalConfig as GlobalConfig_fuin17 } from "payload";
|
|
217
|
-
declare const _default: {
|
|
218
|
-
createPagesCollection: (blocks: Block_129qi5[], options?: Omit<CreatePagesCollectionOptions, "blocks">) => CollectionConfig_j7kwbk;
|
|
219
|
-
createPostsCollection: (options?: CreatePostsCollectionOptions) => CollectionConfig_j7kwbk;
|
|
220
|
-
createStaticPagesCollection: (blocks: Block_129qi5[]) => CollectionConfig_j7kwbk;
|
|
221
|
-
createHeaderGlobal: (options?: CreateHeaderGlobalOptions) => GlobalConfig_fuin17;
|
|
222
|
-
createFooterGlobal: (options?: CreateFooterGlobalOptions) => GlobalConfig_fuin17;
|
|
223
|
-
generatePreviewPath: typeof generatePreviewPath;
|
|
224
|
-
HOME_PAGE_SLUG: string;
|
|
225
|
-
PAGES_SLUG: string;
|
|
226
|
-
POSTS_SLUG: string;
|
|
227
|
-
STATIC_PAGES_SLUG: string;
|
|
25
|
+
declare function createCollectionCacheKey(args: CollectionGlobalLocaleIdentifiersArgs): string;
|
|
26
|
+
import { SanitizedConfig } from "payload";
|
|
27
|
+
import { JsonObject as JsonObject_wrdbbt } from "payload";
|
|
28
|
+
declare function queryDoc(args: CollectionGlobalLocaleIdentifiersArgs, { config: configPromise }: {
|
|
29
|
+
config: Promise<SanitizedConfig>;
|
|
30
|
+
}): Promise<JsonObject_wrdbbt | null>;
|
|
31
|
+
declare const collections: {
|
|
32
|
+
createWWWCollectionGlobal: typeof createWWWCollectionGlobal;
|
|
33
|
+
createRevalidateCollectionGlobalHook: typeof createRevalidateCollectionGlobalHook;
|
|
34
|
+
createCollectionCacheKey: typeof createCollectionCacheKey;
|
|
35
|
+
queryDoc: typeof queryDoc;
|
|
228
36
|
};
|
|
229
|
-
export {
|
|
37
|
+
export { queryDoc, collections as default, createWWWCollectionGlobal, createRevalidateCollectionGlobalHook, createCollectionCacheKey };
|