@payloadcms/plugin-redirects 3.0.0-alpha.47 → 3.0.0-alpha.49
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/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +10 -7
- package/src/index.ts +82 -0
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Config } from 'payload/config';
|
|
2
2
|
import type { PluginConfig } from './types.js';
|
|
3
3
|
declare const redirects: (pluginConfig: PluginConfig) => (incomingConfig: Config) => Config;
|
|
4
|
-
export
|
|
4
|
+
export { redirects };
|
|
5
5
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAA;AAE5C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AAI9C,QAAA,MAAM,SAAS,iBACE,YAAY,sBACV,MAAM,KAAG,MAuExB,CAAA;AAEJ,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAA;AAE5C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AAI9C,QAAA,MAAM,SAAS,iBACE,YAAY,sBACV,MAAM,KAAG,MAuExB,CAAA;AAEJ,OAAO,EAAE,SAAS,EAAE,CAAA"}
|
package/dist/index.js
CHANGED
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import type { Config } from 'payload/config'\n\nimport type { PluginConfig } from './types.js'\n\nimport deepMerge from './deepMerge.js'\n\nconst redirects =\n (pluginConfig: PluginConfig) =>\n (incomingConfig: Config): Config => ({\n ...incomingConfig,\n collections: [\n ...(incomingConfig?.collections || []),\n deepMerge(\n {\n slug: 'redirects',\n access: {\n read: (): boolean => true,\n },\n admin: {\n defaultColumns: ['from', 'to.type', 'createdAt'],\n },\n fields: [\n {\n name: 'from',\n type: 'text',\n index: true,\n label: 'From URL',\n required: true,\n },\n {\n name: 'to',\n type: 'group',\n fields: [\n {\n name: 'type',\n type: 'radio',\n admin: {\n layout: 'horizontal',\n },\n defaultValue: 'reference',\n label: 'To URL Type',\n options: [\n {\n label: 'Internal link',\n value: 'reference',\n },\n {\n label: 'Custom URL',\n value: 'custom',\n },\n ],\n },\n {\n name: 'reference',\n type: 'relationship',\n admin: {\n condition: (_, siblingData) => siblingData?.type === 'reference',\n },\n label: 'Document to redirect to',\n relationTo: pluginConfig?.collections || [],\n required: true,\n },\n {\n name: 'url',\n type: 'text',\n admin: {\n condition: (_, siblingData) => siblingData?.type === 'custom',\n },\n label: 'Custom URL',\n required: true,\n },\n ],\n label: false,\n },\n ],\n },\n pluginConfig?.overrides || {},\n ),\n ],\n })\n\nexport
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import type { Config } from 'payload/config'\n\nimport type { PluginConfig } from './types.js'\n\nimport deepMerge from './deepMerge.js'\n\nconst redirects =\n (pluginConfig: PluginConfig) =>\n (incomingConfig: Config): Config => ({\n ...incomingConfig,\n collections: [\n ...(incomingConfig?.collections || []),\n deepMerge(\n {\n slug: 'redirects',\n access: {\n read: (): boolean => true,\n },\n admin: {\n defaultColumns: ['from', 'to.type', 'createdAt'],\n },\n fields: [\n {\n name: 'from',\n type: 'text',\n index: true,\n label: 'From URL',\n required: true,\n },\n {\n name: 'to',\n type: 'group',\n fields: [\n {\n name: 'type',\n type: 'radio',\n admin: {\n layout: 'horizontal',\n },\n defaultValue: 'reference',\n label: 'To URL Type',\n options: [\n {\n label: 'Internal link',\n value: 'reference',\n },\n {\n label: 'Custom URL',\n value: 'custom',\n },\n ],\n },\n {\n name: 'reference',\n type: 'relationship',\n admin: {\n condition: (_, siblingData) => siblingData?.type === 'reference',\n },\n label: 'Document to redirect to',\n relationTo: pluginConfig?.collections || [],\n required: true,\n },\n {\n name: 'url',\n type: 'text',\n admin: {\n condition: (_, siblingData) => siblingData?.type === 'custom',\n },\n label: 'Custom URL',\n required: true,\n },\n ],\n label: false,\n },\n ],\n },\n pluginConfig?.overrides || {},\n ),\n ],\n })\n\nexport { redirects }\n"],"names":["deepMerge","redirects","pluginConfig","incomingConfig","collections","slug","access","read","admin","defaultColumns","fields","name","type","index","label","required","layout","defaultValue","options","value","condition","_","siblingData","relationTo","overrides"],"mappings":"AAIA,OAAOA,eAAe,iBAAgB;AAEtC,MAAMC,YACJ,CAACC,eACD,CAACC,iBAAoC,CAAA;YACnC,GAAGA,cAAc;YACjBC,aAAa;mBACPD,gBAAgBC,eAAe,EAAE;gBACrCJ,UACE;oBACEK,MAAM;oBACNC,QAAQ;wBACNC,MAAM,IAAe;oBACvB;oBACAC,OAAO;wBACLC,gBAAgB;4BAAC;4BAAQ;4BAAW;yBAAY;oBAClD;oBACAC,QAAQ;wBACN;4BACEC,MAAM;4BACNC,MAAM;4BACNC,OAAO;4BACPC,OAAO;4BACPC,UAAU;wBACZ;wBACA;4BACEJ,MAAM;4BACNC,MAAM;4BACNF,QAAQ;gCACN;oCACEC,MAAM;oCACNC,MAAM;oCACNJ,OAAO;wCACLQ,QAAQ;oCACV;oCACAC,cAAc;oCACdH,OAAO;oCACPI,SAAS;wCACP;4CACEJ,OAAO;4CACPK,OAAO;wCACT;wCACA;4CACEL,OAAO;4CACPK,OAAO;wCACT;qCACD;gCACH;gCACA;oCACER,MAAM;oCACNC,MAAM;oCACNJ,OAAO;wCACLY,WAAW,CAACC,GAAGC,cAAgBA,aAAaV,SAAS;oCACvD;oCACAE,OAAO;oCACPS,YAAYrB,cAAcE,eAAe,EAAE;oCAC3CW,UAAU;gCACZ;gCACA;oCACEJ,MAAM;oCACNC,MAAM;oCACNJ,OAAO;wCACLY,WAAW,CAACC,GAAGC,cAAgBA,aAAaV,SAAS;oCACvD;oCACAE,OAAO;oCACPC,UAAU;gCACZ;6BACD;4BACDD,OAAO;wBACT;qBACD;gBACH,GACAZ,cAAcsB,aAAa,CAAC;aAE/B;QACH,CAAA;AAEF,SAASvB,SAAS,GAAE"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@payloadcms/plugin-redirects",
|
|
3
|
-
"version": "3.0.0-alpha.
|
|
3
|
+
"version": "3.0.0-alpha.49",
|
|
4
4
|
"homepage:": "https://payloadcms.com",
|
|
5
5
|
"repository": "git@github.com:payloadcms/plugin-redirects.git",
|
|
6
6
|
"description": "Redirects plugin for Payload",
|
|
@@ -19,18 +19,21 @@
|
|
|
19
19
|
"author": "dev@payloadcms.com",
|
|
20
20
|
"license": "MIT",
|
|
21
21
|
"peerDependencies": {
|
|
22
|
-
"payload": "3.0.0-alpha.
|
|
22
|
+
"payload": "3.0.0-alpha.49"
|
|
23
23
|
},
|
|
24
24
|
"devDependencies": {
|
|
25
25
|
"@types/express": "^4.17.9",
|
|
26
26
|
"@types/react": "18.0.21",
|
|
27
27
|
"react": "^18.0.0",
|
|
28
|
-
"
|
|
29
|
-
"
|
|
28
|
+
"payload": "3.0.0-alpha.49",
|
|
29
|
+
"@payloadcms/eslint-config": "1.1.1"
|
|
30
30
|
},
|
|
31
|
-
"exports":
|
|
32
|
-
|
|
33
|
-
|
|
31
|
+
"exports": {
|
|
32
|
+
".": {
|
|
33
|
+
"import": "./dist/index.js",
|
|
34
|
+
"require": "./dist/index.js",
|
|
35
|
+
"types": "./dist/index.d.ts"
|
|
36
|
+
}
|
|
34
37
|
},
|
|
35
38
|
"files": [
|
|
36
39
|
"dist",
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import type { Config } from 'payload/config'
|
|
2
|
+
|
|
3
|
+
import type { PluginConfig } from './types.js'
|
|
4
|
+
|
|
5
|
+
import deepMerge from './deepMerge.js'
|
|
6
|
+
|
|
7
|
+
const redirects =
|
|
8
|
+
(pluginConfig: PluginConfig) =>
|
|
9
|
+
(incomingConfig: Config): Config => ({
|
|
10
|
+
...incomingConfig,
|
|
11
|
+
collections: [
|
|
12
|
+
...(incomingConfig?.collections || []),
|
|
13
|
+
deepMerge(
|
|
14
|
+
{
|
|
15
|
+
slug: 'redirects',
|
|
16
|
+
access: {
|
|
17
|
+
read: (): boolean => true,
|
|
18
|
+
},
|
|
19
|
+
admin: {
|
|
20
|
+
defaultColumns: ['from', 'to.type', 'createdAt'],
|
|
21
|
+
},
|
|
22
|
+
fields: [
|
|
23
|
+
{
|
|
24
|
+
name: 'from',
|
|
25
|
+
type: 'text',
|
|
26
|
+
index: true,
|
|
27
|
+
label: 'From URL',
|
|
28
|
+
required: true,
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
name: 'to',
|
|
32
|
+
type: 'group',
|
|
33
|
+
fields: [
|
|
34
|
+
{
|
|
35
|
+
name: 'type',
|
|
36
|
+
type: 'radio',
|
|
37
|
+
admin: {
|
|
38
|
+
layout: 'horizontal',
|
|
39
|
+
},
|
|
40
|
+
defaultValue: 'reference',
|
|
41
|
+
label: 'To URL Type',
|
|
42
|
+
options: [
|
|
43
|
+
{
|
|
44
|
+
label: 'Internal link',
|
|
45
|
+
value: 'reference',
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
label: 'Custom URL',
|
|
49
|
+
value: 'custom',
|
|
50
|
+
},
|
|
51
|
+
],
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
name: 'reference',
|
|
55
|
+
type: 'relationship',
|
|
56
|
+
admin: {
|
|
57
|
+
condition: (_, siblingData) => siblingData?.type === 'reference',
|
|
58
|
+
},
|
|
59
|
+
label: 'Document to redirect to',
|
|
60
|
+
relationTo: pluginConfig?.collections || [],
|
|
61
|
+
required: true,
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
name: 'url',
|
|
65
|
+
type: 'text',
|
|
66
|
+
admin: {
|
|
67
|
+
condition: (_, siblingData) => siblingData?.type === 'custom',
|
|
68
|
+
},
|
|
69
|
+
label: 'Custom URL',
|
|
70
|
+
required: true,
|
|
71
|
+
},
|
|
72
|
+
],
|
|
73
|
+
label: false,
|
|
74
|
+
},
|
|
75
|
+
],
|
|
76
|
+
},
|
|
77
|
+
pluginConfig?.overrides || {},
|
|
78
|
+
),
|
|
79
|
+
],
|
|
80
|
+
})
|
|
81
|
+
|
|
82
|
+
export { redirects }
|