@justanarthur/payload-www 0.3.0 → 0.3.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/dist/collections.js +36 -7
- package/dist/config.js +36 -7
- package/dist/data-collections.js +36 -7
- package/dist/data-test.js +36 -7
- package/dist/server.js +41 -12
- package/dist/test.js +36 -7
- package/dist/with-www-config.js +36 -7
- package/package.json +1 -1
package/dist/collections.js
CHANGED
|
@@ -23,6 +23,35 @@ var authenticatedOrPublished = ({ req: { user } }) => {
|
|
|
23
23
|
return true;
|
|
24
24
|
return { _status: { equals: "published" } };
|
|
25
25
|
};
|
|
26
|
+
|
|
27
|
+
// src/core/fields/slug.ts
|
|
28
|
+
var FLAT_PATTERN = /^[a-z0-9-]+$/;
|
|
29
|
+
var NESTED_PATTERN = /^[a-z0-9_-]+$/;
|
|
30
|
+
var slugField = (options = {}) => {
|
|
31
|
+
const { name = "slug", nested = false, localized = true } = options;
|
|
32
|
+
const pattern = nested ? NESTED_PATTERN : FLAT_PATTERN;
|
|
33
|
+
const invalidMessage = nested ? "Slug must be lowercase, with hyphens or the `_` nesting divider (no spaces or other special characters)" : "Slug must be lowercase, with hyphens (no spaces or special characters)";
|
|
34
|
+
return {
|
|
35
|
+
name,
|
|
36
|
+
type: "text",
|
|
37
|
+
required: true,
|
|
38
|
+
unique: true,
|
|
39
|
+
index: true,
|
|
40
|
+
localized,
|
|
41
|
+
admin: {
|
|
42
|
+
position: "sidebar",
|
|
43
|
+
...nested ? { description: "Lowercase, hyphens for words. Use the `_` divider for nesting, e.g. `about_us` → `/about/us`." } : {}
|
|
44
|
+
},
|
|
45
|
+
validate: (value) => {
|
|
46
|
+
if (typeof value !== "string")
|
|
47
|
+
return "Slug must be a string";
|
|
48
|
+
if (value !== "" && !pattern.test(value))
|
|
49
|
+
return invalidMessage;
|
|
50
|
+
return true;
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
};
|
|
54
|
+
|
|
26
55
|
// src/render/_locale.ts
|
|
27
56
|
function prefixFor(locale, defaultLocale, mode) {
|
|
28
57
|
if (mode === "never")
|
|
@@ -386,11 +415,11 @@ var createStaticPagesCollection = (blocks) => {
|
|
|
386
415
|
};
|
|
387
416
|
|
|
388
417
|
// src/core/fields/link.ts
|
|
389
|
-
var
|
|
418
|
+
var appearanceOptions = {
|
|
390
419
|
default: { label: "Default", value: "default" },
|
|
391
420
|
outline: { label: "Outline", value: "outline" }
|
|
392
421
|
};
|
|
393
|
-
var
|
|
422
|
+
var link = (options = {}) => {
|
|
394
423
|
const {
|
|
395
424
|
appearances,
|
|
396
425
|
disableLabel = false,
|
|
@@ -465,7 +494,7 @@ var link2 = (options = {}) => {
|
|
|
465
494
|
result.fields = [...result.fields, ...linkTypes];
|
|
466
495
|
}
|
|
467
496
|
if (appearances !== false) {
|
|
468
|
-
const opts = appearances ? appearances.map((a) =>
|
|
497
|
+
const opts = appearances ? appearances.map((a) => appearanceOptions[a]) : [appearanceOptions.default, appearanceOptions.outline];
|
|
469
498
|
result.fields.push({
|
|
470
499
|
name: "appearance",
|
|
471
500
|
type: "select",
|
|
@@ -506,12 +535,12 @@ var createHeaderGlobal = (options = {}) => {
|
|
|
506
535
|
slug: "navColumn",
|
|
507
536
|
fields: [
|
|
508
537
|
{ name: "title", type: "text", required: true, localized: true },
|
|
509
|
-
{ name: "links", type: "array", fields: [
|
|
538
|
+
{ name: "links", type: "array", fields: [link({ appearances: false, localized: true, relationTo: linkRelationTo, extraFields: navColumnLinkFields })] }
|
|
510
539
|
]
|
|
511
540
|
};
|
|
512
541
|
const navItemBlock = {
|
|
513
542
|
slug: "navItem",
|
|
514
|
-
fields: [
|
|
543
|
+
fields: [link({ appearances: false, localized: true, relationTo: linkRelationTo, extraFields: navItemLinkFields })]
|
|
515
544
|
};
|
|
516
545
|
return {
|
|
517
546
|
slug: "header",
|
|
@@ -543,12 +572,12 @@ var createFooterGlobal = (options = {}) => {
|
|
|
543
572
|
slug: "navColumn",
|
|
544
573
|
fields: [
|
|
545
574
|
{ name: "title", type: "text", required: true, localized: true },
|
|
546
|
-
{ name: "links", type: "array", fields: [
|
|
575
|
+
{ name: "links", type: "array", fields: [link({ appearances: false, localized: true, relationTo: linkRelationTo, extraFields: navColumnLinkFields })] }
|
|
547
576
|
]
|
|
548
577
|
};
|
|
549
578
|
const navItemBlock = {
|
|
550
579
|
slug: "navItem",
|
|
551
|
-
fields: [
|
|
580
|
+
fields: [link({ appearances: false, localized: true, relationTo: linkRelationTo, extraFields: navItemLinkFields })]
|
|
552
581
|
};
|
|
553
582
|
return {
|
|
554
583
|
slug: "footer",
|
package/dist/config.js
CHANGED
|
@@ -23,6 +23,35 @@ var authenticatedOrPublished = ({ req: { user } }) => {
|
|
|
23
23
|
return true;
|
|
24
24
|
return { _status: { equals: "published" } };
|
|
25
25
|
};
|
|
26
|
+
|
|
27
|
+
// src/core/fields/slug.ts
|
|
28
|
+
var FLAT_PATTERN = /^[a-z0-9-]+$/;
|
|
29
|
+
var NESTED_PATTERN = /^[a-z0-9_-]+$/;
|
|
30
|
+
var slugField = (options = {}) => {
|
|
31
|
+
const { name = "slug", nested = false, localized = true } = options;
|
|
32
|
+
const pattern = nested ? NESTED_PATTERN : FLAT_PATTERN;
|
|
33
|
+
const invalidMessage = nested ? "Slug must be lowercase, with hyphens or the `_` nesting divider (no spaces or other special characters)" : "Slug must be lowercase, with hyphens (no spaces or special characters)";
|
|
34
|
+
return {
|
|
35
|
+
name,
|
|
36
|
+
type: "text",
|
|
37
|
+
required: true,
|
|
38
|
+
unique: true,
|
|
39
|
+
index: true,
|
|
40
|
+
localized,
|
|
41
|
+
admin: {
|
|
42
|
+
position: "sidebar",
|
|
43
|
+
...nested ? { description: "Lowercase, hyphens for words. Use the `_` divider for nesting, e.g. `about_us` → `/about/us`." } : {}
|
|
44
|
+
},
|
|
45
|
+
validate: (value) => {
|
|
46
|
+
if (typeof value !== "string")
|
|
47
|
+
return "Slug must be a string";
|
|
48
|
+
if (value !== "" && !pattern.test(value))
|
|
49
|
+
return invalidMessage;
|
|
50
|
+
return true;
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
};
|
|
54
|
+
|
|
26
55
|
// src/render/_locale.ts
|
|
27
56
|
function prefixFor(locale, defaultLocale, mode) {
|
|
28
57
|
if (mode === "never")
|
|
@@ -386,11 +415,11 @@ var createStaticPagesCollection = (blocks) => {
|
|
|
386
415
|
};
|
|
387
416
|
|
|
388
417
|
// src/core/fields/link.ts
|
|
389
|
-
var
|
|
418
|
+
var appearanceOptions = {
|
|
390
419
|
default: { label: "Default", value: "default" },
|
|
391
420
|
outline: { label: "Outline", value: "outline" }
|
|
392
421
|
};
|
|
393
|
-
var
|
|
422
|
+
var link = (options = {}) => {
|
|
394
423
|
const {
|
|
395
424
|
appearances,
|
|
396
425
|
disableLabel = false,
|
|
@@ -465,7 +494,7 @@ var link2 = (options = {}) => {
|
|
|
465
494
|
result.fields = [...result.fields, ...linkTypes];
|
|
466
495
|
}
|
|
467
496
|
if (appearances !== false) {
|
|
468
|
-
const opts = appearances ? appearances.map((a) =>
|
|
497
|
+
const opts = appearances ? appearances.map((a) => appearanceOptions[a]) : [appearanceOptions.default, appearanceOptions.outline];
|
|
469
498
|
result.fields.push({
|
|
470
499
|
name: "appearance",
|
|
471
500
|
type: "select",
|
|
@@ -506,12 +535,12 @@ var createHeaderGlobal = (options = {}) => {
|
|
|
506
535
|
slug: "navColumn",
|
|
507
536
|
fields: [
|
|
508
537
|
{ name: "title", type: "text", required: true, localized: true },
|
|
509
|
-
{ name: "links", type: "array", fields: [
|
|
538
|
+
{ name: "links", type: "array", fields: [link({ appearances: false, localized: true, relationTo: linkRelationTo, extraFields: navColumnLinkFields })] }
|
|
510
539
|
]
|
|
511
540
|
};
|
|
512
541
|
const navItemBlock = {
|
|
513
542
|
slug: "navItem",
|
|
514
|
-
fields: [
|
|
543
|
+
fields: [link({ appearances: false, localized: true, relationTo: linkRelationTo, extraFields: navItemLinkFields })]
|
|
515
544
|
};
|
|
516
545
|
return {
|
|
517
546
|
slug: "header",
|
|
@@ -543,12 +572,12 @@ var createFooterGlobal = (options = {}) => {
|
|
|
543
572
|
slug: "navColumn",
|
|
544
573
|
fields: [
|
|
545
574
|
{ name: "title", type: "text", required: true, localized: true },
|
|
546
|
-
{ name: "links", type: "array", fields: [
|
|
575
|
+
{ name: "links", type: "array", fields: [link({ appearances: false, localized: true, relationTo: linkRelationTo, extraFields: navColumnLinkFields })] }
|
|
547
576
|
]
|
|
548
577
|
};
|
|
549
578
|
const navItemBlock = {
|
|
550
579
|
slug: "navItem",
|
|
551
|
-
fields: [
|
|
580
|
+
fields: [link({ appearances: false, localized: true, relationTo: linkRelationTo, extraFields: navItemLinkFields })]
|
|
552
581
|
};
|
|
553
582
|
return {
|
|
554
583
|
slug: "footer",
|
package/dist/data-collections.js
CHANGED
|
@@ -23,6 +23,35 @@ var authenticatedOrPublished = ({ req: { user } }) => {
|
|
|
23
23
|
return true;
|
|
24
24
|
return { _status: { equals: "published" } };
|
|
25
25
|
};
|
|
26
|
+
|
|
27
|
+
// src/core/fields/slug.ts
|
|
28
|
+
var FLAT_PATTERN = /^[a-z0-9-]+$/;
|
|
29
|
+
var NESTED_PATTERN = /^[a-z0-9_-]+$/;
|
|
30
|
+
var slugField = (options = {}) => {
|
|
31
|
+
const { name = "slug", nested = false, localized = true } = options;
|
|
32
|
+
const pattern = nested ? NESTED_PATTERN : FLAT_PATTERN;
|
|
33
|
+
const invalidMessage = nested ? "Slug must be lowercase, with hyphens or the `_` nesting divider (no spaces or other special characters)" : "Slug must be lowercase, with hyphens (no spaces or special characters)";
|
|
34
|
+
return {
|
|
35
|
+
name,
|
|
36
|
+
type: "text",
|
|
37
|
+
required: true,
|
|
38
|
+
unique: true,
|
|
39
|
+
index: true,
|
|
40
|
+
localized,
|
|
41
|
+
admin: {
|
|
42
|
+
position: "sidebar",
|
|
43
|
+
...nested ? { description: "Lowercase, hyphens for words. Use the `_` divider for nesting, e.g. `about_us` → `/about/us`." } : {}
|
|
44
|
+
},
|
|
45
|
+
validate: (value) => {
|
|
46
|
+
if (typeof value !== "string")
|
|
47
|
+
return "Slug must be a string";
|
|
48
|
+
if (value !== "" && !pattern.test(value))
|
|
49
|
+
return invalidMessage;
|
|
50
|
+
return true;
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
};
|
|
54
|
+
|
|
26
55
|
// src/render/_locale.ts
|
|
27
56
|
function prefixFor(locale, defaultLocale, mode) {
|
|
28
57
|
if (mode === "never")
|
|
@@ -386,11 +415,11 @@ var createStaticPagesCollection = (blocks) => {
|
|
|
386
415
|
};
|
|
387
416
|
|
|
388
417
|
// src/core/fields/link.ts
|
|
389
|
-
var
|
|
418
|
+
var appearanceOptions = {
|
|
390
419
|
default: { label: "Default", value: "default" },
|
|
391
420
|
outline: { label: "Outline", value: "outline" }
|
|
392
421
|
};
|
|
393
|
-
var
|
|
422
|
+
var link = (options = {}) => {
|
|
394
423
|
const {
|
|
395
424
|
appearances,
|
|
396
425
|
disableLabel = false,
|
|
@@ -465,7 +494,7 @@ var link2 = (options = {}) => {
|
|
|
465
494
|
result.fields = [...result.fields, ...linkTypes];
|
|
466
495
|
}
|
|
467
496
|
if (appearances !== false) {
|
|
468
|
-
const opts = appearances ? appearances.map((a) =>
|
|
497
|
+
const opts = appearances ? appearances.map((a) => appearanceOptions[a]) : [appearanceOptions.default, appearanceOptions.outline];
|
|
469
498
|
result.fields.push({
|
|
470
499
|
name: "appearance",
|
|
471
500
|
type: "select",
|
|
@@ -506,12 +535,12 @@ var createHeaderGlobal = (options = {}) => {
|
|
|
506
535
|
slug: "navColumn",
|
|
507
536
|
fields: [
|
|
508
537
|
{ name: "title", type: "text", required: true, localized: true },
|
|
509
|
-
{ name: "links", type: "array", fields: [
|
|
538
|
+
{ name: "links", type: "array", fields: [link({ appearances: false, localized: true, relationTo: linkRelationTo, extraFields: navColumnLinkFields })] }
|
|
510
539
|
]
|
|
511
540
|
};
|
|
512
541
|
const navItemBlock = {
|
|
513
542
|
slug: "navItem",
|
|
514
|
-
fields: [
|
|
543
|
+
fields: [link({ appearances: false, localized: true, relationTo: linkRelationTo, extraFields: navItemLinkFields })]
|
|
515
544
|
};
|
|
516
545
|
return {
|
|
517
546
|
slug: "header",
|
|
@@ -543,12 +572,12 @@ var createFooterGlobal = (options = {}) => {
|
|
|
543
572
|
slug: "navColumn",
|
|
544
573
|
fields: [
|
|
545
574
|
{ name: "title", type: "text", required: true, localized: true },
|
|
546
|
-
{ name: "links", type: "array", fields: [
|
|
575
|
+
{ name: "links", type: "array", fields: [link({ appearances: false, localized: true, relationTo: linkRelationTo, extraFields: navColumnLinkFields })] }
|
|
547
576
|
]
|
|
548
577
|
};
|
|
549
578
|
const navItemBlock = {
|
|
550
579
|
slug: "navItem",
|
|
551
|
-
fields: [
|
|
580
|
+
fields: [link({ appearances: false, localized: true, relationTo: linkRelationTo, extraFields: navItemLinkFields })]
|
|
552
581
|
};
|
|
553
582
|
return {
|
|
554
583
|
slug: "footer",
|
package/dist/data-test.js
CHANGED
|
@@ -29,6 +29,35 @@ var authenticatedOrPublished = ({ req: { user } }) => {
|
|
|
29
29
|
return true;
|
|
30
30
|
return { _status: { equals: "published" } };
|
|
31
31
|
};
|
|
32
|
+
|
|
33
|
+
// src/core/fields/slug.ts
|
|
34
|
+
var FLAT_PATTERN = /^[a-z0-9-]+$/;
|
|
35
|
+
var NESTED_PATTERN = /^[a-z0-9_-]+$/;
|
|
36
|
+
var slugField = (options = {}) => {
|
|
37
|
+
const { name = "slug", nested = false, localized = true } = options;
|
|
38
|
+
const pattern = nested ? NESTED_PATTERN : FLAT_PATTERN;
|
|
39
|
+
const invalidMessage = nested ? "Slug must be lowercase, with hyphens or the `_` nesting divider (no spaces or other special characters)" : "Slug must be lowercase, with hyphens (no spaces or special characters)";
|
|
40
|
+
return {
|
|
41
|
+
name,
|
|
42
|
+
type: "text",
|
|
43
|
+
required: true,
|
|
44
|
+
unique: true,
|
|
45
|
+
index: true,
|
|
46
|
+
localized,
|
|
47
|
+
admin: {
|
|
48
|
+
position: "sidebar",
|
|
49
|
+
...nested ? { description: "Lowercase, hyphens for words. Use the `_` divider for nesting, e.g. `about_us` → `/about/us`." } : {}
|
|
50
|
+
},
|
|
51
|
+
validate: (value) => {
|
|
52
|
+
if (typeof value !== "string")
|
|
53
|
+
return "Slug must be a string";
|
|
54
|
+
if (value !== "" && !pattern.test(value))
|
|
55
|
+
return invalidMessage;
|
|
56
|
+
return true;
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
};
|
|
60
|
+
|
|
32
61
|
// src/render/_locale.ts
|
|
33
62
|
function prefixFor(locale, defaultLocale, mode) {
|
|
34
63
|
if (mode === "never")
|
|
@@ -392,11 +421,11 @@ var createStaticPagesCollection = (blocks) => {
|
|
|
392
421
|
};
|
|
393
422
|
|
|
394
423
|
// src/core/fields/link.ts
|
|
395
|
-
var
|
|
424
|
+
var appearanceOptions = {
|
|
396
425
|
default: { label: "Default", value: "default" },
|
|
397
426
|
outline: { label: "Outline", value: "outline" }
|
|
398
427
|
};
|
|
399
|
-
var
|
|
428
|
+
var link = (options = {}) => {
|
|
400
429
|
const {
|
|
401
430
|
appearances,
|
|
402
431
|
disableLabel = false,
|
|
@@ -471,7 +500,7 @@ var link2 = (options = {}) => {
|
|
|
471
500
|
result.fields = [...result.fields, ...linkTypes];
|
|
472
501
|
}
|
|
473
502
|
if (appearances !== false) {
|
|
474
|
-
const opts = appearances ? appearances.map((a) =>
|
|
503
|
+
const opts = appearances ? appearances.map((a) => appearanceOptions[a]) : [appearanceOptions.default, appearanceOptions.outline];
|
|
475
504
|
result.fields.push({
|
|
476
505
|
name: "appearance",
|
|
477
506
|
type: "select",
|
|
@@ -512,12 +541,12 @@ var createHeaderGlobal = (options = {}) => {
|
|
|
512
541
|
slug: "navColumn",
|
|
513
542
|
fields: [
|
|
514
543
|
{ name: "title", type: "text", required: true, localized: true },
|
|
515
|
-
{ name: "links", type: "array", fields: [
|
|
544
|
+
{ name: "links", type: "array", fields: [link({ appearances: false, localized: true, relationTo: linkRelationTo, extraFields: navColumnLinkFields })] }
|
|
516
545
|
]
|
|
517
546
|
};
|
|
518
547
|
const navItemBlock = {
|
|
519
548
|
slug: "navItem",
|
|
520
|
-
fields: [
|
|
549
|
+
fields: [link({ appearances: false, localized: true, relationTo: linkRelationTo, extraFields: navItemLinkFields })]
|
|
521
550
|
};
|
|
522
551
|
return {
|
|
523
552
|
slug: "header",
|
|
@@ -549,12 +578,12 @@ var createFooterGlobal = (options = {}) => {
|
|
|
549
578
|
slug: "navColumn",
|
|
550
579
|
fields: [
|
|
551
580
|
{ name: "title", type: "text", required: true, localized: true },
|
|
552
|
-
{ name: "links", type: "array", fields: [
|
|
581
|
+
{ name: "links", type: "array", fields: [link({ appearances: false, localized: true, relationTo: linkRelationTo, extraFields: navColumnLinkFields })] }
|
|
553
582
|
]
|
|
554
583
|
};
|
|
555
584
|
const navItemBlock = {
|
|
556
585
|
slug: "navItem",
|
|
557
|
-
fields: [
|
|
586
|
+
fields: [link({ appearances: false, localized: true, relationTo: linkRelationTo, extraFields: navItemLinkFields })]
|
|
558
587
|
};
|
|
559
588
|
return {
|
|
560
589
|
slug: "footer",
|
package/dist/server.js
CHANGED
|
@@ -192,6 +192,35 @@ var authenticatedOrPublished = ({ req: { user } }) => {
|
|
|
192
192
|
return true;
|
|
193
193
|
return { _status: { equals: "published" } };
|
|
194
194
|
};
|
|
195
|
+
|
|
196
|
+
// src/core/fields/slug.ts
|
|
197
|
+
var FLAT_PATTERN = /^[a-z0-9-]+$/;
|
|
198
|
+
var NESTED_PATTERN = /^[a-z0-9_-]+$/;
|
|
199
|
+
var slugField = (options = {}) => {
|
|
200
|
+
const { name = "slug", nested = false, localized = true } = options;
|
|
201
|
+
const pattern = nested ? NESTED_PATTERN : FLAT_PATTERN;
|
|
202
|
+
const invalidMessage = nested ? "Slug must be lowercase, with hyphens or the `_` nesting divider (no spaces or other special characters)" : "Slug must be lowercase, with hyphens (no spaces or special characters)";
|
|
203
|
+
return {
|
|
204
|
+
name,
|
|
205
|
+
type: "text",
|
|
206
|
+
required: true,
|
|
207
|
+
unique: true,
|
|
208
|
+
index: true,
|
|
209
|
+
localized,
|
|
210
|
+
admin: {
|
|
211
|
+
position: "sidebar",
|
|
212
|
+
...nested ? { description: "Lowercase, hyphens for words. Use the `_` divider for nesting, e.g. `about_us` → `/about/us`." } : {}
|
|
213
|
+
},
|
|
214
|
+
validate: (value) => {
|
|
215
|
+
if (typeof value !== "string")
|
|
216
|
+
return "Slug must be a string";
|
|
217
|
+
if (value !== "" && !pattern.test(value))
|
|
218
|
+
return invalidMessage;
|
|
219
|
+
return true;
|
|
220
|
+
}
|
|
221
|
+
};
|
|
222
|
+
};
|
|
223
|
+
|
|
195
224
|
// src/render/_locale.ts
|
|
196
225
|
function prefixFor(locale, defaultLocale, mode) {
|
|
197
226
|
if (mode === "never")
|
|
@@ -555,11 +584,11 @@ var createStaticPagesCollection = (blocks) => {
|
|
|
555
584
|
};
|
|
556
585
|
|
|
557
586
|
// src/core/fields/link.ts
|
|
558
|
-
var
|
|
587
|
+
var appearanceOptions = {
|
|
559
588
|
default: { label: "Default", value: "default" },
|
|
560
589
|
outline: { label: "Outline", value: "outline" }
|
|
561
590
|
};
|
|
562
|
-
var
|
|
591
|
+
var link = (options = {}) => {
|
|
563
592
|
const {
|
|
564
593
|
appearances,
|
|
565
594
|
disableLabel = false,
|
|
@@ -634,7 +663,7 @@ var link2 = (options = {}) => {
|
|
|
634
663
|
result.fields = [...result.fields, ...linkTypes];
|
|
635
664
|
}
|
|
636
665
|
if (appearances !== false) {
|
|
637
|
-
const opts = appearances ? appearances.map((a) =>
|
|
666
|
+
const opts = appearances ? appearances.map((a) => appearanceOptions[a]) : [appearanceOptions.default, appearanceOptions.outline];
|
|
638
667
|
result.fields.push({
|
|
639
668
|
name: "appearance",
|
|
640
669
|
type: "select",
|
|
@@ -675,12 +704,12 @@ var createHeaderGlobal = (options = {}) => {
|
|
|
675
704
|
slug: "navColumn",
|
|
676
705
|
fields: [
|
|
677
706
|
{ name: "title", type: "text", required: true, localized: true },
|
|
678
|
-
{ name: "links", type: "array", fields: [
|
|
707
|
+
{ name: "links", type: "array", fields: [link({ appearances: false, localized: true, relationTo: linkRelationTo, extraFields: navColumnLinkFields })] }
|
|
679
708
|
]
|
|
680
709
|
};
|
|
681
710
|
const navItemBlock = {
|
|
682
711
|
slug: "navItem",
|
|
683
|
-
fields: [
|
|
712
|
+
fields: [link({ appearances: false, localized: true, relationTo: linkRelationTo, extraFields: navItemLinkFields })]
|
|
684
713
|
};
|
|
685
714
|
return {
|
|
686
715
|
slug: "header",
|
|
@@ -712,12 +741,12 @@ var createFooterGlobal = (options = {}) => {
|
|
|
712
741
|
slug: "navColumn",
|
|
713
742
|
fields: [
|
|
714
743
|
{ name: "title", type: "text", required: true, localized: true },
|
|
715
|
-
{ name: "links", type: "array", fields: [
|
|
744
|
+
{ name: "links", type: "array", fields: [link({ appearances: false, localized: true, relationTo: linkRelationTo, extraFields: navColumnLinkFields })] }
|
|
716
745
|
]
|
|
717
746
|
};
|
|
718
747
|
const navItemBlock = {
|
|
719
748
|
slug: "navItem",
|
|
720
|
-
fields: [
|
|
749
|
+
fields: [link({ appearances: false, localized: true, relationTo: linkRelationTo, extraFields: navItemLinkFields })]
|
|
721
750
|
};
|
|
722
751
|
return {
|
|
723
752
|
slug: "footer",
|
|
@@ -1081,10 +1110,10 @@ function createWWWConfig(options) {
|
|
|
1081
1110
|
}
|
|
1082
1111
|
|
|
1083
1112
|
// src/core/fields/linkGroup.ts
|
|
1084
|
-
var
|
|
1113
|
+
var linkGroup = (options = {}) => ({
|
|
1085
1114
|
name: "links",
|
|
1086
1115
|
type: "array",
|
|
1087
|
-
fields: [
|
|
1116
|
+
fields: [link(options)],
|
|
1088
1117
|
admin: { initCollapsed: true }
|
|
1089
1118
|
});
|
|
1090
1119
|
|
|
@@ -2020,8 +2049,8 @@ export {
|
|
|
2020
2049
|
queryDocBySlug,
|
|
2021
2050
|
queryAllLocaleSlugs,
|
|
2022
2051
|
queryAllDocs,
|
|
2023
|
-
|
|
2024
|
-
|
|
2052
|
+
linkGroup,
|
|
2053
|
+
link,
|
|
2025
2054
|
getUrlPath,
|
|
2026
2055
|
getRenderModuleExports,
|
|
2027
2056
|
getFromImportMap,
|
|
@@ -2049,7 +2078,7 @@ export {
|
|
|
2049
2078
|
buildArticleLd,
|
|
2050
2079
|
authenticatedOrPublished,
|
|
2051
2080
|
authenticated,
|
|
2052
|
-
|
|
2081
|
+
appearanceOptions,
|
|
2053
2082
|
anyone,
|
|
2054
2083
|
addCollectionsToSitemap,
|
|
2055
2084
|
STATIC_PAGES_SLUG,
|
package/dist/test.js
CHANGED
|
@@ -29,6 +29,35 @@ var authenticatedOrPublished = ({ req: { user } }) => {
|
|
|
29
29
|
return true;
|
|
30
30
|
return { _status: { equals: "published" } };
|
|
31
31
|
};
|
|
32
|
+
|
|
33
|
+
// src/core/fields/slug.ts
|
|
34
|
+
var FLAT_PATTERN = /^[a-z0-9-]+$/;
|
|
35
|
+
var NESTED_PATTERN = /^[a-z0-9_-]+$/;
|
|
36
|
+
var slugField = (options = {}) => {
|
|
37
|
+
const { name = "slug", nested = false, localized = true } = options;
|
|
38
|
+
const pattern = nested ? NESTED_PATTERN : FLAT_PATTERN;
|
|
39
|
+
const invalidMessage = nested ? "Slug must be lowercase, with hyphens or the `_` nesting divider (no spaces or other special characters)" : "Slug must be lowercase, with hyphens (no spaces or special characters)";
|
|
40
|
+
return {
|
|
41
|
+
name,
|
|
42
|
+
type: "text",
|
|
43
|
+
required: true,
|
|
44
|
+
unique: true,
|
|
45
|
+
index: true,
|
|
46
|
+
localized,
|
|
47
|
+
admin: {
|
|
48
|
+
position: "sidebar",
|
|
49
|
+
...nested ? { description: "Lowercase, hyphens for words. Use the `_` divider for nesting, e.g. `about_us` → `/about/us`." } : {}
|
|
50
|
+
},
|
|
51
|
+
validate: (value) => {
|
|
52
|
+
if (typeof value !== "string")
|
|
53
|
+
return "Slug must be a string";
|
|
54
|
+
if (value !== "" && !pattern.test(value))
|
|
55
|
+
return invalidMessage;
|
|
56
|
+
return true;
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
};
|
|
60
|
+
|
|
32
61
|
// src/render/_locale.ts
|
|
33
62
|
function prefixFor(locale, defaultLocale, mode) {
|
|
34
63
|
if (mode === "never")
|
|
@@ -392,11 +421,11 @@ var createStaticPagesCollection = (blocks) => {
|
|
|
392
421
|
};
|
|
393
422
|
|
|
394
423
|
// src/core/fields/link.ts
|
|
395
|
-
var
|
|
424
|
+
var appearanceOptions = {
|
|
396
425
|
default: { label: "Default", value: "default" },
|
|
397
426
|
outline: { label: "Outline", value: "outline" }
|
|
398
427
|
};
|
|
399
|
-
var
|
|
428
|
+
var link = (options = {}) => {
|
|
400
429
|
const {
|
|
401
430
|
appearances,
|
|
402
431
|
disableLabel = false,
|
|
@@ -471,7 +500,7 @@ var link2 = (options = {}) => {
|
|
|
471
500
|
result.fields = [...result.fields, ...linkTypes];
|
|
472
501
|
}
|
|
473
502
|
if (appearances !== false) {
|
|
474
|
-
const opts = appearances ? appearances.map((a) =>
|
|
503
|
+
const opts = appearances ? appearances.map((a) => appearanceOptions[a]) : [appearanceOptions.default, appearanceOptions.outline];
|
|
475
504
|
result.fields.push({
|
|
476
505
|
name: "appearance",
|
|
477
506
|
type: "select",
|
|
@@ -512,12 +541,12 @@ var createHeaderGlobal = (options = {}) => {
|
|
|
512
541
|
slug: "navColumn",
|
|
513
542
|
fields: [
|
|
514
543
|
{ name: "title", type: "text", required: true, localized: true },
|
|
515
|
-
{ name: "links", type: "array", fields: [
|
|
544
|
+
{ name: "links", type: "array", fields: [link({ appearances: false, localized: true, relationTo: linkRelationTo, extraFields: navColumnLinkFields })] }
|
|
516
545
|
]
|
|
517
546
|
};
|
|
518
547
|
const navItemBlock = {
|
|
519
548
|
slug: "navItem",
|
|
520
|
-
fields: [
|
|
549
|
+
fields: [link({ appearances: false, localized: true, relationTo: linkRelationTo, extraFields: navItemLinkFields })]
|
|
521
550
|
};
|
|
522
551
|
return {
|
|
523
552
|
slug: "header",
|
|
@@ -549,12 +578,12 @@ var createFooterGlobal = (options = {}) => {
|
|
|
549
578
|
slug: "navColumn",
|
|
550
579
|
fields: [
|
|
551
580
|
{ name: "title", type: "text", required: true, localized: true },
|
|
552
|
-
{ name: "links", type: "array", fields: [
|
|
581
|
+
{ name: "links", type: "array", fields: [link({ appearances: false, localized: true, relationTo: linkRelationTo, extraFields: navColumnLinkFields })] }
|
|
553
582
|
]
|
|
554
583
|
};
|
|
555
584
|
const navItemBlock = {
|
|
556
585
|
slug: "navItem",
|
|
557
|
-
fields: [
|
|
586
|
+
fields: [link({ appearances: false, localized: true, relationTo: linkRelationTo, extraFields: navItemLinkFields })]
|
|
558
587
|
};
|
|
559
588
|
return {
|
|
560
589
|
slug: "footer",
|
package/dist/with-www-config.js
CHANGED
|
@@ -23,6 +23,35 @@ var authenticatedOrPublished = ({ req: { user } }) => {
|
|
|
23
23
|
return true;
|
|
24
24
|
return { _status: { equals: "published" } };
|
|
25
25
|
};
|
|
26
|
+
|
|
27
|
+
// src/core/fields/slug.ts
|
|
28
|
+
var FLAT_PATTERN = /^[a-z0-9-]+$/;
|
|
29
|
+
var NESTED_PATTERN = /^[a-z0-9_-]+$/;
|
|
30
|
+
var slugField = (options = {}) => {
|
|
31
|
+
const { name = "slug", nested = false, localized = true } = options;
|
|
32
|
+
const pattern = nested ? NESTED_PATTERN : FLAT_PATTERN;
|
|
33
|
+
const invalidMessage = nested ? "Slug must be lowercase, with hyphens or the `_` nesting divider (no spaces or other special characters)" : "Slug must be lowercase, with hyphens (no spaces or special characters)";
|
|
34
|
+
return {
|
|
35
|
+
name,
|
|
36
|
+
type: "text",
|
|
37
|
+
required: true,
|
|
38
|
+
unique: true,
|
|
39
|
+
index: true,
|
|
40
|
+
localized,
|
|
41
|
+
admin: {
|
|
42
|
+
position: "sidebar",
|
|
43
|
+
...nested ? { description: "Lowercase, hyphens for words. Use the `_` divider for nesting, e.g. `about_us` → `/about/us`." } : {}
|
|
44
|
+
},
|
|
45
|
+
validate: (value) => {
|
|
46
|
+
if (typeof value !== "string")
|
|
47
|
+
return "Slug must be a string";
|
|
48
|
+
if (value !== "" && !pattern.test(value))
|
|
49
|
+
return invalidMessage;
|
|
50
|
+
return true;
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
};
|
|
54
|
+
|
|
26
55
|
// src/render/_locale.ts
|
|
27
56
|
function prefixFor(locale, defaultLocale, mode) {
|
|
28
57
|
if (mode === "never")
|
|
@@ -386,11 +415,11 @@ var createStaticPagesCollection = (blocks) => {
|
|
|
386
415
|
};
|
|
387
416
|
|
|
388
417
|
// src/core/fields/link.ts
|
|
389
|
-
var
|
|
418
|
+
var appearanceOptions = {
|
|
390
419
|
default: { label: "Default", value: "default" },
|
|
391
420
|
outline: { label: "Outline", value: "outline" }
|
|
392
421
|
};
|
|
393
|
-
var
|
|
422
|
+
var link = (options = {}) => {
|
|
394
423
|
const {
|
|
395
424
|
appearances,
|
|
396
425
|
disableLabel = false,
|
|
@@ -465,7 +494,7 @@ var link2 = (options = {}) => {
|
|
|
465
494
|
result.fields = [...result.fields, ...linkTypes];
|
|
466
495
|
}
|
|
467
496
|
if (appearances !== false) {
|
|
468
|
-
const opts = appearances ? appearances.map((a) =>
|
|
497
|
+
const opts = appearances ? appearances.map((a) => appearanceOptions[a]) : [appearanceOptions.default, appearanceOptions.outline];
|
|
469
498
|
result.fields.push({
|
|
470
499
|
name: "appearance",
|
|
471
500
|
type: "select",
|
|
@@ -506,12 +535,12 @@ var createHeaderGlobal = (options = {}) => {
|
|
|
506
535
|
slug: "navColumn",
|
|
507
536
|
fields: [
|
|
508
537
|
{ name: "title", type: "text", required: true, localized: true },
|
|
509
|
-
{ name: "links", type: "array", fields: [
|
|
538
|
+
{ name: "links", type: "array", fields: [link({ appearances: false, localized: true, relationTo: linkRelationTo, extraFields: navColumnLinkFields })] }
|
|
510
539
|
]
|
|
511
540
|
};
|
|
512
541
|
const navItemBlock = {
|
|
513
542
|
slug: "navItem",
|
|
514
|
-
fields: [
|
|
543
|
+
fields: [link({ appearances: false, localized: true, relationTo: linkRelationTo, extraFields: navItemLinkFields })]
|
|
515
544
|
};
|
|
516
545
|
return {
|
|
517
546
|
slug: "header",
|
|
@@ -543,12 +572,12 @@ var createFooterGlobal = (options = {}) => {
|
|
|
543
572
|
slug: "navColumn",
|
|
544
573
|
fields: [
|
|
545
574
|
{ name: "title", type: "text", required: true, localized: true },
|
|
546
|
-
{ name: "links", type: "array", fields: [
|
|
575
|
+
{ name: "links", type: "array", fields: [link({ appearances: false, localized: true, relationTo: linkRelationTo, extraFields: navColumnLinkFields })] }
|
|
547
576
|
]
|
|
548
577
|
};
|
|
549
578
|
const navItemBlock = {
|
|
550
579
|
slug: "navItem",
|
|
551
|
-
fields: [
|
|
580
|
+
fields: [link({ appearances: false, localized: true, relationTo: linkRelationTo, extraFields: navItemLinkFields })]
|
|
552
581
|
};
|
|
553
582
|
return {
|
|
554
583
|
slug: "footer",
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@justanarthur/payload-www",
|
|
3
3
|
"description": "Reusable Payload CMS website template — config builder, collections, globals, blocks, fields, access, hooks, metadata (JSON-LD, hreflang), page renderers, and test helpers.",
|
|
4
|
-
"version": "0.3.
|
|
4
|
+
"version": "0.3.1",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"private": false,
|
|
7
7
|
"module": "./dist/index.js",
|