@justanarthur/payload-www 0.1.1
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 +381 -0
- package/dist/access.d.ts +11 -0
- package/dist/access.js +34 -0
- package/dist/blocks.d.ts +24 -0
- package/dist/blocks.js +75 -0
- package/dist/collections.d.ts +200 -0
- package/dist/collections.js +625 -0
- package/dist/components.d.ts +6 -0
- package/dist/components.js +38 -0
- package/dist/config.d.ts +100 -0
- package/dist/config.js +914 -0
- package/dist/core-access.d.ts +11 -0
- package/dist/core-access.js +34 -0
- package/dist/core-blocks.d.ts +24 -0
- package/dist/core-blocks.js +75 -0
- package/dist/core-fields.d.ts +36 -0
- package/dist/core-fields.js +134 -0
- package/dist/core-utils.d.ts +16 -0
- package/dist/core-utils.js +59 -0
- package/dist/data-collections.d.ts +200 -0
- package/dist/data-collections.js +625 -0
- package/dist/data-seed.d.ts +76 -0
- package/dist/data-seed.js +212 -0
- package/dist/data-test.d.ts +30 -0
- package/dist/data-test.js +1018 -0
- package/dist/fields.d.ts +36 -0
- package/dist/fields.js +134 -0
- package/dist/globals.d.ts +48 -0
- package/dist/globals.js +228 -0
- package/dist/hooks.d.ts +108 -0
- package/dist/hooks.js +196 -0
- package/dist/imagehash.d.ts +3 -0
- package/dist/imagehash.js +24 -0
- package/dist/import-map-provider.d.ts +20 -0
- package/dist/import-map-provider.js +26 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +38 -0
- package/dist/metadata.d.ts +122 -0
- package/dist/metadata.js +335 -0
- package/dist/pages.d.ts +323 -0
- package/dist/pages.js +1016 -0
- package/dist/render-components.d.ts +42 -0
- package/dist/render-components.js +144 -0
- package/dist/render-metadata.d.ts +122 -0
- package/dist/render-metadata.js +335 -0
- package/dist/render-pages.d.ts +574 -0
- package/dist/render-pages.js +1450 -0
- package/dist/render-utils.d.ts +158 -0
- package/dist/render-utils.js +341 -0
- package/dist/seed.d.ts +76 -0
- package/dist/seed.js +212 -0
- package/dist/server.d.ts +922 -0
- package/dist/server.js +2055 -0
- package/dist/test.d.ts +30 -0
- package/dist/test.js +1018 -0
- package/dist/translator.d.ts +2 -0
- package/dist/translator.js +24 -0
- package/dist/utils.d.ts +16 -0
- package/dist/utils.js +59 -0
- package/dist/with-www-config.d.ts +100 -0
- package/dist/with-www-config.js +914 -0
- package/package.json +246 -0
package/dist/fields.d.ts
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { Field, GroupField } from "payload";
|
|
2
|
+
type LinkAppearances = "default" | "outline";
|
|
3
|
+
declare const appearanceOptions: Record<LinkAppearances, {
|
|
4
|
+
label: string;
|
|
5
|
+
value: string;
|
|
6
|
+
}>;
|
|
7
|
+
type LinkOptions = {
|
|
8
|
+
appearances?: LinkAppearances[] | false;
|
|
9
|
+
disableLabel?: boolean;
|
|
10
|
+
/**
|
|
11
|
+
* Collection slugs the link can reference. Payload 3.85 rejects
|
|
12
|
+
* empty arrays, so the lib defaults to `['pages']` (its own Pages
|
|
13
|
+
* collection). Hosts that reference different collections pass
|
|
14
|
+
* their own list.
|
|
15
|
+
*/
|
|
16
|
+
relationTo?: string[];
|
|
17
|
+
/** Mark the text fields as `localized: true`. */
|
|
18
|
+
localized?: boolean;
|
|
19
|
+
/** Deep-merge into the resulting group. */
|
|
20
|
+
overrides?: Partial<GroupField>;
|
|
21
|
+
/** Legacy alias for the host's custom field overrides. */
|
|
22
|
+
linkOverrides?: Partial<GroupField>;
|
|
23
|
+
};
|
|
24
|
+
declare const link: (options?: LinkOptions) => Field;
|
|
25
|
+
import { Field as Field2 } from "payload";
|
|
26
|
+
declare const linkGroup: (options?: LinkOptions) => Field2;
|
|
27
|
+
import { Field as Field_14espm } from "payload";
|
|
28
|
+
declare const _default: {
|
|
29
|
+
link: (options?: LinkOptions) => Field_14espm;
|
|
30
|
+
linkGroup: (options?: LinkOptions) => Field_14espm;
|
|
31
|
+
appearanceOptions: Record<LinkAppearances, {
|
|
32
|
+
label: string;
|
|
33
|
+
value: string;
|
|
34
|
+
}>;
|
|
35
|
+
};
|
|
36
|
+
export { linkGroup, link, _default as default, appearanceOptions, LinkOptions, LinkAppearances };
|
package/dist/fields.js
ADDED
|
@@ -0,0 +1,134 @@
|
|
|
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
|
+
|
|
18
|
+
// src/config/constants.ts
|
|
19
|
+
var PAGES_RENDER_PATH = "@justanarthur/payload-www/render-pages#PagesPage";
|
|
20
|
+
var POSTS_RENDER_PATH = "@justanarthur/payload-www/render-pages#PostsPage";
|
|
21
|
+
var HEADER_RENDER_PATH = "@justanarthur/payload-www/render-pages#HeaderPage";
|
|
22
|
+
var FOOTER_RENDER_PATH = "@justanarthur/payload-www/render-pages#FooterPage";
|
|
23
|
+
var LIVE_PREVIEW_LISTENER_PATH = "@justanarthur/payload-www/render-components#LivePreviewListener";
|
|
24
|
+
var PAGES_SLUG = "pages";
|
|
25
|
+
var POSTS_SLUG = "posts";
|
|
26
|
+
var STATIC_PAGES_SLUG = "staticPages";
|
|
27
|
+
|
|
28
|
+
// src/core/fields/link.ts
|
|
29
|
+
var appearanceOptions = {
|
|
30
|
+
default: { label: "Default", value: "default" },
|
|
31
|
+
outline: { label: "Outline", value: "outline" }
|
|
32
|
+
};
|
|
33
|
+
var link = (options = {}) => {
|
|
34
|
+
const {
|
|
35
|
+
appearances,
|
|
36
|
+
disableLabel = false,
|
|
37
|
+
relationTo = [PAGES_SLUG],
|
|
38
|
+
localized = false,
|
|
39
|
+
overrides = {}
|
|
40
|
+
} = options;
|
|
41
|
+
const result = {
|
|
42
|
+
name: "link",
|
|
43
|
+
type: "group",
|
|
44
|
+
admin: { hideGutter: true },
|
|
45
|
+
fields: [
|
|
46
|
+
{
|
|
47
|
+
type: "row",
|
|
48
|
+
fields: [
|
|
49
|
+
{
|
|
50
|
+
name: "type",
|
|
51
|
+
type: "radio",
|
|
52
|
+
admin: { layout: "horizontal", width: "50%" },
|
|
53
|
+
defaultValue: "reference",
|
|
54
|
+
options: [
|
|
55
|
+
{ label: "Internal link", value: "reference" },
|
|
56
|
+
{ label: "Custom URL", value: "custom" }
|
|
57
|
+
]
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
name: "newTab",
|
|
61
|
+
type: "checkbox",
|
|
62
|
+
admin: { style: { alignSelf: "flex-end" }, width: "50%" },
|
|
63
|
+
label: "Open in new tab"
|
|
64
|
+
}
|
|
65
|
+
]
|
|
66
|
+
}
|
|
67
|
+
]
|
|
68
|
+
};
|
|
69
|
+
const linkTypes = [
|
|
70
|
+
{
|
|
71
|
+
name: "reference",
|
|
72
|
+
type: "relationship",
|
|
73
|
+
admin: { condition: (_, siblingData) => siblingData?.type === "reference" },
|
|
74
|
+
label: "Document to link to",
|
|
75
|
+
relationTo,
|
|
76
|
+
required: true,
|
|
77
|
+
localized
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
name: "url",
|
|
81
|
+
type: "text",
|
|
82
|
+
admin: { condition: (_, siblingData) => siblingData?.type === "custom" },
|
|
83
|
+
label: "Custom URL",
|
|
84
|
+
required: true,
|
|
85
|
+
localized
|
|
86
|
+
}
|
|
87
|
+
];
|
|
88
|
+
if (!disableLabel) {
|
|
89
|
+
result.fields.push({
|
|
90
|
+
type: "row",
|
|
91
|
+
fields: [
|
|
92
|
+
...linkTypes,
|
|
93
|
+
{
|
|
94
|
+
name: "label",
|
|
95
|
+
type: "text",
|
|
96
|
+
admin: { width: "50%" },
|
|
97
|
+
label: "Label",
|
|
98
|
+
required: true,
|
|
99
|
+
localized
|
|
100
|
+
}
|
|
101
|
+
]
|
|
102
|
+
});
|
|
103
|
+
} else {
|
|
104
|
+
result.fields = [...result.fields, ...linkTypes];
|
|
105
|
+
}
|
|
106
|
+
if (appearances !== false) {
|
|
107
|
+
const opts = appearances ? appearances.map((a) => appearanceOptions[a]) : [appearanceOptions.default, appearanceOptions.outline];
|
|
108
|
+
result.fields.push({
|
|
109
|
+
name: "appearance",
|
|
110
|
+
type: "select",
|
|
111
|
+
admin: { description: "Choose how the link should be rendered." },
|
|
112
|
+
defaultValue: "default",
|
|
113
|
+
options: opts
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
return { ...result, ...overrides };
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
// src/core/fields/linkGroup.ts
|
|
120
|
+
var linkGroup = (options = {}) => ({
|
|
121
|
+
name: "links",
|
|
122
|
+
type: "array",
|
|
123
|
+
fields: [link(options)],
|
|
124
|
+
admin: { initCollapsed: true }
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
// src/exports/fields.ts
|
|
128
|
+
var fields_default = { link, linkGroup, appearanceOptions };
|
|
129
|
+
export {
|
|
130
|
+
linkGroup,
|
|
131
|
+
link,
|
|
132
|
+
fields_default as default,
|
|
133
|
+
appearanceOptions
|
|
134
|
+
};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { GlobalConfig } from "payload";
|
|
2
|
+
type CreateHeaderGlobalOptions = {
|
|
3
|
+
/**
|
|
4
|
+
* Optional override for the `custom.path` Payload uses to resolve
|
|
5
|
+
* the header's render module. Default: the lib's `HEADER_RENDER_PATH`.
|
|
6
|
+
*/
|
|
7
|
+
renderPath?: string;
|
|
8
|
+
/**
|
|
9
|
+
* Collection slugs the nav's link fields can reference. Required
|
|
10
|
+
* by Payload 3.85 — empty `relationTo` arrays are rejected.
|
|
11
|
+
* Defaults to `['pages']` (the lib's Pages collection). Pass a
|
|
12
|
+
* different list when your host has additional linkable collections.
|
|
13
|
+
*/
|
|
14
|
+
linkRelationTo?: string[];
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Build the Header global. The lib's default shape: a `nav` blocks
|
|
18
|
+
* field with two block types — `navColumn` (a titled group of links)
|
|
19
|
+
* and `navItem` (a single link).
|
|
20
|
+
*/
|
|
21
|
+
declare const createHeaderGlobal: (options?: CreateHeaderGlobalOptions) => GlobalConfig;
|
|
22
|
+
import { GlobalConfig as GlobalConfig2 } from "payload";
|
|
23
|
+
type CreateFooterGlobalOptions = {
|
|
24
|
+
/**
|
|
25
|
+
* Optional override for the `custom.path` Payload uses to resolve
|
|
26
|
+
* the footer's render module. Default: the lib's `FOOTER_RENDER_PATH`.
|
|
27
|
+
*/
|
|
28
|
+
renderPath?: string;
|
|
29
|
+
/**
|
|
30
|
+
* Collection slugs the nav's link fields can reference. Required
|
|
31
|
+
* by Payload 3.85 — empty `relationTo` arrays are rejected.
|
|
32
|
+
* Defaults to `['pages']` (the lib's Pages collection). Pass a
|
|
33
|
+
* different list when your host has additional linkable collections.
|
|
34
|
+
*/
|
|
35
|
+
linkRelationTo?: string[];
|
|
36
|
+
};
|
|
37
|
+
/**
|
|
38
|
+
* Build the Footer global. The lib's default shape mirrors the
|
|
39
|
+
* Header: a `nav` blocks field with `navColumn` (a titled group of
|
|
40
|
+
* links) and `navItem` (a single link) blocks.
|
|
41
|
+
*/
|
|
42
|
+
declare const createFooterGlobal: (options?: CreateFooterGlobalOptions) => GlobalConfig2;
|
|
43
|
+
import { GlobalConfig as GlobalConfig_fuin17 } from "payload";
|
|
44
|
+
declare const _default: {
|
|
45
|
+
createHeaderGlobal: (options?: CreateHeaderGlobalOptions) => GlobalConfig_fuin17;
|
|
46
|
+
createFooterGlobal: (options?: CreateFooterGlobalOptions) => GlobalConfig_fuin17;
|
|
47
|
+
};
|
|
48
|
+
export { _default as default, createHeaderGlobal, createFooterGlobal, CreateHeaderGlobalOptions, CreateFooterGlobalOptions };
|
package/dist/globals.js
ADDED
|
@@ -0,0 +1,228 @@
|
|
|
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
|
+
|
|
18
|
+
// src/config/constants.ts
|
|
19
|
+
var PAGES_RENDER_PATH = "@justanarthur/payload-www/render-pages#PagesPage";
|
|
20
|
+
var POSTS_RENDER_PATH = "@justanarthur/payload-www/render-pages#PostsPage";
|
|
21
|
+
var HEADER_RENDER_PATH = "@justanarthur/payload-www/render-pages#HeaderPage";
|
|
22
|
+
var FOOTER_RENDER_PATH = "@justanarthur/payload-www/render-pages#FooterPage";
|
|
23
|
+
var LIVE_PREVIEW_LISTENER_PATH = "@justanarthur/payload-www/render-components#LivePreviewListener";
|
|
24
|
+
var PAGES_SLUG = "pages";
|
|
25
|
+
var POSTS_SLUG = "posts";
|
|
26
|
+
var STATIC_PAGES_SLUG = "staticPages";
|
|
27
|
+
|
|
28
|
+
// src/core/fields/link.ts
|
|
29
|
+
var appearanceOptions = {
|
|
30
|
+
default: { label: "Default", value: "default" },
|
|
31
|
+
outline: { label: "Outline", value: "outline" }
|
|
32
|
+
};
|
|
33
|
+
var link = (options = {}) => {
|
|
34
|
+
const {
|
|
35
|
+
appearances,
|
|
36
|
+
disableLabel = false,
|
|
37
|
+
relationTo = [PAGES_SLUG],
|
|
38
|
+
localized = false,
|
|
39
|
+
overrides = {}
|
|
40
|
+
} = options;
|
|
41
|
+
const result = {
|
|
42
|
+
name: "link",
|
|
43
|
+
type: "group",
|
|
44
|
+
admin: { hideGutter: true },
|
|
45
|
+
fields: [
|
|
46
|
+
{
|
|
47
|
+
type: "row",
|
|
48
|
+
fields: [
|
|
49
|
+
{
|
|
50
|
+
name: "type",
|
|
51
|
+
type: "radio",
|
|
52
|
+
admin: { layout: "horizontal", width: "50%" },
|
|
53
|
+
defaultValue: "reference",
|
|
54
|
+
options: [
|
|
55
|
+
{ label: "Internal link", value: "reference" },
|
|
56
|
+
{ label: "Custom URL", value: "custom" }
|
|
57
|
+
]
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
name: "newTab",
|
|
61
|
+
type: "checkbox",
|
|
62
|
+
admin: { style: { alignSelf: "flex-end" }, width: "50%" },
|
|
63
|
+
label: "Open in new tab"
|
|
64
|
+
}
|
|
65
|
+
]
|
|
66
|
+
}
|
|
67
|
+
]
|
|
68
|
+
};
|
|
69
|
+
const linkTypes = [
|
|
70
|
+
{
|
|
71
|
+
name: "reference",
|
|
72
|
+
type: "relationship",
|
|
73
|
+
admin: { condition: (_, siblingData) => siblingData?.type === "reference" },
|
|
74
|
+
label: "Document to link to",
|
|
75
|
+
relationTo,
|
|
76
|
+
required: true,
|
|
77
|
+
localized
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
name: "url",
|
|
81
|
+
type: "text",
|
|
82
|
+
admin: { condition: (_, siblingData) => siblingData?.type === "custom" },
|
|
83
|
+
label: "Custom URL",
|
|
84
|
+
required: true,
|
|
85
|
+
localized
|
|
86
|
+
}
|
|
87
|
+
];
|
|
88
|
+
if (!disableLabel) {
|
|
89
|
+
result.fields.push({
|
|
90
|
+
type: "row",
|
|
91
|
+
fields: [
|
|
92
|
+
...linkTypes,
|
|
93
|
+
{
|
|
94
|
+
name: "label",
|
|
95
|
+
type: "text",
|
|
96
|
+
admin: { width: "50%" },
|
|
97
|
+
label: "Label",
|
|
98
|
+
required: true,
|
|
99
|
+
localized
|
|
100
|
+
}
|
|
101
|
+
]
|
|
102
|
+
});
|
|
103
|
+
} else {
|
|
104
|
+
result.fields = [...result.fields, ...linkTypes];
|
|
105
|
+
}
|
|
106
|
+
if (appearances !== false) {
|
|
107
|
+
const opts = appearances ? appearances.map((a) => appearanceOptions[a]) : [appearanceOptions.default, appearanceOptions.outline];
|
|
108
|
+
result.fields.push({
|
|
109
|
+
name: "appearance",
|
|
110
|
+
type: "select",
|
|
111
|
+
admin: { description: "Choose how the link should be rendered." },
|
|
112
|
+
defaultValue: "default",
|
|
113
|
+
options: opts
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
return { ...result, ...overrides };
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
// src/render/hooks/_shared.ts
|
|
120
|
+
var cachePromise = null;
|
|
121
|
+
function nextCacheImport() {
|
|
122
|
+
return cachePromise ??= import("next/cache");
|
|
123
|
+
}
|
|
124
|
+
function shouldSkipRevalidate(context) {
|
|
125
|
+
return Boolean(context?.disableRevalidate);
|
|
126
|
+
}
|
|
127
|
+
async function safeRevalidatePath(payload, path) {
|
|
128
|
+
try {
|
|
129
|
+
const { revalidatePath } = await nextCacheImport();
|
|
130
|
+
revalidatePath(path);
|
|
131
|
+
} catch (error) {
|
|
132
|
+
payload.logger.error(`revalidatePath("${path}") failed: ${String(error)}`);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
async function safeRevalidateTag(payload, tag, profile = "max") {
|
|
136
|
+
try {
|
|
137
|
+
const { revalidateTag } = await nextCacheImport();
|
|
138
|
+
revalidateTag(tag, profile);
|
|
139
|
+
} catch (error) {
|
|
140
|
+
payload.logger.error(`revalidateTag("${tag}") failed: ${String(error)}`);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
// src/render/hooks/revalidateGlobal.ts
|
|
145
|
+
function createRevalidateGlobalHook(slug) {
|
|
146
|
+
return async ({ doc, req: { payload, context, locale } }) => {
|
|
147
|
+
if (shouldSkipRevalidate(context))
|
|
148
|
+
return doc;
|
|
149
|
+
const tags = [`global_${slug}`, `global_${slug}_${locale}`];
|
|
150
|
+
payload.logger.info?.(`Revalidating global: ${tags.join(", ")}`);
|
|
151
|
+
for (const tag of tags) {
|
|
152
|
+
await safeRevalidateTag(payload, tag);
|
|
153
|
+
}
|
|
154
|
+
return doc;
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
// src/data/collections/globals/Header/config.ts
|
|
159
|
+
var createHeaderGlobal = (options = {}) => {
|
|
160
|
+
const { renderPath = HEADER_RENDER_PATH, linkRelationTo = [PAGES_SLUG] } = options;
|
|
161
|
+
const navColumnBlock = {
|
|
162
|
+
slug: "navColumn",
|
|
163
|
+
fields: [
|
|
164
|
+
{ name: "title", type: "text", required: true, localized: true },
|
|
165
|
+
{ name: "links", type: "array", fields: [link({ appearances: false, localized: true, relationTo: linkRelationTo })] }
|
|
166
|
+
]
|
|
167
|
+
};
|
|
168
|
+
const navItemBlock = {
|
|
169
|
+
slug: "navItem",
|
|
170
|
+
fields: [link({ appearances: false, localized: true, relationTo: linkRelationTo })]
|
|
171
|
+
};
|
|
172
|
+
return {
|
|
173
|
+
slug: "header",
|
|
174
|
+
custom: { path: renderPath },
|
|
175
|
+
access: { read: () => true },
|
|
176
|
+
fields: [
|
|
177
|
+
{
|
|
178
|
+
name: "nav",
|
|
179
|
+
type: "blocks",
|
|
180
|
+
required: true,
|
|
181
|
+
blocks: [navColumnBlock, navItemBlock]
|
|
182
|
+
}
|
|
183
|
+
],
|
|
184
|
+
hooks: {
|
|
185
|
+
afterChange: [createRevalidateGlobalHook("header")]
|
|
186
|
+
}
|
|
187
|
+
};
|
|
188
|
+
};
|
|
189
|
+
|
|
190
|
+
// src/data/collections/globals/Footer/config.ts
|
|
191
|
+
var createFooterGlobal = (options = {}) => {
|
|
192
|
+
const { renderPath = FOOTER_RENDER_PATH, linkRelationTo = [PAGES_SLUG] } = options;
|
|
193
|
+
const navColumnBlock = {
|
|
194
|
+
slug: "navColumn",
|
|
195
|
+
fields: [
|
|
196
|
+
{ name: "title", type: "text", required: true, localized: true },
|
|
197
|
+
{ name: "links", type: "array", fields: [link({ appearances: false, localized: true, relationTo: linkRelationTo })] }
|
|
198
|
+
]
|
|
199
|
+
};
|
|
200
|
+
const navItemBlock = {
|
|
201
|
+
slug: "navItem",
|
|
202
|
+
fields: [link({ appearances: false, localized: true, relationTo: linkRelationTo })]
|
|
203
|
+
};
|
|
204
|
+
return {
|
|
205
|
+
slug: "footer",
|
|
206
|
+
custom: { path: renderPath },
|
|
207
|
+
access: { read: () => true },
|
|
208
|
+
fields: [
|
|
209
|
+
{
|
|
210
|
+
name: "nav",
|
|
211
|
+
type: "blocks",
|
|
212
|
+
required: true,
|
|
213
|
+
blocks: [navColumnBlock, navItemBlock]
|
|
214
|
+
}
|
|
215
|
+
],
|
|
216
|
+
hooks: {
|
|
217
|
+
afterChange: [createRevalidateGlobalHook("footer")]
|
|
218
|
+
}
|
|
219
|
+
};
|
|
220
|
+
};
|
|
221
|
+
|
|
222
|
+
// src/exports/globals.ts
|
|
223
|
+
var globals_default = { createHeaderGlobal, createFooterGlobal };
|
|
224
|
+
export {
|
|
225
|
+
globals_default as default,
|
|
226
|
+
createHeaderGlobal,
|
|
227
|
+
createFooterGlobal
|
|
228
|
+
};
|
package/dist/hooks.d.ts
ADDED
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { CollectionAfterChangeHook, CollectionAfterDeleteHook } from "payload";
|
|
2
|
+
type LocalePrefixMode = "always" | "as-needed" | "never";
|
|
3
|
+
type CreateRevalidateCollectionHookOptions = {
|
|
4
|
+
/**
|
|
5
|
+
* The collection's slug. Used in the per-collection tag fired
|
|
6
|
+
* alongside path invalidation: `collection_<slug>_<id>`.
|
|
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
|
+
/**
|
|
44
|
+
* Canonical factory for **all** collection revalidation hooks —
|
|
45
|
+
* Pages, Posts, and any host-defined collection.
|
|
46
|
+
*
|
|
47
|
+
* Behavior:
|
|
48
|
+
*
|
|
49
|
+
* - Fires `revalidatePath` for **every** locale the host has
|
|
50
|
+
* declared (not just the request locale). The path is
|
|
51
|
+
* `${prefixFor(locale)}${urlPathPrefix}/${slug}` (or
|
|
52
|
+
* `${prefixFor(locale)}${urlPathPrefix}` for the home page with
|
|
53
|
+
* empty slug).
|
|
54
|
+
* - Fires `revalidateTag(sitemapTag, 'max')` on every change /
|
|
55
|
+
* delete so the sitemap handler sees fresh data.
|
|
56
|
+
* - Fires `revalidateTag('collection_<slug>_<id>', 'max')` so
|
|
57
|
+
* hosts using `unstable_cache` keyed by id stay fresh.
|
|
58
|
+
* - Handles slug renames while published (fires both old and new
|
|
59
|
+
* paths across all locales).
|
|
60
|
+
* - Respects `req.context.disableRevalidate` for seed / test
|
|
61
|
+
* scripts.
|
|
62
|
+
*
|
|
63
|
+
* Use `createRevalidateCollectionHook({ ... })` for any
|
|
64
|
+
* collection. For Pages specifically, the lib still exposes
|
|
65
|
+
* `createRevalidatePageHooks()` as a deprecated alias that
|
|
66
|
+
* delegates to this factory with `collectionSlug: 'pages'` and
|
|
67
|
+
* `urlPathPrefix: ''`.
|
|
68
|
+
*/
|
|
69
|
+
declare function createRevalidateCollectionHook(options: CreateRevalidateCollectionHookOptions): {
|
|
70
|
+
afterChange: CollectionAfterChangeHook;
|
|
71
|
+
afterDelete: CollectionAfterDeleteHook;
|
|
72
|
+
};
|
|
73
|
+
type CreateRevalidatePageHooksOptions = Omit<CreateRevalidateCollectionHookOptions, "collectionSlug" | "urlPathPrefix">;
|
|
74
|
+
/**
|
|
75
|
+
* @deprecated Use `createRevalidateCollectionHook({ collectionSlug: 'pages', urlPathPrefix: '' })` instead.
|
|
76
|
+
* Kept so hosts that imported this name directly don't break — the
|
|
77
|
+
* alias delegates to the canonical factory with the Pages preset.
|
|
78
|
+
*/
|
|
79
|
+
declare const createRevalidatePageHooks: (opts?: CreateRevalidatePageHooksOptions) => {
|
|
80
|
+
afterChange: CollectionAfterChangeHook;
|
|
81
|
+
afterDelete: CollectionAfterDeleteHook;
|
|
82
|
+
};
|
|
83
|
+
import { GlobalAfterChangeHook } from "payload";
|
|
84
|
+
/**
|
|
85
|
+
* Build a tag-based revalidation hook for a global. Fires two tags
|
|
86
|
+
* after a save:
|
|
87
|
+
*
|
|
88
|
+
* - `global_${slug}` — invalidates the lib's `getCachedGlobal` cache
|
|
89
|
+
* and any host caches that key by slug alone.
|
|
90
|
+
* - `global_${slug}_${locale}` — invalidates per-locale cache slots
|
|
91
|
+
* for hosts that key by `[slug, locale]`.
|
|
92
|
+
*
|
|
93
|
+
* The hook fires both so the lib's single-slot cache and the
|
|
94
|
+
* per-locale pattern both stay fresh regardless of which the host
|
|
95
|
+
* uses.
|
|
96
|
+
*/
|
|
97
|
+
declare function createRevalidateGlobalHook(slug: string): GlobalAfterChangeHook;
|
|
98
|
+
import { CollectionAfterChangeHook as CollectionAfterChangeHook_qdlahd } from "payload";
|
|
99
|
+
import { CollectionAfterDeleteHook as CollectionAfterDeleteHook_jscwy4 } from "payload";
|
|
100
|
+
declare const _default: {
|
|
101
|
+
createRevalidateCollectionHook: typeof createRevalidateCollectionHook;
|
|
102
|
+
createRevalidatePageHooks: (opts?: CreateRevalidatePageHooksOptions) => {
|
|
103
|
+
afterChange: CollectionAfterChangeHook_qdlahd;
|
|
104
|
+
afterDelete: CollectionAfterDeleteHook_jscwy4;
|
|
105
|
+
};
|
|
106
|
+
createRevalidateGlobalHook: typeof createRevalidateGlobalHook;
|
|
107
|
+
};
|
|
108
|
+
export { _default as default, createRevalidatePageHooks, createRevalidateGlobalHook, createRevalidateCollectionHook, CreateRevalidatePageHooksOptions, CreateRevalidateCollectionHookOptions };
|