Compare commits
563 Commits
fix/next-n
...
alpha-post
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
19620f4fa4 | ||
|
|
2fb265ae2d | ||
|
|
3b5e7f1dc4 | ||
|
|
aba7c13a1d | ||
|
|
f59d3f36d1 | ||
|
|
3f0d0ecd5f | ||
|
|
0c51502cc5 | ||
|
|
e829650cd9 | ||
|
|
a8082c551b | ||
|
|
ff55cfa001 | ||
|
|
623a3d3b7b | ||
|
|
fb32e2a561 | ||
|
|
8aa8a380e1 | ||
|
|
f35b8b05e8 | ||
|
|
05bb73bb7c | ||
|
|
18299dc65e | ||
|
|
818ab2c10f | ||
|
|
df0bf28d57 | ||
|
|
ff65f10c2f | ||
|
|
5cf49aa166 | ||
|
|
0651daa1d4 | ||
|
|
921c53f75c | ||
|
|
dd37519185 | ||
|
|
a1e8c4eb2b | ||
|
|
1f8c191cb3 | ||
|
|
f4acc74eee | ||
|
|
3d1378ab77 | ||
|
|
58e4174edb | ||
|
|
20b4585666 | ||
|
|
9c7e7ed8d4 | ||
|
|
436c4f2736 | ||
|
|
0ce752af79 | ||
|
|
92ff896bdb | ||
|
|
77a3cbaba5 | ||
|
|
56f9c88251 | ||
|
|
8a5a08cbe1 | ||
|
|
5241c38ba0 | ||
|
|
072a903351 | ||
|
|
328bd453bb | ||
|
|
690a3cfa68 | ||
|
|
1c1847f63c | ||
|
|
c3d9d8ee2f | ||
|
|
65932b65d2 | ||
|
|
682e961416 | ||
|
|
9fcccc8197 | ||
|
|
72f3ced219 | ||
|
|
74de066529 | ||
|
|
3d1589404c | ||
|
|
30d9d46dd8 | ||
|
|
740373897a | ||
|
|
f7ca01bafd | ||
|
|
7654ff686a | ||
|
|
5266612bb3 | ||
|
|
a9b46a4d63 | ||
|
|
76e9bd8ad6 | ||
|
|
317a443644 | ||
|
|
43f91ca42c | ||
|
|
8d78d07415 | ||
|
|
99a00a1ae2 | ||
|
|
2cd8d891a1 | ||
|
|
7fc33af1e5 | ||
|
|
67c57a1137 | ||
|
|
9f8ac06659 | ||
|
|
aea28b28d0 | ||
|
|
ee4cd61696 | ||
|
|
e9f15c377f | ||
|
|
d5935ea81b | ||
|
|
934ad96a98 | ||
|
|
2c68f8fba1 | ||
|
|
c90de87f37 | ||
|
|
ab84566d86 | ||
|
|
4c109a467f | ||
|
|
bc4f6aaf9c | ||
|
|
cf8ac7e8b3 | ||
|
|
3a9b230aef | ||
|
|
016b644d86 | ||
|
|
7082b47856 | ||
|
|
57ec382102 | ||
|
|
9748ed2259 | ||
|
|
6ec5981f1d | ||
|
|
e20ea342c2 | ||
|
|
2ff3603245 | ||
|
|
da6e8f14d6 | ||
|
|
2dd04739b5 | ||
|
|
8e758ea979 | ||
|
|
a81f7e2a24 | ||
|
|
c98ec3658c | ||
|
|
249463f7df | ||
|
|
700e77ad43 | ||
|
|
1a272879f1 | ||
|
|
aa6cb4f25b | ||
|
|
59eec36746 | ||
|
|
45baff403a | ||
|
|
5de1883390 | ||
|
|
35b0d213a6 | ||
|
|
774a4b7533 | ||
|
|
11cbb774bc | ||
|
|
0f7d0a03d9 | ||
|
|
cb568a1af4 | ||
|
|
f4da03d840 | ||
|
|
e5cc8123b9 | ||
|
|
cc13e1210d | ||
|
|
1e838f2e55 | ||
|
|
154d4170cc | ||
|
|
64d6163f13 | ||
|
|
85ffc5d8bf | ||
|
|
38f36d465c | ||
|
|
d956055795 | ||
|
|
c1e1cd0596 | ||
|
|
a3df2ca0ef | ||
|
|
6b3325d0ba | ||
|
|
9e4dd44a2e | ||
|
|
e880588aac | ||
|
|
c2af3df331 | ||
|
|
46be6e37dc | ||
|
|
5165077bc9 | ||
|
|
5ae537f23c | ||
|
|
5f572dbd04 | ||
|
|
d511e80b01 | ||
|
|
27dfa41b67 | ||
|
|
f55c28352e | ||
|
|
a7b884d170 | ||
|
|
fd4f996c30 | ||
|
|
c897037b7a | ||
|
|
11fe64eee3 | ||
|
|
6cbc0f0304 | ||
|
|
b3d28bac6a | ||
|
|
96833bdf89 | ||
|
|
6cf5730bcb | ||
|
|
e5403f8dfd | ||
|
|
8278992feb | ||
|
|
9f690c1f5d | ||
|
|
b946f7e697 | ||
|
|
c9dea854f6 | ||
|
|
e72dfe5af2 | ||
|
|
d5912a53f4 | ||
|
|
cb5d005e68 | ||
|
|
0dd0f39250 | ||
|
|
9c7e250109 | ||
|
|
ca103b6af3 | ||
|
|
2f75ee9472 | ||
|
|
7eab38afa7 | ||
|
|
68d0a442e4 | ||
|
|
ee2b6d3b85 | ||
|
|
e73220e069 | ||
|
|
d2a1404f04 | ||
|
|
c8a7eb4988 | ||
|
|
7ec37e058e | ||
|
|
64f2d2a502 | ||
|
|
6afb4ccf26 | ||
|
|
a4676d1fea | ||
|
|
97173de555 | ||
|
|
9e6d01b2a1 | ||
|
|
d3a5437079 | ||
|
|
b22a03a317 | ||
|
|
06cd13aef2 | ||
|
|
25a3feb2ca | ||
|
|
c8c3332366 | ||
|
|
006b315120 | ||
|
|
f74d6efcae | ||
|
|
b2d802aa85 | ||
|
|
964a51e21d | ||
|
|
4a43db06dd | ||
|
|
3ce7fe638f | ||
|
|
c2a4d44bf4 | ||
|
|
867817f568 | ||
|
|
46a56a236f | ||
|
|
6357009055 | ||
|
|
42f7091038 | ||
|
|
a3c63fcdf0 | ||
|
|
6b358c626f | ||
|
|
3bbfa822d7 | ||
|
|
a13fc138f2 | ||
|
|
721a082758 | ||
|
|
07288de5a1 | ||
|
|
ac0bb78412 | ||
|
|
c24464179b | ||
|
|
d473600a15 | ||
|
|
accd9eaa27 | ||
|
|
cb180cbbf8 | ||
|
|
a3dbe482e2 | ||
|
|
959302a868 | ||
|
|
95be2b55f7 | ||
|
|
3bce86a1e8 | ||
|
|
dd10931316 | ||
|
|
f5b8f5a6f8 | ||
|
|
65fddc5d28 | ||
|
|
d3ac843249 | ||
|
|
1b5f4f5c3c | ||
|
|
1af558af44 | ||
|
|
b3b36f3340 | ||
|
|
4624659af6 | ||
|
|
ab649af8be | ||
|
|
c5491e6f27 | ||
|
|
b47b5ddb05 | ||
|
|
095799a816 | ||
|
|
1104b6daa4 | ||
|
|
4ecd811302 | ||
|
|
b112ccd6d8 | ||
|
|
bee32f9898 | ||
|
|
69fce590e3 | ||
|
|
c51ed43a10 | ||
|
|
fd51511380 | ||
|
|
8a054d8cc9 | ||
|
|
91731896c4 | ||
|
|
e897d04218 | ||
|
|
69e4de6ba9 | ||
|
|
6b176066ec | ||
|
|
4c372962fc | ||
|
|
001f386244 | ||
|
|
5eb73e0c05 | ||
|
|
3347f92414 | ||
|
|
72c6200f17 | ||
|
|
ed01ee1e2d | ||
|
|
b259bc60a2 | ||
|
|
772d5e10b8 | ||
|
|
7e96560fbb | ||
|
|
6ae5e11c6f | ||
|
|
9877fe2eed | ||
|
|
fe086e90a1 | ||
|
|
c9958e1634 | ||
|
|
67f7c002c9 | ||
|
|
bf7c38d8e8 | ||
|
|
f361d153d1 | ||
|
|
0e571c3e35 | ||
|
|
7857c80c79 | ||
|
|
99adfd2bba | ||
|
|
9a493491f1 | ||
|
|
1ac76d7758 | ||
|
|
c5ecf48d94 | ||
|
|
1e10f021b5 | ||
|
|
7d0bd49ae3 | ||
|
|
d4e7cabee5 | ||
|
|
92471b0beb | ||
|
|
ea713758a1 | ||
|
|
9182d8d594 | ||
|
|
7df3434c6a | ||
|
|
5e9014b2c3 | ||
|
|
4d95c824f3 | ||
|
|
28d7d2544e | ||
|
|
decc56e54d | ||
|
|
976d86ae1a | ||
|
|
4e650e17aa | ||
|
|
d08d04debd | ||
|
|
602108b150 | ||
|
|
a9b1a2e7b7 | ||
|
|
99f31bbc23 | ||
|
|
6c2faf68c4 | ||
|
|
ee8c29c5ef | ||
|
|
26df916421 | ||
|
|
0a8f400a59 | ||
|
|
cc1cbd1ed7 | ||
|
|
034e85aa87 | ||
|
|
12e54e189a | ||
|
|
5eaea1c7f1 | ||
|
|
10786c6ca8 | ||
|
|
55d9377403 | ||
|
|
70f29785ca | ||
|
|
e197c5120d | ||
|
|
2cf72aea81 | ||
|
|
30111bb125 | ||
|
|
7d38f6b074 | ||
|
|
7e625b8e9e | ||
|
|
152eea3cb8 | ||
|
|
ee72b1be5d | ||
|
|
605d96b71b | ||
|
|
8e1c7d955f | ||
|
|
8046b5675f | ||
|
|
0ac8a39c5e | ||
|
|
81522b33e6 | ||
|
|
4df49689a9 | ||
|
|
0f7106bf4a | ||
|
|
900c5b7661 | ||
|
|
5cac4c953d | ||
|
|
65f2cb9a22 | ||
|
|
7ddb68b70d | ||
|
|
14eb66c87d | ||
|
|
ef141d499b | ||
|
|
1ab27e8fe3 | ||
|
|
145a3b7ee4 | ||
|
|
a042327741 | ||
|
|
4eba651c3d | ||
|
|
ba3b2ea66f | ||
|
|
c48719dfdb | ||
|
|
1680f0ef52 | ||
|
|
ae6c4b2ddf | ||
|
|
8e9192181d | ||
|
|
a2f2a59c21 | ||
|
|
e739c26f2e | ||
|
|
b215eae914 | ||
|
|
1123e4e751 | ||
|
|
203bc26c0e | ||
|
|
fb4651bdad | ||
|
|
09f2926bbb | ||
|
|
eef06425a3 | ||
|
|
b329e3c43c | ||
|
|
04a3223ff5 | ||
|
|
9226be058c | ||
|
|
2dc425b083 | ||
|
|
c5f915651c | ||
|
|
e2d7fec793 | ||
|
|
d3b4f46b25 | ||
|
|
6311156169 | ||
|
|
695a814eb3 | ||
|
|
5ef2e35685 | ||
|
|
8818ed9d7b | ||
|
|
d785af1826 | ||
|
|
398811a14e | ||
|
|
c5f9533d2b | ||
|
|
aaf17aa2b2 | ||
|
|
3e11379e6c | ||
|
|
f78d0b7c7a | ||
|
|
978e19c817 | ||
|
|
1550e32282 | ||
|
|
7fb2dc6500 | ||
|
|
92654af609 | ||
|
|
c10787dbb3 | ||
|
|
4fecb7fad9 | ||
|
|
01a121868b | ||
|
|
a023009dee | ||
|
|
e301393f33 | ||
|
|
39600fb0f5 | ||
|
|
663cde7676 | ||
|
|
dac771c096 | ||
|
|
b8b1d572b4 | ||
|
|
6789e61488 | ||
|
|
051fdfb081 | ||
|
|
1f07a827ec | ||
|
|
81618d2efc | ||
|
|
6f44a88ffd | ||
|
|
4300c3d550 | ||
|
|
5fbf7b3d24 | ||
|
|
eb5899c94b | ||
|
|
5e68fa1255 | ||
|
|
f1c322fe69 | ||
|
|
580520f100 | ||
|
|
40343df255 | ||
|
|
57f8b427db | ||
|
|
f85e96acac | ||
|
|
bff83f1785 | ||
|
|
ca27748799 | ||
|
|
2dc98f682f | ||
|
|
d4f3309ffd | ||
|
|
821777bd64 | ||
|
|
84c2fa9491 | ||
|
|
d193c677c7 | ||
|
|
cbfc7c8b43 | ||
|
|
6a43065316 | ||
|
|
9dd390f7a7 | ||
|
|
6c631cb11e | ||
|
|
817b790757 | ||
|
|
98aa8cc22a | ||
|
|
e9e228abaf | ||
|
|
909bb6f6cf | ||
|
|
e8b47eef2f | ||
|
|
415ba26efe | ||
|
|
777e2744c4 | ||
|
|
53a09f4989 | ||
|
|
e3e0f056a9 | ||
|
|
b6ce1fbd51 | ||
|
|
7267cfdbfc | ||
|
|
fa259aa194 | ||
|
|
da1d2873d5 | ||
|
|
be88d278c6 | ||
|
|
81cb8c83bf | ||
|
|
eee44a9919 | ||
|
|
4f730410bc | ||
|
|
171144be80 | ||
|
|
5c2bcba000 | ||
|
|
5b5c6e975d | ||
|
|
45110f60c3 | ||
|
|
26c434c4ee | ||
|
|
2e872d4818 | ||
|
|
30a1219f9d | ||
|
|
cf1632f80b | ||
|
|
885b003730 | ||
|
|
a9a61b2617 | ||
|
|
b968d8594c | ||
|
|
d7ebb871bb | ||
|
|
6f67b2381a | ||
|
|
2237d7e860 | ||
|
|
6ea456d6da | ||
|
|
f0a2edf7cf | ||
|
|
881fcd4e9b | ||
|
|
8954af5c53 | ||
|
|
e3c6d5859b | ||
|
|
16441b5b6a | ||
|
|
195b1ccfcc | ||
|
|
b3f5670cc0 | ||
|
|
e43c80b4f5 | ||
|
|
931e2f6134 | ||
|
|
e091a37241 | ||
|
|
5f093846a7 | ||
|
|
dcbae0618c | ||
|
|
4d70d6319b | ||
|
|
09484667f0 | ||
|
|
04fcf57d0a | ||
|
|
8436dd5851 | ||
|
|
bbae8cccfb | ||
|
|
044fa2d10f | ||
|
|
2dd50cccd3 | ||
|
|
c05ffb0c6b | ||
|
|
935044d2da | ||
|
|
6ec6505a5d | ||
|
|
96e0f55c61 | ||
|
|
b765f06dfd | ||
|
|
8da6318cc6 | ||
|
|
0fcdec604c | ||
|
|
3edda36a91 | ||
|
|
97d65bfca0 | ||
|
|
66771c6f62 | ||
|
|
e6b23aee18 | ||
|
|
5e9ee50f99 | ||
|
|
93584bc766 | ||
|
|
a89180ea06 | ||
|
|
4983da7efa | ||
|
|
8fd6bd4c71 | ||
|
|
c7ea62a394 | ||
|
|
fc8e2d3e05 | ||
|
|
6cf3c91293 | ||
|
|
e122278ec4 | ||
|
|
7c9b5cba1c | ||
|
|
a86c1b7cd3 | ||
|
|
dd6d08d61d | ||
|
|
0fc120d7d5 | ||
|
|
6e03558dcb | ||
|
|
b327dd31b7 | ||
|
|
da1326a336 | ||
|
|
d22cb1dfa7 | ||
|
|
5556915564 | ||
|
|
4c6fc53ba5 | ||
|
|
626b6500de | ||
|
|
dbbbb6b921 | ||
|
|
d9e3d4dbae | ||
|
|
92648de3b4 | ||
|
|
4f9e5b9336 | ||
|
|
d55d0ad621 | ||
|
|
4edbe2aace | ||
|
|
ba2702cfca | ||
|
|
eba1f6327d | ||
|
|
1ba0b4037c | ||
|
|
49daa75bc4 | ||
|
|
cd21138b3d | ||
|
|
fea1eb1149 | ||
|
|
9a58f6c454 | ||
|
|
66cefe6bb5 | ||
|
|
23510acf40 | ||
|
|
faa49f36e7 | ||
|
|
a5fb8b20a1 | ||
|
|
e14b303609 | ||
|
|
2ec3df6680 | ||
|
|
1f4b6001ef | ||
|
|
6e7c9cc6a3 | ||
|
|
2db385c6a5 | ||
|
|
bd27f48eae | ||
|
|
98a33250f6 | ||
|
|
8f9729a928 | ||
|
|
1a8564bc35 | ||
|
|
76c9632417 | ||
|
|
2370361b43 | ||
|
|
cb63095d3f | ||
|
|
601f2fb450 | ||
|
|
e746f17167 | ||
|
|
5f76097562 | ||
|
|
03756c4210 | ||
|
|
5e1e158414 | ||
|
|
76d2525fd2 | ||
|
|
ec8c7e5c2c | ||
|
|
0a4cbe1a08 | ||
|
|
c228421a38 | ||
|
|
a742f82370 | ||
|
|
213678ca3e | ||
|
|
e1b7ad6a71 | ||
|
|
8b9985a92c | ||
|
|
f276826b09 | ||
|
|
8c1df551ef | ||
|
|
b62cb157e1 | ||
|
|
045c74ce67 | ||
|
|
911e902da4 | ||
|
|
4e0d90d720 | ||
|
|
7b62705cc0 | ||
|
|
bdf02bebaa | ||
|
|
94aa309910 | ||
|
|
499a0a782a | ||
|
|
1e5a531a83 | ||
|
|
3e6a4073c4 | ||
|
|
e7cb6abd1f | ||
|
|
abfd8841a5 | ||
|
|
5e385fa33b | ||
|
|
95688c7e30 | ||
|
|
b041d3e70e | ||
|
|
0e91cddab9 | ||
|
|
d3856693ce | ||
|
|
40f36104f3 | ||
|
|
7215edb784 | ||
|
|
189be7ce69 | ||
|
|
28f10ffc25 | ||
|
|
be015320de | ||
|
|
a37d53b2e7 | ||
|
|
f43de11121 | ||
|
|
4c1129188b | ||
|
|
34e04f5251 | ||
|
|
b613d65b36 | ||
|
|
66aec63f6b | ||
|
|
5b0d18bb3b | ||
|
|
1c5b43c218 | ||
|
|
c78cfb9fcf | ||
|
|
927d4dd06f | ||
|
|
afb75ef75a | ||
|
|
92181866a4 | ||
|
|
c97805c7f1 | ||
|
|
c20a139e58 | ||
|
|
4287d1032f | ||
|
|
8b784d7c10 | ||
|
|
8895f6420f | ||
|
|
bb10ed5b7d | ||
|
|
9dc315dbf3 | ||
|
|
677531531f | ||
|
|
70c89b14a9 | ||
|
|
7f7c94e0d5 | ||
|
|
e6f09e42a1 | ||
|
|
f0419b7502 | ||
|
|
f01072eb11 | ||
|
|
c88102d6cc | ||
|
|
847a2994f9 | ||
|
|
ab186c0608 | ||
|
|
349ae8ed27 | ||
|
|
0066b858d6 | ||
|
|
e12e720a99 | ||
|
|
c17f2e2560 | ||
|
|
d75bf235bb | ||
|
|
881d1e9594 | ||
|
|
45a443989a | ||
|
|
7880fb402a | ||
|
|
ac2f8c9141 | ||
|
|
e36e774382 | ||
|
|
b1be2dfbf4 | ||
|
|
32f3a11bf7 | ||
|
|
7d0c72f92e | ||
|
|
27e0e12595 | ||
|
|
f6ae6b3658 | ||
|
|
9e1d633244 | ||
|
|
6b28e72686 | ||
|
|
dfd3a06600 | ||
|
|
2c35a6f0e1 | ||
|
|
f956558656 | ||
|
|
32fa7006ff | ||
|
|
95acf71dbf | ||
|
|
5640c27cec | ||
|
|
a7c5e4f317 | ||
|
|
274682e736 | ||
|
|
b4b6ab2667 | ||
|
|
bbe9dd6760 | ||
|
|
2aa7adb3bd | ||
|
|
fb7e671c26 | ||
|
|
7420dba0c9 | ||
|
|
9a059bdce4 | ||
|
|
50c7269315 | ||
|
|
b4434a369b | ||
|
|
1c945ebfbf | ||
|
|
20d0915a03 | ||
|
|
21ee94739b | ||
|
|
9ebb894694 |
@@ -1,4 +0,0 @@
|
||||
DATABASE_URI=mongodb://127.0.0.1/payloadtests
|
||||
PAYLOAD_SECRET=laijflieawfjlweifjewalifjwe
|
||||
# PAYLOAD_CONFIG_PATH=MUST BE SET PROGRAMMATICALLY
|
||||
PAYLOAD_DROP_DATABASE=true
|
||||
@@ -8,3 +8,6 @@
|
||||
**/dist/**
|
||||
**/node_modules
|
||||
**/temp
|
||||
playwright.config.ts
|
||||
jest.config.js
|
||||
test/live-preview/next-app
|
||||
|
||||
@@ -1,6 +1,15 @@
|
||||
/** @type {import('eslint').Linter.Config} */
|
||||
module.exports = {
|
||||
extends: ['@payloadcms'],
|
||||
ignorePatterns: ['README.md', 'packages/**/*.spec.ts'],
|
||||
overrides: [
|
||||
{
|
||||
files: ['packages/**'],
|
||||
plugins: ['payload'],
|
||||
rules: {
|
||||
'payload/no-jsx-import-statements': 'warn',
|
||||
},
|
||||
},
|
||||
{
|
||||
files: ['scripts/**'],
|
||||
rules: {
|
||||
@@ -46,6 +55,10 @@ module.exports = {
|
||||
parserOptions: {
|
||||
project: ['./tsconfig.json'],
|
||||
tsconfigRootDir: __dirname,
|
||||
EXPERIMENTAL_useSourceOfProjectReferenceRedirect: true,
|
||||
EXPERIMENTAL_useProjectService: true,
|
||||
sourceType: 'module',
|
||||
ecmaVersion: 'latest',
|
||||
},
|
||||
root: true,
|
||||
}
|
||||
|
||||
@@ -16,3 +16,6 @@ fb7d1be2f3325d076b7c967b1730afcef37922c2
|
||||
|
||||
# lint and format create-payload-app
|
||||
5fd3d430001efe86515262ded5e26f00c1451181
|
||||
|
||||
# 3.0 prettier & lint everywhere
|
||||
6789e61488a1d3de56f472ac3214faf344030005
|
||||
|
||||
13
.github/CODEOWNERS
vendored
13
.github/CODEOWNERS
vendored
@@ -1,32 +1,24 @@
|
||||
# Order matters. The last matching pattern takes precedence.
|
||||
|
||||
### Catch-all ###
|
||||
* @denolfe @jmikrut @DanRibbens
|
||||
.* @denolfe @jmikrut @DanRibbens
|
||||
|
||||
### Core ###
|
||||
/packages/payload/ @denolfe @jmikrut @DanRibbens
|
||||
/packages/payload/src/uploads/ @denolfe
|
||||
/packages/payload/src/admin/ @jmikrut @jacobsfletch @JarrodMFlesch
|
||||
|
||||
### Adapters ###
|
||||
/packages/bundler-*/ @denolfe @jmikrut @DanRibbens @JarrodMFlesch
|
||||
/packages/db-*/ @denolfe @jmikrut @DanRibbens
|
||||
/packages/richtext-*/ @denolfe @jmikrut @DanRibbens @AlessioGr
|
||||
|
||||
### Plugins ###
|
||||
/packages/plugin-*/ @denolfe @jmikrut @DanRibbens @jacobsfletch @JarrodMFlesch @AlessioGr
|
||||
/packages/plugin-*/ @denolfe @jmikrut @DanRibbens
|
||||
/packages/plugin-cloud*/ @denolfe
|
||||
/packages/plugin-form-builder/ @jacobsfletch
|
||||
/packages/plugin-live-preview*/ @jacobsfletch
|
||||
/packages/plugin-nested-docs/ @jacobsfletch
|
||||
/packages/plugin-password-protection/ @jmikrut
|
||||
/packages/plugin-redirects/ @jacobsfletch
|
||||
/packages/plugin-search/ @jacobsfletch
|
||||
/packages/plugin-sentry/ @JessChowdhury
|
||||
/packages/plugin-seo/ @jacobsfletch
|
||||
/packages/plugin-stripe/ @jacobsfletch
|
||||
/packages/plugin-zapier/ @JarrodMFlesch
|
||||
|
||||
### Examples ###
|
||||
/examples/ @jacobsfletch
|
||||
@@ -35,8 +27,7 @@
|
||||
/examples/whitelabel/ @JessChowdhury
|
||||
|
||||
### Templates ###
|
||||
/templates/ @jacobsfletch
|
||||
/templates/blank/ @denolfe
|
||||
/templates/ @jacobsfletch @denolfe
|
||||
|
||||
### Misc ###
|
||||
/packages/create-payload-app/ @denolfe
|
||||
|
||||
95
.github/workflows/main.yml
vendored
95
.github/workflows/main.yml
vendored
@@ -2,9 +2,9 @@ name: build
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
types: [ opened, reopened, synchronize ]
|
||||
types: [opened, reopened, synchronize]
|
||||
push:
|
||||
branches: ['main', 'feat/next-poc']
|
||||
branches: ['main', 'alpha']
|
||||
|
||||
jobs:
|
||||
changes:
|
||||
@@ -18,7 +18,7 @@ jobs:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 25
|
||||
- uses: dorny/paths-filter@v2
|
||||
- uses: dorny/paths-filter@v3
|
||||
id: filter
|
||||
with:
|
||||
filters: |
|
||||
@@ -46,12 +46,12 @@ jobs:
|
||||
fetch-depth: 25
|
||||
|
||||
- name: Use Node.js 18
|
||||
uses: actions/setup-node@v3
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 18
|
||||
|
||||
- name: Install pnpm
|
||||
uses: pnpm/action-setup@v2
|
||||
uses: pnpm/action-setup@v3
|
||||
with:
|
||||
version: 8
|
||||
run_install: false
|
||||
@@ -61,7 +61,7 @@ jobs:
|
||||
run: |
|
||||
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
|
||||
|
||||
- uses: actions/cache@v3
|
||||
- uses: actions/cache@v4
|
||||
name: Setup pnpm cache
|
||||
with:
|
||||
path: ${{ env.STORE_PATH }}
|
||||
@@ -74,7 +74,7 @@ jobs:
|
||||
- run: pnpm run build:core
|
||||
|
||||
- name: Cache build
|
||||
uses: actions/cache@v3
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: ./*
|
||||
key: ${{ github.sha }}-${{ github.run_number }}
|
||||
@@ -90,12 +90,12 @@ jobs:
|
||||
fetch-depth: 25
|
||||
|
||||
- name: Use Node.js 18
|
||||
uses: actions/setup-node@v3
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 18
|
||||
|
||||
- name: Install pnpm
|
||||
uses: pnpm/action-setup@v2
|
||||
uses: pnpm/action-setup@v3
|
||||
with:
|
||||
version: 8
|
||||
run_install: false
|
||||
@@ -105,7 +105,7 @@ jobs:
|
||||
run: |
|
||||
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
|
||||
|
||||
- uses: actions/cache@v3
|
||||
- uses: actions/cache@v4
|
||||
name: Setup pnpm cache
|
||||
with:
|
||||
path: ${{ env.STORE_PATH }}
|
||||
@@ -123,7 +123,12 @@ jobs:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
database: [mongoose, postgres, postgres-custom-schema, postgres-uuid, supabase]
|
||||
database:
|
||||
- mongodb
|
||||
- postgres
|
||||
- postgres-custom-schema
|
||||
- postgres-uuid
|
||||
- supabase
|
||||
env:
|
||||
POSTGRES_USER: postgres
|
||||
POSTGRES_PASSWORD: postgres
|
||||
@@ -135,18 +140,18 @@ jobs:
|
||||
|
||||
steps:
|
||||
- name: Use Node.js 18
|
||||
uses: actions/setup-node@v3
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 18
|
||||
|
||||
- name: Install pnpm
|
||||
uses: pnpm/action-setup@v2
|
||||
uses: pnpm/action-setup@v3
|
||||
with:
|
||||
version: 8
|
||||
run_install: false
|
||||
|
||||
- name: Restore build
|
||||
uses: actions/cache@v3
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: ./*
|
||||
key: ${{ github.sha }}-${{ github.run_number }}
|
||||
@@ -157,7 +162,7 @@ jobs:
|
||||
- name: Start PostgreSQL
|
||||
uses: CasperWA/postgresql-action@v1.2
|
||||
with:
|
||||
postgresql version: '14' # See https://hub.docker.com/_/postgres for available versions
|
||||
postgresql version: '14' # See https://hub.docker.com/_/postgres for available versions
|
||||
postgresql db: ${{ env.POSTGRES_DB }}
|
||||
postgresql user: ${{ env.POSTGRES_USER }}
|
||||
postgresql password: ${{ env.POSTGRES_PASSWORD }}
|
||||
@@ -196,11 +201,8 @@ jobs:
|
||||
echo "POSTGRES_URL=postgresql://postgres:postgres@127.0.0.1:54322/postgres" >> $GITHUB_ENV
|
||||
if: matrix.database == 'supabase'
|
||||
|
||||
- name: Component Tests
|
||||
run: pnpm test:components
|
||||
|
||||
- name: Integration Tests
|
||||
run: pnpm test:int
|
||||
run: pnpm test:int --testPathIgnorePatterns=test/fields # Ignore fields tests until reworked
|
||||
env:
|
||||
NODE_OPTIONS: --max-old-space-size=8096
|
||||
PAYLOAD_DATABASE: ${{ matrix.database }}
|
||||
@@ -212,59 +214,79 @@ jobs:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
part: [ 1/8, 2/8, 3/8, 4/8, 5/8, 6/8, 7/8, 8/8 ]
|
||||
# find test -type f -name 'e2e.spec.ts' | sort | xargs dirname | xargs -I {} basename {}
|
||||
suite:
|
||||
- _community
|
||||
- access-control
|
||||
# - admin
|
||||
- auth
|
||||
# - field-error-states
|
||||
# - fields-relationship
|
||||
# - fields
|
||||
- fields/lexical
|
||||
- live-preview
|
||||
# - localization
|
||||
# - plugin-nested-docs
|
||||
# - plugin-seo
|
||||
# - refresh-permissions
|
||||
# - uploads
|
||||
# - versions
|
||||
|
||||
steps:
|
||||
- name: Use Node.js 18
|
||||
uses: actions/setup-node@v3
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 18
|
||||
|
||||
- name: Install pnpm
|
||||
uses: pnpm/action-setup@v2
|
||||
uses: pnpm/action-setup@v3
|
||||
with:
|
||||
version: 8
|
||||
run_install: false
|
||||
|
||||
- name: Restore build
|
||||
uses: actions/cache@v3
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: ./*
|
||||
key: ${{ github.sha }}-${{ github.run_number }}
|
||||
|
||||
- name: Install Playwright
|
||||
run: pnpm exec playwright install
|
||||
|
||||
- name: E2E Tests
|
||||
uses: nick-fields/retry@v2
|
||||
uses: nick-fields/retry@v3
|
||||
with:
|
||||
retry_on: error
|
||||
max_attempts: 2
|
||||
timeout_minutes: 15
|
||||
command: pnpm test:e2e --part ${{ matrix.part }} --bail
|
||||
command: pnpm test:e2e ${{ matrix.suite }}
|
||||
|
||||
- uses: actions/upload-artifact@v3
|
||||
- uses: actions/upload-artifact@v4
|
||||
if: always()
|
||||
with:
|
||||
name: test-results
|
||||
path: test-results/
|
||||
path: test/test-results/
|
||||
retention-days: 1
|
||||
|
||||
tests-type-generation:
|
||||
if: false # This should be replaced with gen on a real Payload project
|
||||
runs-on: ubuntu-latest
|
||||
needs: core-build
|
||||
|
||||
steps:
|
||||
- name: Use Node.js 18
|
||||
uses: actions/setup-node@v3
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 18
|
||||
|
||||
- name: Install pnpm
|
||||
uses: pnpm/action-setup@v2
|
||||
uses: pnpm/action-setup@v3
|
||||
with:
|
||||
version: 8
|
||||
run_install: false
|
||||
|
||||
- name: Restore build
|
||||
uses: actions/cache@v3
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: ./*
|
||||
key: ${{ github.sha }}-${{ github.run_number }}
|
||||
@@ -293,18 +315,18 @@ jobs:
|
||||
|
||||
steps:
|
||||
- name: Use Node.js 18
|
||||
uses: actions/setup-node@v3
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 18
|
||||
|
||||
- name: Install pnpm
|
||||
uses: pnpm/action-setup@v2
|
||||
uses: pnpm/action-setup@v3
|
||||
with:
|
||||
version: 8
|
||||
run_install: false
|
||||
|
||||
- name: Restore build
|
||||
uses: actions/cache@v3
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: ./*
|
||||
key: ${{ github.sha }}-${{ github.run_number }}
|
||||
@@ -314,16 +336,15 @@ jobs:
|
||||
|
||||
- name: Test ${{ matrix.pkg }}
|
||||
run: pnpm --filter ${{ matrix.pkg }} run test
|
||||
if: matrix.pkg != 'create-payload-app' # degit doesn't work within GitHub Actions
|
||||
|
||||
templates:
|
||||
needs: changes
|
||||
if: ${{ needs.changes.outputs.templates == 'true' }}
|
||||
if: false # Disable until templates are updated for 3.0
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
template: [ blank, website, ecommerce ]
|
||||
template: [blank, website, ecommerce]
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
@@ -331,7 +352,7 @@ jobs:
|
||||
fetch-depth: 25
|
||||
|
||||
- name: Use Node.js 18
|
||||
uses: actions/setup-node@v3
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 18
|
||||
|
||||
|
||||
6
.gitignore
vendored
6
.gitignore
vendored
@@ -8,12 +8,15 @@ test-results
|
||||
.devcontainer
|
||||
.localstack
|
||||
/migrations
|
||||
/media
|
||||
.localstack
|
||||
.turbo
|
||||
|
||||
.turbo
|
||||
|
||||
# Ignore test directory media folder/files
|
||||
/media
|
||||
/versions
|
||||
|
||||
# Created by https://www.toptal.com/developers/gitignore/api/node,macos,windows,webstorm,sublimetext,visualstudiocode
|
||||
# Edit at https://www.toptal.com/developers/gitignore?templates=node,macos,windows,webstorm,sublimetext,visualstudiocode
|
||||
|
||||
@@ -285,3 +288,4 @@ $RECYCLE.BIN/
|
||||
# End of https://www.toptal.com/developers/gitignore/api/node,macos,windows,webstorm,sublimetext,visualstudiocode
|
||||
|
||||
/build
|
||||
.swc
|
||||
5
.idea/runConfigurations/Run_Dev_Fields.xml
generated
5
.idea/runConfigurations/Run_Dev_Fields.xml
generated
@@ -1,5 +1,8 @@
|
||||
<component name="ProjectRunConfigurationManager">
|
||||
<configuration default="false" name="Run Dev Fields" type="NodeJSConfigurationType" application-parameters="fields" path-to-js-file="node_modules/.pnpm/nodemon@3.0.3/node_modules/nodemon/bin/nodemon.js" working-dir="$PROJECT_DIR$">
|
||||
<configuration default="false" name="Run Dev Fields" type="NodeJSConfigurationType" application-parameters="--no-deprecation fields" path-to-js-file="test/dev.js" working-dir="$PROJECT_DIR$">
|
||||
<envs>
|
||||
<env name="NODE_OPTIONS" value="--no-deprecation" />
|
||||
</envs>
|
||||
<method v="2" />
|
||||
</configuration>
|
||||
</component>
|
||||
5
.idea/runConfigurations/Run_Dev__community.xml
generated
5
.idea/runConfigurations/Run_Dev__community.xml
generated
@@ -1,5 +1,8 @@
|
||||
<component name="ProjectRunConfigurationManager">
|
||||
<configuration default="false" name="Run Dev _community" type="NodeJSConfigurationType" application-parameters="_community" path-to-js-file="node_modules/.pnpm/nodemon@3.0.3/node_modules/nodemon/bin/nodemon.js" working-dir="$PROJECT_DIR$">
|
||||
<configuration default="false" name="Run Dev _community" type="NodeJSConfigurationType" application-parameters="--no-deprecation _community" path-to-js-file="test/dev.js" working-dir="$PROJECT_DIR$">
|
||||
<envs>
|
||||
<env name="NODE_OPTIONS" value="--no-deprecation" />
|
||||
</envs>
|
||||
<method v="2" />
|
||||
</configuration>
|
||||
</component>
|
||||
@@ -1,16 +0,0 @@
|
||||
module.exports = {
|
||||
verbose: true,
|
||||
git: {
|
||||
requireCleanWorkingDir: false,
|
||||
commit: false,
|
||||
push: false,
|
||||
tag: false,
|
||||
},
|
||||
npm: {
|
||||
skipChecks: true,
|
||||
tag: 'beta',
|
||||
},
|
||||
hooks: {
|
||||
'before:init': ['pnpm install', 'pnpm clean', 'pnpm build'],
|
||||
},
|
||||
}
|
||||
15
.swcrc
Normal file
15
.swcrc
Normal file
@@ -0,0 +1,15 @@
|
||||
{
|
||||
"$schema": "https://json.schemastore.org/swcrc",
|
||||
"sourceMaps": "inline",
|
||||
"jsc": {
|
||||
"target": "esnext",
|
||||
"parser": {
|
||||
"syntax": "typescript",
|
||||
"tsx": true,
|
||||
"dts": true
|
||||
}
|
||||
},
|
||||
"module": {
|
||||
"type": "es6"
|
||||
}
|
||||
}
|
||||
7
.vscode/extensions.json
vendored
7
.vscode/extensions.json
vendored
@@ -1,3 +1,8 @@
|
||||
{
|
||||
"recommendations": ["esbenp.prettier-vscode", "dbaeumer.vscode-eslint"]
|
||||
"recommendations": [
|
||||
"dbaeumer.vscode-eslint",
|
||||
"esbenp.prettier-vscode",
|
||||
"firsttris.vscode-jest-runner",
|
||||
"ms-playwright.playwright"
|
||||
]
|
||||
}
|
||||
|
||||
27
.vscode/launch.json
vendored
27
.vscode/launch.json
vendored
@@ -3,12 +3,26 @@
|
||||
// Hover to view descriptions of existing attributes.
|
||||
"configurations": [
|
||||
{
|
||||
"command": "pnpm run dev _community -- --no-turbo",
|
||||
"command": "pnpm generate:types",
|
||||
"name": "Generate Types CLI",
|
||||
"request": "launch",
|
||||
"type": "node-terminal",
|
||||
"cwd": "${workspaceFolder}"
|
||||
},
|
||||
{
|
||||
"command": "node --no-deprecation test/dev.js fields",
|
||||
"cwd": "${workspaceFolder}",
|
||||
"name": "Run Dev Community",
|
||||
"request": "launch",
|
||||
"type": "node-terminal"
|
||||
},
|
||||
{
|
||||
"command": "pnpm run dev live-preview -- --no-turbo",
|
||||
"cwd": "${workspaceFolder}",
|
||||
"name": "Run Dev Live Preview",
|
||||
"request": "launch",
|
||||
"type": "node-terminal"
|
||||
},
|
||||
{
|
||||
"command": "pnpm run dev plugin-cloud-storage",
|
||||
"cwd": "${workspaceFolder}",
|
||||
@@ -102,17 +116,6 @@
|
||||
"request": "launch",
|
||||
"type": "node-terminal"
|
||||
},
|
||||
{
|
||||
"command": "ts-node ./packages/payload/src/bin/index.ts generate:types",
|
||||
"env": {
|
||||
"PAYLOAD_CONFIG_PATH": "test/_community/config.ts",
|
||||
"DISABLE_SWC": "true" // SWC messes up debugging the bin scripts
|
||||
},
|
||||
"name": "Generate Types CLI",
|
||||
"outputCapture": "std",
|
||||
"request": "launch",
|
||||
"type": "node-terminal"
|
||||
},
|
||||
{
|
||||
"command": "ts-node ./packages/payload/src/bin/index.ts migrate:status",
|
||||
"env": {
|
||||
|
||||
22
.vscode/settings.json
vendored
22
.vscode/settings.json
vendored
@@ -40,25 +40,5 @@
|
||||
"editor.codeActionsOnSave": {
|
||||
"source.fixAll.eslint": "explicit"
|
||||
}
|
||||
},
|
||||
"workbench.colorCustomizations": {
|
||||
"activityBar.activeBackground": "#8cb5b6",
|
||||
"activityBar.background": "#8cb5b6",
|
||||
"activityBar.foreground": "#15202b",
|
||||
"activityBar.inactiveForeground": "#15202b99",
|
||||
"activityBarBadge.background": "#9c639b",
|
||||
"activityBarBadge.foreground": "#e7e7e7",
|
||||
"commandCenter.border": "#15202b99",
|
||||
"sash.hoverBorder": "#8cb5b6",
|
||||
"statusBar.background": "#6da1a2",
|
||||
"statusBar.foreground": "#15202b",
|
||||
"statusBarItem.hoverBackground": "#568586",
|
||||
"statusBarItem.remoteBackground": "#6da1a2",
|
||||
"statusBarItem.remoteForeground": "#15202b",
|
||||
"titleBar.activeBackground": "#6da1a2",
|
||||
"titleBar.activeForeground": "#15202b",
|
||||
"titleBar.inactiveBackground": "#6da1a299",
|
||||
"titleBar.inactiveForeground": "#15202b99"
|
||||
},
|
||||
"peacock.color": "#6da1a2"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
/* THIS FILE WAS GENERATED AUTOMATICALLY BY PAYLOAD. */
|
||||
import type { Metadata } from 'next'
|
||||
|
||||
import config from '@payload-config'
|
||||
/* DO NOT MODIFY IT BECAUSE IT COULD BE REWRITTEN AT ANY TIME. */
|
||||
import { RootPage, generatePageMetadata } from '@payloadcms/next/views/Root/index.js'
|
||||
@@ -12,7 +14,7 @@ type Args = {
|
||||
}
|
||||
}
|
||||
|
||||
export const generateMetadata = ({ params, searchParams }: Args) =>
|
||||
export const generateMetadata = ({ params, searchParams }: Args): Promise<Metadata> =>
|
||||
generatePageMetadata({ config, params, searchParams })
|
||||
|
||||
const Page = ({ params, searchParams }: Args) => RootPage({ config, params, searchParams })
|
||||
|
||||
@@ -1,31 +1,37 @@
|
||||
'use client'
|
||||
|
||||
import { Page as PageType } from '@/payload-types'
|
||||
import { useLivePreview } from '../../../../../../packages/live-preview-react/src'
|
||||
import { useLivePreview } from '@payloadcms/live-preview-react'
|
||||
import React from 'react'
|
||||
import { PAYLOAD_SERVER_URL } from '@/app/_api/serverURL'
|
||||
import { Hero } from '@/app/_components/Hero'
|
||||
import { Blocks } from '@/app/_components/Blocks'
|
||||
|
||||
import type { Page as PageType } from '../../../../test/live-preview/payload-types.js'
|
||||
|
||||
import { PAYLOAD_SERVER_URL } from '../../_api/serverURL.js'
|
||||
import { Blocks } from '../../_components/Blocks/index.js'
|
||||
import { Gutter } from '../../_components/Gutter/index.js'
|
||||
import { Hero } from '../../_components/Hero/index.js'
|
||||
|
||||
export const PageClient: React.FC<{
|
||||
page: PageType
|
||||
}> = ({ page: initialPage }) => {
|
||||
const { data } = useLivePreview<PageType>({
|
||||
depth: 2,
|
||||
initialData: initialPage,
|
||||
serverURL: PAYLOAD_SERVER_URL,
|
||||
depth: 2,
|
||||
})
|
||||
|
||||
return (
|
||||
<React.Fragment>
|
||||
<Gutter>
|
||||
<h1 id="page-title">{data.title}</h1>
|
||||
</Gutter>
|
||||
<Hero {...data?.hero} />
|
||||
<Blocks
|
||||
blocks={[
|
||||
...(data?.layout ?? []),
|
||||
{
|
||||
blockType: 'relationships',
|
||||
blockName: 'Relationships',
|
||||
data: data,
|
||||
blockType: 'relationships',
|
||||
data,
|
||||
},
|
||||
]}
|
||||
disableTopPadding={
|
||||
@@ -1,18 +1,20 @@
|
||||
import { notFound } from 'next/navigation.js'
|
||||
import React from 'react'
|
||||
import { notFound } from 'next/navigation'
|
||||
|
||||
import { Page } from '../../../payload-types'
|
||||
import { fetchDocs } from '@/app/_api/fetchDocs'
|
||||
import { fetchDoc } from '@/app/_api/fetchDoc'
|
||||
import { PageClient } from './page.client'
|
||||
import type { Page } from '../../../../test/live-preview/payload-types.js'
|
||||
|
||||
import { fetchDoc } from '../../_api/fetchDoc.js'
|
||||
import { fetchDocs } from '../../_api/fetchDocs.js'
|
||||
import { PageClient } from './page.client.js'
|
||||
|
||||
// eslint-disable-next-line no-restricted-exports
|
||||
export default async function Page({ params: { slug = 'home' } }) {
|
||||
let page: Page | null = null
|
||||
|
||||
try {
|
||||
page = await fetchDoc<Page>({
|
||||
collection: 'pages',
|
||||
slug,
|
||||
collection: 'pages',
|
||||
})
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
@@ -1,19 +1,21 @@
|
||||
'use client'
|
||||
|
||||
import { Post as PostType } from '@/payload-types'
|
||||
import { useLivePreview } from '../../../../../../../packages/live-preview-react/src'
|
||||
import { useLivePreview } from '@payloadcms/live-preview-react'
|
||||
import React from 'react'
|
||||
import { PAYLOAD_SERVER_URL } from '@/app/_api/serverURL'
|
||||
import { Blocks } from '@/app/_components/Blocks'
|
||||
import { PostHero } from '@/app/_heros/PostHero'
|
||||
|
||||
import type { Post as PostType } from '../../../../../test/live-preview/payload-types.js'
|
||||
|
||||
import { PAYLOAD_SERVER_URL } from '../../../_api/serverURL.js'
|
||||
import { Blocks } from '../../../_components/Blocks/index.js'
|
||||
import { PostHero } from '../../../_heros/PostHero/index.js'
|
||||
|
||||
export const PostClient: React.FC<{
|
||||
post: PostType
|
||||
}> = ({ post: initialPost }) => {
|
||||
const { data } = useLivePreview<PostType>({
|
||||
depth: 2,
|
||||
initialData: initialPost,
|
||||
serverURL: PAYLOAD_SERVER_URL,
|
||||
depth: 2,
|
||||
})
|
||||
|
||||
return (
|
||||
@@ -21,12 +23,11 @@ export const PostClient: React.FC<{
|
||||
<PostHero post={data} />
|
||||
<Blocks blocks={data?.layout} />
|
||||
<Blocks
|
||||
disableTopPadding
|
||||
blocks={[
|
||||
{
|
||||
blockType: 'relatedPosts',
|
||||
blockName: 'Related Posts',
|
||||
relationTo: 'posts',
|
||||
blockType: 'relatedPosts',
|
||||
docs: data?.relatedPosts,
|
||||
introContent: [
|
||||
{
|
||||
type: 'h4',
|
||||
@@ -44,12 +45,12 @@ export const PostClient: React.FC<{
|
||||
},
|
||||
{
|
||||
type: 'link',
|
||||
url: `/admin/collections/posts/${data?.id}`,
|
||||
children: [
|
||||
{
|
||||
text: 'navigate to the admin dashboard',
|
||||
},
|
||||
],
|
||||
url: `/admin/collections/posts/${data?.id}`,
|
||||
},
|
||||
{
|
||||
text: '.',
|
||||
@@ -57,9 +58,10 @@ export const PostClient: React.FC<{
|
||||
],
|
||||
},
|
||||
],
|
||||
docs: data?.relatedPosts,
|
||||
relationTo: 'posts',
|
||||
},
|
||||
]}
|
||||
disableTopPadding
|
||||
/>
|
||||
</React.Fragment>
|
||||
)
|
||||
@@ -1,18 +1,19 @@
|
||||
import { notFound } from 'next/navigation.js'
|
||||
import React from 'react'
|
||||
import { notFound } from 'next/navigation'
|
||||
|
||||
import { Post } from '../../../../payload-types'
|
||||
import { fetchDoc } from '../../../_api/fetchDoc'
|
||||
import { fetchDocs } from '../../../_api/fetchDocs'
|
||||
import { PostClient } from './page.client'
|
||||
import type { Post } from '../../../../../test/live-preview/payload-types.js'
|
||||
|
||||
import { fetchDoc } from '../../../_api/fetchDoc.js'
|
||||
import { fetchDocs } from '../../../_api/fetchDocs.js'
|
||||
import { PostClient } from './page.client.js'
|
||||
|
||||
export default async function Post({ params: { slug = '' } }) {
|
||||
let post: Post | null = null
|
||||
|
||||
try {
|
||||
post = await fetchDoc<Post>({
|
||||
collection: 'posts',
|
||||
slug,
|
||||
collection: 'posts',
|
||||
})
|
||||
} catch (error) {
|
||||
console.error(error) // eslint-disable-line no-console
|
||||
@@ -1,14 +1,14 @@
|
||||
import QueryString from 'qs'
|
||||
import type { Config } from '../../payload-types'
|
||||
import { PAYLOAD_SERVER_URL } from './serverURL'
|
||||
|
||||
import { PAYLOAD_SERVER_URL } from './serverURL.js'
|
||||
|
||||
export const fetchDoc = async <T>(args: {
|
||||
collection: keyof Config['collections']
|
||||
slug?: string
|
||||
id?: string
|
||||
collection: string
|
||||
depth?: number
|
||||
id?: string
|
||||
slug?: string
|
||||
}): Promise<T> => {
|
||||
const { collection, slug, id, depth = 2 } = args || {}
|
||||
const { id, slug, collection, depth = 2 } = args || {}
|
||||
|
||||
const queryString = QueryString.stringify(
|
||||
{
|
||||
@@ -19,11 +19,11 @@ export const fetchDoc = async <T>(args: {
|
||||
)
|
||||
|
||||
const doc: T = await fetch(`${PAYLOAD_SERVER_URL}/api/${collection}${queryString}`, {
|
||||
method: 'GET',
|
||||
cache: 'no-store',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
method: 'GET',
|
||||
})
|
||||
?.then((res) => res.json())
|
||||
?.then((res) => {
|
||||
@@ -1,13 +1,12 @@
|
||||
import type { Config } from '../../payload-types'
|
||||
import { PAYLOAD_SERVER_URL } from './serverURL'
|
||||
import { PAYLOAD_SERVER_URL } from './serverURL.js'
|
||||
|
||||
export const fetchDocs = async <T>(collection: keyof Config['collections']): Promise<T[]> => {
|
||||
export const fetchDocs = async <T>(collection: string): Promise<T[]> => {
|
||||
const docs: T[] = await fetch(`${PAYLOAD_SERVER_URL}/api/${collection}?depth=0&limit=100`, {
|
||||
method: 'GET',
|
||||
cache: 'no-store',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
method: 'GET',
|
||||
})
|
||||
?.then((res) => res.json())
|
||||
?.then((res) => {
|
||||
@@ -1,15 +1,16 @@
|
||||
import type { Footer } from '../../payload-types'
|
||||
import { PAYLOAD_SERVER_URL } from './serverURL'
|
||||
import type { Footer } from '../../../test/live-preview/payload-types.js'
|
||||
|
||||
import { PAYLOAD_SERVER_URL } from './serverURL.js'
|
||||
|
||||
export async function fetchFooter(): Promise<Footer> {
|
||||
if (!PAYLOAD_SERVER_URL) throw new Error('PAYLOAD_SERVER_URL not found')
|
||||
|
||||
const footer = await fetch(`${PAYLOAD_SERVER_URL}/api/globals/footer`, {
|
||||
method: 'GET',
|
||||
cache: 'no-store',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
method: 'GET',
|
||||
})
|
||||
.then((res) => {
|
||||
if (!res.ok) throw new Error('Error fetching doc')
|
||||
@@ -1,15 +1,16 @@
|
||||
import type { Header } from '../../payload-types'
|
||||
import { PAYLOAD_SERVER_URL } from './serverURL'
|
||||
import type { Header } from '../../../test/live-preview/payload-types.js'
|
||||
|
||||
import { PAYLOAD_SERVER_URL } from './serverURL.js'
|
||||
|
||||
export async function fetchHeader(): Promise<Header> {
|
||||
if (!PAYLOAD_SERVER_URL) throw new Error('PAYLOAD_SERVER_URL not found')
|
||||
|
||||
const header = await fetch(`${PAYLOAD_SERVER_URL}/api/globals/header`, {
|
||||
method: 'GET',
|
||||
cache: 'no-store',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
method: 'GET',
|
||||
})
|
||||
?.then((res) => {
|
||||
if (!res.ok) throw new Error('Error fetching doc')
|
||||
@@ -1,10 +1,10 @@
|
||||
import React from 'react'
|
||||
|
||||
import { CollectionArchive } from '../../_components/CollectionArchive'
|
||||
import { Gutter } from '../../_components/Gutter'
|
||||
import RichText from '../../_components/RichText'
|
||||
import { ArchiveBlockProps } from './types'
|
||||
import type { ArchiveBlockProps } from './types.js'
|
||||
|
||||
import { CollectionArchive } from '../../_components/CollectionArchive/index.js'
|
||||
import { Gutter } from '../../_components/Gutter/index.js'
|
||||
import RichText from '../../_components/RichText/index.js'
|
||||
import classes from './index.module.scss'
|
||||
|
||||
export const ArchiveBlock: React.FC<
|
||||
@@ -13,33 +13,33 @@ export const ArchiveBlock: React.FC<
|
||||
}
|
||||
> = (props) => {
|
||||
const {
|
||||
introContent,
|
||||
id,
|
||||
relationTo,
|
||||
populateBy,
|
||||
categories,
|
||||
introContent,
|
||||
limit,
|
||||
populateBy,
|
||||
populatedDocs,
|
||||
populatedDocsTotal,
|
||||
categories,
|
||||
relationTo,
|
||||
selectedDocs,
|
||||
} = props
|
||||
|
||||
return (
|
||||
<div id={`block-${id}`} className={classes.archiveBlock}>
|
||||
<div className={classes.archiveBlock} id={`block-${id}`}>
|
||||
{introContent && (
|
||||
<Gutter className={classes.introContent}>
|
||||
<RichText content={introContent} />
|
||||
</Gutter>
|
||||
)}
|
||||
<CollectionArchive
|
||||
populateBy={populateBy}
|
||||
relationTo={relationTo}
|
||||
populatedDocs={populatedDocs}
|
||||
populatedDocsTotal={populatedDocsTotal}
|
||||
categories={categories}
|
||||
limit={limit}
|
||||
sort="-publishedDate"
|
||||
populateBy={populateBy}
|
||||
populatedDocs={populatedDocs}
|
||||
populatedDocsTotal={populatedDocsTotal}
|
||||
relationTo={relationTo}
|
||||
selectedDocs={selectedDocs}
|
||||
sort="-publishedDate"
|
||||
/>
|
||||
</div>
|
||||
)
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { Page } from '../../../payload-types'
|
||||
import type { Page } from '../../../../test/live-preview/payload-types.js'
|
||||
|
||||
export type ArchiveBlockProps = Extract<
|
||||
Exclude<Page['layout'], undefined>[0],
|
||||
@@ -1,11 +1,11 @@
|
||||
import React from 'react'
|
||||
|
||||
import { Page } from '../../../payload-types'
|
||||
import { Gutter } from '../../_components/Gutter'
|
||||
import { CMSLink } from '../../_components/Link'
|
||||
import RichText from '../../_components/RichText'
|
||||
import { VerticalPadding } from '../../_components/VerticalPadding'
|
||||
import type { Page } from '../../../../test/live-preview/payload-types.js'
|
||||
|
||||
import { Gutter } from '../../_components/Gutter/index.js'
|
||||
import { CMSLink } from '../../_components/Link/index.js'
|
||||
import RichText from '../../_components/RichText/index.js'
|
||||
import { VerticalPadding } from '../../_components/VerticalPadding/index.js'
|
||||
import classes from './index.module.scss'
|
||||
|
||||
type Props = Extract<Exclude<Page['layout'], undefined>[0], { blockType: 'cta' }>
|
||||
@@ -14,7 +14,7 @@ export const CallToActionBlock: React.FC<
|
||||
Props & {
|
||||
id?: string
|
||||
}
|
||||
> = ({ links, richText, invertBackground }) => {
|
||||
> = ({ invertBackground, links, richText }) => {
|
||||
return (
|
||||
<Gutter>
|
||||
<VerticalPadding
|
||||
@@ -1,10 +1,10 @@
|
||||
import React, { Fragment } from 'react'
|
||||
|
||||
import { Page } from '../../../payload-types'
|
||||
import { Gutter } from '../../_components/Gutter'
|
||||
import { CMSLink } from '../../_components/Link'
|
||||
import RichText from '../../_components/RichText'
|
||||
import type { Page } from '../../../../test/live-preview/payload-types.js'
|
||||
|
||||
import { Gutter } from '../../_components/Gutter/index.js'
|
||||
import { CMSLink } from '../../_components/Link/index.js'
|
||||
import RichText from '../../_components/RichText/index.js'
|
||||
import classes from './index.module.scss'
|
||||
|
||||
type Props = Extract<Exclude<Page['layout'], undefined>[0], { blockType: 'content' }>
|
||||
@@ -22,10 +22,10 @@ export const ContentBlock: React.FC<
|
||||
{columns && columns.length > 0 ? (
|
||||
<Fragment>
|
||||
{columns.map((col, index) => {
|
||||
const { enableLink, richText, link, size } = col
|
||||
const { enableLink, link, richText, size } = col
|
||||
|
||||
return (
|
||||
<div key={index} className={[classes.column, classes[`column--${size}`]].join(' ')}>
|
||||
<div className={[classes.column, classes[`column--${size}`]].join(' ')} key={index}>
|
||||
<RichText content={richText} />
|
||||
{enableLink && <CMSLink className={classes.link} {...link} />}
|
||||
</div>
|
||||
@@ -1,16 +1,17 @@
|
||||
import type { StaticImageData } from 'next/image.js'
|
||||
|
||||
import React from 'react'
|
||||
import { StaticImageData } from 'next/image'
|
||||
|
||||
import { Page } from '../../../payload-types'
|
||||
import { Gutter } from '../../_components/Gutter'
|
||||
import { Media } from '../../_components/Media'
|
||||
import RichText from '../../_components/RichText'
|
||||
import type { Page } from '../../../../test/live-preview/payload-types.js'
|
||||
|
||||
import { Gutter } from '../../_components/Gutter/index.js'
|
||||
import { Media } from '../../_components/Media/index.js'
|
||||
import RichText from '../../_components/RichText/index.js'
|
||||
import classes from './index.module.scss'
|
||||
|
||||
type Props = Extract<Exclude<Page['layout'], undefined>[0], { blockType: 'mediaBlock' }> & {
|
||||
staticImage?: StaticImageData
|
||||
id?: string
|
||||
staticImage?: StaticImageData
|
||||
}
|
||||
|
||||
export const MediaBlock: React.FC<Props> = (props) => {
|
||||
@@ -1,22 +1,22 @@
|
||||
import React from 'react'
|
||||
|
||||
import { Post } from '../../../payload-types'
|
||||
import { Card } from '../../_components/Card'
|
||||
import { Gutter } from '../../_components/Gutter'
|
||||
import RichText from '../../_components/RichText'
|
||||
import type { Post } from '../../../../test/live-preview/payload-types.js'
|
||||
|
||||
import { Card } from '../../_components/Card/index.js'
|
||||
import { Gutter } from '../../_components/Gutter/index.js'
|
||||
import RichText from '../../_components/RichText/index.js'
|
||||
import classes from './index.module.scss'
|
||||
|
||||
export type RelatedPostsProps = {
|
||||
blockType: 'relatedPosts'
|
||||
blockName: string
|
||||
blockType: 'relatedPosts'
|
||||
docs?: (Post | string)[] | null
|
||||
introContent?: any
|
||||
docs?: (string | Post)[] | null
|
||||
relationTo: 'posts'
|
||||
}
|
||||
|
||||
export const RelatedPosts: React.FC<RelatedPostsProps> = (props) => {
|
||||
const { introContent, docs, relationTo } = props
|
||||
const { docs, introContent, relationTo } = props
|
||||
|
||||
return (
|
||||
<div className={classes.relatedPosts}>
|
||||
@@ -32,7 +32,6 @@ export const RelatedPosts: React.FC<RelatedPostsProps> = (props) => {
|
||||
|
||||
return (
|
||||
<div
|
||||
key={index}
|
||||
className={[
|
||||
classes.column,
|
||||
docs.length === 2 && classes['cols-half'],
|
||||
@@ -40,8 +39,9 @@ export const RelatedPosts: React.FC<RelatedPostsProps> = (props) => {
|
||||
]
|
||||
.filter(Boolean)
|
||||
.join(' ')}
|
||||
key={index}
|
||||
>
|
||||
<Card relationTo={relationTo} doc={doc} showCategories />
|
||||
<Card doc={doc} relationTo={relationTo} showCategories />
|
||||
</div>
|
||||
)
|
||||
})}
|
||||
@@ -1,14 +1,14 @@
|
||||
import React, { Fragment } from 'react'
|
||||
|
||||
import { Page } from '../../../payload-types'
|
||||
import type { Page } from '../../../../test/live-preview/payload-types.js'
|
||||
|
||||
import { Gutter } from '../../_components/Gutter/index.js'
|
||||
import RichText from '../../_components/RichText/index.js'
|
||||
import classes from './index.module.scss'
|
||||
import { Gutter } from '@/app/_components/Gutter'
|
||||
import RichText from '@/app/_components/RichText'
|
||||
|
||||
export type RelationshipsBlockProps = {
|
||||
blockType: 'relationships'
|
||||
blockName: string
|
||||
blockType: 'relationships'
|
||||
data: Page
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ export const RelationshipsBlock: React.FC<RelationshipsBlockProps> = (props) =>
|
||||
<b>Rich Text — Lexical:</b>
|
||||
</p>
|
||||
{data?.richTextLexical && (
|
||||
<RichText serializer="lexical" content={data.richTextLexical} renderUploadFilenameOnly />
|
||||
<RichText content={data.richTextLexical} renderUploadFilenameOnly serializer="lexical" />
|
||||
)}
|
||||
<p>
|
||||
<b>Upload:</b>
|
||||
@@ -3,17 +3,17 @@ import React from 'react'
|
||||
import classes from './index.module.scss'
|
||||
|
||||
type Props = {
|
||||
invert?: boolean | null
|
||||
className?: string
|
||||
children?: React.ReactNode
|
||||
className?: string
|
||||
id?: string
|
||||
invert?: boolean | null
|
||||
}
|
||||
|
||||
export const BackgroundColor: React.FC<Props> = (props) => {
|
||||
const { id, className, children, invert } = props
|
||||
const { id, children, className, invert } = props
|
||||
|
||||
return (
|
||||
<div id={id} className={[invert && classes.invert, className].filter(Boolean).join(' ')}>
|
||||
<div className={[invert && classes.invert, className].filter(Boolean).join(' ')} id={id}>
|
||||
{children}
|
||||
</div>
|
||||
)
|
||||
@@ -1,21 +1,24 @@
|
||||
import React, { Fragment } from 'react'
|
||||
|
||||
import { Page } from '../../../payload-types.js'
|
||||
import { ArchiveBlock } from '../../_blocks/ArchiveBlock'
|
||||
import { CallToActionBlock } from '../../_blocks/CallToAction'
|
||||
import { ContentBlock } from '../../_blocks/Content'
|
||||
import { MediaBlock } from '../../_blocks/MediaBlock'
|
||||
import { RelatedPosts, type RelatedPostsProps } from '../../_blocks/RelatedPosts'
|
||||
import { toKebabCase } from '../../_utilities/toKebabCase'
|
||||
import { BackgroundColor } from '../BackgroundColor'
|
||||
import { VerticalPadding, VerticalPaddingOptions } from '../VerticalPadding'
|
||||
import { RelationshipsBlock, RelationshipsBlockProps } from '../../_blocks/Relationships'
|
||||
import type { Page } from '../../../../test/live-preview/payload-types.js'
|
||||
import type { RelationshipsBlockProps } from '../../_blocks/Relationships/index.js'
|
||||
import type { VerticalPaddingOptions } from '../VerticalPadding/index.js'
|
||||
|
||||
import { ArchiveBlock } from '../../_blocks/ArchiveBlock/index.js'
|
||||
import { CallToActionBlock } from '../../_blocks/CallToAction/index.js'
|
||||
import { ContentBlock } from '../../_blocks/Content/index.js'
|
||||
import { MediaBlock } from '../../_blocks/MediaBlock/index.js'
|
||||
import { RelatedPosts, type RelatedPostsProps } from '../../_blocks/RelatedPosts/index.js'
|
||||
import { RelationshipsBlock } from '../../_blocks/Relationships/index.js'
|
||||
import { toKebabCase } from '../../_utilities/toKebabCase.js'
|
||||
import { BackgroundColor } from '../BackgroundColor/index.js'
|
||||
import { VerticalPadding } from '../VerticalPadding/index.js'
|
||||
|
||||
const blockComponents = {
|
||||
cta: CallToActionBlock,
|
||||
content: ContentBlock,
|
||||
mediaBlock: MediaBlock,
|
||||
archive: ArchiveBlock,
|
||||
content: ContentBlock,
|
||||
cta: CallToActionBlock,
|
||||
mediaBlock: MediaBlock,
|
||||
relatedPosts: RelatedPosts,
|
||||
relationships: RelationshipsBlock,
|
||||
}
|
||||
@@ -26,7 +29,7 @@ export const Blocks: React.FC<{
|
||||
blocks?: (Block | RelatedPostsProps | RelationshipsBlockProps)[] | null
|
||||
disableTopPadding?: boolean
|
||||
}> = (props) => {
|
||||
const { disableTopPadding, blocks } = props
|
||||
const { blocks, disableTopPadding } = props
|
||||
|
||||
const hasBlocks = blocks && Array.isArray(blocks) && blocks.length > 0
|
||||
|
||||
@@ -66,8 +69,8 @@ export const Blocks: React.FC<{
|
||||
|
||||
if (Block) {
|
||||
return (
|
||||
<BackgroundColor key={index} invert={blockIsInverted}>
|
||||
<VerticalPadding top={paddingTop} bottom={paddingBottom}>
|
||||
<BackgroundColor invert={blockIsInverted} key={index}>
|
||||
<VerticalPadding bottom={paddingBottom} top={paddingTop}>
|
||||
{/* @ts-expect-error */}
|
||||
<Block id={toKebabCase(blockName)} {...block} />
|
||||
</VerticalPadding>
|
||||
@@ -1,38 +1,42 @@
|
||||
'use client'
|
||||
|
||||
import React, { ElementType } from 'react'
|
||||
import Link from 'next/link'
|
||||
import type { ElementType } from 'react'
|
||||
|
||||
import LinkWithDefault from 'next/link.js'
|
||||
import React from 'react'
|
||||
|
||||
import classes from './index.module.scss'
|
||||
|
||||
const Link = (LinkWithDefault.default || LinkWithDefault) as typeof LinkWithDefault.default
|
||||
|
||||
export type Props = {
|
||||
label?: string
|
||||
appearance?: 'default' | 'primary' | 'secondary' | 'none'
|
||||
el?: 'button' | 'link' | 'a'
|
||||
onClick?: () => void
|
||||
href?: string
|
||||
newTab?: boolean
|
||||
appearance?: 'default' | 'none' | 'primary' | 'secondary'
|
||||
className?: string
|
||||
type?: 'submit' | 'button'
|
||||
disabled?: boolean
|
||||
el?: 'a' | 'button' | 'link'
|
||||
href?: string
|
||||
invert?: boolean
|
||||
label?: string
|
||||
newTab?: boolean
|
||||
onClick?: () => void
|
||||
type?: 'button' | 'submit'
|
||||
}
|
||||
|
||||
export const Button: React.FC<Props> = ({
|
||||
el: elFromProps = 'link',
|
||||
label,
|
||||
newTab,
|
||||
href,
|
||||
type = 'button',
|
||||
appearance,
|
||||
className: classNameFromProps,
|
||||
onClick,
|
||||
type = 'button',
|
||||
disabled,
|
||||
el: elFromProps = 'link',
|
||||
href,
|
||||
invert,
|
||||
label,
|
||||
newTab,
|
||||
onClick,
|
||||
}) => {
|
||||
let el = elFromProps
|
||||
|
||||
const newTabProps = newTab ? { target: '_blank', rel: 'noopener noreferrer' } : {}
|
||||
const newTabProps = newTab ? { rel: 'noopener noreferrer', target: '_blank' } : {}
|
||||
|
||||
const className = [
|
||||
classes.button,
|
||||
@@ -53,7 +57,7 @@ export const Button: React.FC<Props> = ({
|
||||
|
||||
if (el === 'link') {
|
||||
return (
|
||||
<Link href={href || ''} className={className} {...newTabProps} onClick={onClick}>
|
||||
<Link className={className} href={href || ''} {...newTabProps} onClick={onClick}>
|
||||
{content}
|
||||
</Link>
|
||||
)
|
||||
@@ -63,12 +67,12 @@ export const Button: React.FC<Props> = ({
|
||||
|
||||
return (
|
||||
<Element
|
||||
href={href}
|
||||
className={className}
|
||||
href={href}
|
||||
type={type}
|
||||
{...newTabProps}
|
||||
onClick={onClick}
|
||||
disabled={disabled}
|
||||
onClick={onClick}
|
||||
>
|
||||
{content}
|
||||
</Element>
|
||||
@@ -1,37 +1,39 @@
|
||||
import LinkWithDefault from 'next/link.js'
|
||||
import React, { Fragment } from 'react'
|
||||
import Link from 'next/link'
|
||||
|
||||
import { Post } from '../../../payload-types'
|
||||
import { Media } from '../Media'
|
||||
import type { Post } from '../../../../test/live-preview/payload-types.js'
|
||||
|
||||
import { Media } from '../Media/index.js'
|
||||
import classes from './index.module.scss'
|
||||
|
||||
const Link = (LinkWithDefault.default || LinkWithDefault) as typeof LinkWithDefault.default
|
||||
|
||||
export const Card: React.FC<{
|
||||
alignItems?: 'center'
|
||||
className?: string
|
||||
showCategories?: boolean
|
||||
hideImagesOnMobile?: boolean
|
||||
title?: string
|
||||
relationTo?: 'posts'
|
||||
doc?: Post
|
||||
hideImagesOnMobile?: boolean
|
||||
orientation?: 'horizontal' | 'vertical'
|
||||
relationTo?: 'posts'
|
||||
showCategories?: boolean
|
||||
title?: string
|
||||
}> = (props) => {
|
||||
const {
|
||||
className,
|
||||
doc,
|
||||
orientation = 'vertical',
|
||||
relationTo,
|
||||
showCategories,
|
||||
title: titleFromProps,
|
||||
doc,
|
||||
className,
|
||||
orientation = 'vertical',
|
||||
} = props
|
||||
|
||||
const { slug, title, categories, meta } = doc || {}
|
||||
const { slug, categories, meta, title } = doc || {}
|
||||
const { description, image: metaImage } = meta || {}
|
||||
|
||||
const hasCategories = categories && Array.isArray(categories) && categories.length > 0
|
||||
const titleToUse = titleFromProps || title
|
||||
const sanitizedDescription = description?.replace(/\s/g, ' ') // replace non-breaking space with white space
|
||||
const href = `/${relationTo}/${slug}`
|
||||
const href = `/live-preview/${relationTo}/${slug}`
|
||||
|
||||
return (
|
||||
<div
|
||||
@@ -39,10 +41,10 @@ export const Card: React.FC<{
|
||||
.filter(Boolean)
|
||||
.join(' ')}
|
||||
>
|
||||
<Link href={href} className={classes.mediaWrapper}>
|
||||
<Link className={classes.mediaWrapper} href={href}>
|
||||
{!metaImage && <div className={classes.placeholder}>No image</div>}
|
||||
{metaImage && typeof metaImage !== 'string' && (
|
||||
<Media imgClassName={classes.image} resource={metaImage} fill />
|
||||
<Media fill imgClassName={classes.image} resource={metaImage} />
|
||||
)}
|
||||
</Link>
|
||||
<div className={classes.content}>
|
||||
@@ -70,7 +72,7 @@ export const Card: React.FC<{
|
||||
)}
|
||||
{titleToUse && (
|
||||
<h4 className={classes.title}>
|
||||
<Link href={href} className={classes.titleLink}>
|
||||
<Link className={classes.titleLink} href={href}>
|
||||
{titleToUse}
|
||||
</Link>
|
||||
</h4>
|
||||
@@ -6,19 +6,19 @@ export const Chevron: React.FC<{
|
||||
}> = ({ className, rotate }) => {
|
||||
return (
|
||||
<svg
|
||||
width="100%"
|
||||
height="100%"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
viewBox="0 0 24 24"
|
||||
className={className}
|
||||
height="100%"
|
||||
style={{
|
||||
transform: typeof rotate === 'number' ? `rotate(${rotate || 0}deg)` : undefined,
|
||||
}}
|
||||
viewBox="0 0 24 24"
|
||||
width="100%"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
>
|
||||
<path
|
||||
d="M23.245 4l-11.245 14.374-11.219-14.374-.781.619 12 15.381 12-15.391-.755-.609z"
|
||||
stroke="currentColor"
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
vectorEffect="non-scaling-stroke"
|
||||
/>
|
||||
</svg>
|
||||
@@ -1,58 +1,58 @@
|
||||
'use client'
|
||||
|
||||
import React, { Fragment, useCallback, useEffect, useRef, useState } from 'react'
|
||||
import qs from 'qs'
|
||||
import React, { Fragment, useCallback, useEffect, useRef, useState } from 'react'
|
||||
|
||||
import { Post } from '../../../../payload-types'
|
||||
import type { ArchiveBlockProps } from '../../../_blocks/ArchiveBlock/types'
|
||||
import { Card } from '../../Card'
|
||||
import { Gutter } from '../../Gutter'
|
||||
import { PageRange } from '../../PageRange'
|
||||
import { Pagination } from '../../Pagination'
|
||||
import type { Post } from '../../../../../test/live-preview/payload-types.js'
|
||||
import type { ArchiveBlockProps } from '../../../_blocks/ArchiveBlock/types.js'
|
||||
|
||||
import { PAYLOAD_SERVER_URL } from '../../../_api/serverURL.js'
|
||||
import { Card } from '../../Card/index.js'
|
||||
import { Gutter } from '../../Gutter/index.js'
|
||||
import { PageRange } from '../../PageRange/index.js'
|
||||
import { Pagination } from '../../Pagination/index.js'
|
||||
import classes from './index.module.scss'
|
||||
import { PAYLOAD_SERVER_URL } from '@/app/_api/serverURL'
|
||||
|
||||
type Result = {
|
||||
totalDocs: number
|
||||
docs: (Post | string)[]
|
||||
page: number
|
||||
totalPages: number
|
||||
hasPrevPage: boolean
|
||||
hasNextPage: boolean
|
||||
hasPrevPage: boolean
|
||||
nextPage: number
|
||||
page: number
|
||||
prevPage: number
|
||||
totalDocs: number
|
||||
totalPages: number
|
||||
}
|
||||
|
||||
export type Props = Omit<ArchiveBlockProps, 'blockType'> & {
|
||||
className?: string
|
||||
showPageRange?: boolean
|
||||
onResultChange?: (result: Result) => void // eslint-disable-line no-unused-vars
|
||||
showPageRange?: boolean
|
||||
sort?: string
|
||||
}
|
||||
|
||||
export const CollectionArchiveByCollection: React.FC<Props> = (props) => {
|
||||
const {
|
||||
categories: catsFromProps,
|
||||
className,
|
||||
relationTo,
|
||||
showPageRange,
|
||||
onResultChange,
|
||||
sort = '-createdAt',
|
||||
limit = 10,
|
||||
onResultChange,
|
||||
populatedDocs,
|
||||
populatedDocsTotal,
|
||||
categories: catsFromProps,
|
||||
relationTo,
|
||||
showPageRange,
|
||||
sort = '-createdAt',
|
||||
} = props
|
||||
|
||||
const [results, setResults] = useState<Result>({
|
||||
totalDocs: typeof populatedDocsTotal === 'number' ? populatedDocsTotal : 0,
|
||||
docs: populatedDocs?.map((doc) => doc.value) || [],
|
||||
page: 1,
|
||||
totalPages: 1,
|
||||
hasPrevPage: false,
|
||||
hasNextPage: false,
|
||||
prevPage: 1,
|
||||
hasPrevPage: false,
|
||||
nextPage: 1,
|
||||
page: 1,
|
||||
prevPage: 1,
|
||||
totalDocs: typeof populatedDocsTotal === 'number' ? populatedDocsTotal : 0,
|
||||
totalPages: 1,
|
||||
})
|
||||
|
||||
const [isLoading, setIsLoading] = useState(false)
|
||||
@@ -77,12 +77,10 @@ export const CollectionArchiveByCollection: React.FC<Props> = (props) => {
|
||||
}, [isLoading, scrollToRef, results])
|
||||
|
||||
useEffect(() => {
|
||||
let timer: NodeJS.Timeout
|
||||
|
||||
// hydrate the block with fresh content after first render
|
||||
// don't show loader unless the request takes longer than x ms
|
||||
// and don't show it during initial hydration
|
||||
timer = setTimeout(() => {
|
||||
const timer = setTimeout(() => {
|
||||
if (hasHydrated) {
|
||||
setIsLoading(true)
|
||||
}
|
||||
@@ -90,6 +88,9 @@ export const CollectionArchiveByCollection: React.FC<Props> = (props) => {
|
||||
|
||||
const searchQuery = qs.stringify(
|
||||
{
|
||||
depth: 1,
|
||||
limit,
|
||||
page,
|
||||
sort,
|
||||
where: {
|
||||
...(catsFromProps && catsFromProps?.length > 0
|
||||
@@ -105,9 +106,6 @@ export const CollectionArchiveByCollection: React.FC<Props> = (props) => {
|
||||
}
|
||||
: {}),
|
||||
},
|
||||
limit,
|
||||
page,
|
||||
depth: 1,
|
||||
},
|
||||
{ encode: false },
|
||||
)
|
||||
@@ -135,7 +133,7 @@ export const CollectionArchiveByCollection: React.FC<Props> = (props) => {
|
||||
}
|
||||
}
|
||||
|
||||
makeRequest()
|
||||
void makeRequest()
|
||||
|
||||
return () => {
|
||||
if (timer) clearTimeout(timer)
|
||||
@@ -144,17 +142,17 @@ export const CollectionArchiveByCollection: React.FC<Props> = (props) => {
|
||||
|
||||
return (
|
||||
<div className={[classes.collectionArchive, className].filter(Boolean).join(' ')}>
|
||||
<div ref={scrollRef} className={classes.scrollRef} />
|
||||
<div className={classes.scrollRef} ref={scrollRef} />
|
||||
{!isLoading && error && <Gutter>{error}</Gutter>}
|
||||
<Fragment>
|
||||
{showPageRange !== false && (
|
||||
<Gutter>
|
||||
<div className={classes.pageRange}>
|
||||
<PageRange
|
||||
totalDocs={results.totalDocs}
|
||||
currentPage={results.page}
|
||||
collection={relationTo}
|
||||
currentPage={results.page}
|
||||
limit={limit}
|
||||
totalDocs={results.totalDocs}
|
||||
/>
|
||||
</div>
|
||||
</Gutter>
|
||||
@@ -167,8 +165,8 @@ export const CollectionArchiveByCollection: React.FC<Props> = (props) => {
|
||||
}
|
||||
|
||||
return (
|
||||
<div key={index} className={classes.column}>
|
||||
<Card relationTo="posts" doc={result} showCategories />
|
||||
<div className={classes.column} key={index}>
|
||||
<Card doc={result} relationTo="posts" showCategories />
|
||||
</div>
|
||||
)
|
||||
})}
|
||||
@@ -176,9 +174,9 @@ export const CollectionArchiveByCollection: React.FC<Props> = (props) => {
|
||||
{results.totalPages > 1 && (
|
||||
<Pagination
|
||||
className={classes.pagination}
|
||||
onClick={setPage}
|
||||
page={results.page}
|
||||
totalPages={results.totalPages}
|
||||
onClick={setPage}
|
||||
/>
|
||||
)}
|
||||
</Gutter>
|
||||
@@ -2,10 +2,10 @@
|
||||
|
||||
import React, { Fragment } from 'react'
|
||||
|
||||
import type { ArchiveBlockProps } from '../../../_blocks/ArchiveBlock/types'
|
||||
import { Card } from '../../Card'
|
||||
import { Gutter } from '../../Gutter'
|
||||
import type { ArchiveBlockProps } from '../../../_blocks/ArchiveBlock/types.js'
|
||||
|
||||
import { Card } from '../../Card/index.js'
|
||||
import { Gutter } from '../../Gutter/index.js'
|
||||
import classes from './index.module.scss'
|
||||
|
||||
export type Props = {
|
||||
@@ -29,8 +29,8 @@ export const CollectionArchiveBySelection: React.FC<Props> = (props) => {
|
||||
}
|
||||
|
||||
return (
|
||||
<div key={index} className={classes.column}>
|
||||
<Card relationTo="posts" doc={result} showCategories />
|
||||
<div className={classes.column} key={index}>
|
||||
<Card doc={result} relationTo="posts" showCategories />
|
||||
</div>
|
||||
)
|
||||
})}
|
||||
@@ -1,8 +1,9 @@
|
||||
import React from 'react'
|
||||
|
||||
import type { ArchiveBlockProps } from '../../_blocks/ArchiveBlock/types'
|
||||
import { CollectionArchiveBySelection } from './PopulateBySelection'
|
||||
import { CollectionArchiveByCollection } from './PopulateByCollection'
|
||||
import type { ArchiveBlockProps } from '../../_blocks/ArchiveBlock/types.js'
|
||||
|
||||
import { CollectionArchiveByCollection } from './PopulateByCollection/index.js'
|
||||
import { CollectionArchiveBySelection } from './PopulateBySelection/index.js'
|
||||
|
||||
export type Props = Omit<ArchiveBlockProps, 'blockType'> & {
|
||||
className?: string
|
||||
@@ -13,7 +14,7 @@ export const CollectionArchive: React.FC<Props> = (props) => {
|
||||
const { className, populateBy, selectedDocs } = props
|
||||
|
||||
if (populateBy === 'selection') {
|
||||
return <CollectionArchiveBySelection selectedDocs={selectedDocs} className={className} />
|
||||
return <CollectionArchiveBySelection className={className} selectedDocs={selectedDocs} />
|
||||
}
|
||||
|
||||
if (populateBy === 'collection') {
|
||||
@@ -1,12 +1,13 @@
|
||||
import LinkWithDefault from 'next/link.js'
|
||||
import React from 'react'
|
||||
import Link from 'next/link'
|
||||
|
||||
import { fetchFooter } from '../../_api/fetchFooter'
|
||||
import { Gutter } from '../Gutter'
|
||||
import { CMSLink } from '../Link'
|
||||
|
||||
import { fetchFooter } from '../../_api/fetchFooter.js'
|
||||
import { Gutter } from '../Gutter/index.js'
|
||||
import { CMSLink } from '../Link/index.js'
|
||||
import classes from './index.module.scss'
|
||||
|
||||
const Link = (LinkWithDefault.default || LinkWithDefault) as typeof LinkWithDefault.default
|
||||
|
||||
export async function Footer() {
|
||||
const footer = await fetchFooter()
|
||||
|
||||
@@ -18,8 +19,8 @@ export async function Footer() {
|
||||
<Link href="/">
|
||||
<picture>
|
||||
<img
|
||||
className={classes.logo}
|
||||
alt="Payload Logo"
|
||||
className={classes.logo}
|
||||
src="https://raw.githubusercontent.com/payloadcms/payload/main/packages/payload/src/admin/assets/images/payload-logo-light.svg"
|
||||
/>
|
||||
</picture>
|
||||
@@ -1,21 +1,22 @@
|
||||
import React, { forwardRef, Ref } from 'react'
|
||||
import type { Ref } from 'react'
|
||||
|
||||
import React, { forwardRef } from 'react'
|
||||
|
||||
import classes from './index.module.scss'
|
||||
|
||||
type Props = {
|
||||
left?: boolean
|
||||
right?: boolean
|
||||
className?: string
|
||||
children: React.ReactNode
|
||||
className?: string
|
||||
left?: boolean
|
||||
ref?: Ref<HTMLDivElement>
|
||||
right?: boolean
|
||||
}
|
||||
|
||||
export const Gutter: React.FC<Props> = forwardRef<HTMLDivElement, Props>((props, ref) => {
|
||||
const { left = true, right = true, className, children } = props
|
||||
const { children, className, left = true, right = true } = props
|
||||
|
||||
return (
|
||||
<div
|
||||
ref={ref}
|
||||
className={[
|
||||
classes.gutter,
|
||||
left && classes.gutterLeft,
|
||||
@@ -24,6 +25,7 @@ export const Gutter: React.FC<Props> = forwardRef<HTMLDivElement, Props>((props,
|
||||
]
|
||||
.filter(Boolean)
|
||||
.join(' ')}
|
||||
ref={ref}
|
||||
>
|
||||
{children}
|
||||
</div>
|
||||
@@ -2,9 +2,9 @@
|
||||
|
||||
import React from 'react'
|
||||
|
||||
import { Header as HeaderType } from '../../../../payload-types'
|
||||
import { CMSLink } from '../../Link'
|
||||
import type { Header as HeaderType } from '../../../../../test/live-preview/payload-types.js'
|
||||
|
||||
import { CMSLink } from '../../Link/index.js'
|
||||
import classes from './index.module.scss'
|
||||
|
||||
export const HeaderNav: React.FC<{ header: HeaderType }> = ({ header }) => {
|
||||
@@ -1,15 +1,12 @@
|
||||
{
|
||||
/* eslint-disable @next/next/no-img-element */
|
||||
}
|
||||
|
||||
import LinkWithDefault from 'next/link.js'
|
||||
import React from 'react'
|
||||
import Link from 'next/link'
|
||||
|
||||
import { Gutter } from '../Gutter'
|
||||
import { HeaderNav } from './Nav'
|
||||
|
||||
import { fetchHeader } from '../../_api/fetchHeader.js'
|
||||
import { Gutter } from '../Gutter/index.js'
|
||||
import { HeaderNav } from './Nav/index.js'
|
||||
import classes from './index.module.scss'
|
||||
import { fetchHeader } from '@/app/_api/fetchHeader'
|
||||
|
||||
const Link = (LinkWithDefault.default || LinkWithDefault) as typeof LinkWithDefault.default
|
||||
|
||||
export async function Header() {
|
||||
const header = await fetchHeader()
|
||||
@@ -17,10 +14,10 @@ export async function Header() {
|
||||
return (
|
||||
<header className={classes.header}>
|
||||
<Gutter className={classes.wrap}>
|
||||
<Link href="/">
|
||||
<Link href="/live-preview">
|
||||
<img
|
||||
className={classes.logo}
|
||||
alt="Payload Logo"
|
||||
className={classes.logo}
|
||||
src="https://raw.githubusercontent.com/payloadcms/payload/main/packages/payload/src/admin/assets/images/payload-logo-dark.svg"
|
||||
/>
|
||||
</Link>
|
||||
@@ -1,8 +1,9 @@
|
||||
import React from 'react'
|
||||
|
||||
import { Page } from '../../../payload-types'
|
||||
import { HighImpactHero } from '../../_heros/HighImpact'
|
||||
import { LowImpactHero } from '../../_heros/LowImpact'
|
||||
import type { Page } from '../../../../test/live-preview/payload-types.js'
|
||||
|
||||
import { HighImpactHero } from '../../_heros/HighImpact/index.js'
|
||||
import { LowImpactHero } from '../../_heros/LowImpact/index.js'
|
||||
|
||||
const heroes = {
|
||||
highImpact: HighImpactHero,
|
||||
@@ -1,34 +1,38 @@
|
||||
import LinkWithDefault from 'next/link.js'
|
||||
import React from 'react'
|
||||
import Link from 'next/link'
|
||||
|
||||
import { Page } from '../../../payload-types'
|
||||
import { Button, Props as ButtonProps } from '../Button'
|
||||
import type { Page, Post } from '../../../../test/live-preview/payload-types.js'
|
||||
import type { Props as ButtonProps } from '../Button/index.js'
|
||||
|
||||
import { Button } from '../Button/index.js'
|
||||
|
||||
const Link = (LinkWithDefault.default || LinkWithDefault) as typeof LinkWithDefault.default
|
||||
|
||||
type CMSLinkType = {
|
||||
type?: 'custom' | 'reference'
|
||||
url?: string
|
||||
newTab?: boolean
|
||||
reference?: {
|
||||
value: string | Page
|
||||
relationTo: 'pages' | 'posts'
|
||||
}
|
||||
label?: string
|
||||
appearance?: ButtonProps['appearance']
|
||||
children?: React.ReactNode
|
||||
className?: string
|
||||
invert?: ButtonProps['invert']
|
||||
label?: string
|
||||
newTab?: boolean
|
||||
reference?: {
|
||||
relationTo: 'pages' | 'posts'
|
||||
value: Page | Post | string
|
||||
}
|
||||
type?: 'custom' | 'reference'
|
||||
url?: string
|
||||
}
|
||||
|
||||
export const CMSLink: React.FC<CMSLinkType> = ({
|
||||
type,
|
||||
url,
|
||||
newTab,
|
||||
reference,
|
||||
label,
|
||||
appearance,
|
||||
children,
|
||||
className,
|
||||
invert,
|
||||
label,
|
||||
newTab,
|
||||
reference,
|
||||
url,
|
||||
}) => {
|
||||
const href =
|
||||
type === 'reference' && typeof reference?.value === 'object' && reference.value.slug
|
||||
@@ -38,11 +42,11 @@ export const CMSLink: React.FC<CMSLinkType> = ({
|
||||
if (!href) return null
|
||||
|
||||
if (!appearance) {
|
||||
const newTabProps = newTab ? { target: '_blank', rel: 'noopener noreferrer' } : {}
|
||||
const newTabProps = newTab ? { rel: 'noopener noreferrer', target: '_blank' } : {}
|
||||
|
||||
if (href || url) {
|
||||
return (
|
||||
<Link {...newTabProps} href={href || url || ''} className={className}>
|
||||
<Link {...newTabProps} className={className} href={href || url || ''}>
|
||||
{label && label}
|
||||
{children && children}
|
||||
</Link>
|
||||
@@ -52,12 +56,12 @@ export const CMSLink: React.FC<CMSLinkType> = ({
|
||||
|
||||
return (
|
||||
<Button
|
||||
className={className}
|
||||
newTab={newTab}
|
||||
href={href}
|
||||
appearance={appearance}
|
||||
label={label}
|
||||
className={className}
|
||||
href={href}
|
||||
invert={invert}
|
||||
label={label}
|
||||
newTab={newTab}
|
||||
/>
|
||||
)
|
||||
}
|
||||
@@ -1,26 +1,31 @@
|
||||
'use client'
|
||||
|
||||
import type { StaticImageData } from 'next/image.js'
|
||||
|
||||
import NextImageWithDefault from 'next/image.js'
|
||||
import React from 'react'
|
||||
import NextImage, { StaticImageData } from 'next/image'
|
||||
|
||||
import cssVariables from '../../../cssVariables'
|
||||
import { Props as MediaProps } from '../types'
|
||||
import type { Props as MediaProps } from '../types.js'
|
||||
|
||||
import { PAYLOAD_SERVER_URL } from '../../../_api/serverURL.js'
|
||||
import cssVariables from '../../../cssVariables.js'
|
||||
import classes from './index.module.scss'
|
||||
import { PAYLOAD_SERVER_URL } from '@/app/_api/serverURL'
|
||||
|
||||
const { breakpoints } = cssVariables
|
||||
|
||||
const NextImage = (NextImageWithDefault.default ||
|
||||
NextImageWithDefault) as typeof NextImageWithDefault.default
|
||||
|
||||
export const Image: React.FC<MediaProps> = (props) => {
|
||||
const {
|
||||
alt: altFromProps,
|
||||
fill,
|
||||
imgClassName,
|
||||
onClick,
|
||||
onLoad: onLoadFromProps,
|
||||
resource,
|
||||
priority,
|
||||
fill,
|
||||
resource,
|
||||
src: srcFromProps,
|
||||
alt: altFromProps,
|
||||
} = props
|
||||
|
||||
const [isLoading, setIsLoading] = React.useState(true)
|
||||
@@ -32,10 +37,10 @@ export const Image: React.FC<MediaProps> = (props) => {
|
||||
|
||||
if (!src && resource && typeof resource !== 'string') {
|
||||
const {
|
||||
width: fullWidth,
|
||||
height: fullHeight,
|
||||
filename: fullFilename,
|
||||
alt: altFromResource,
|
||||
filename: fullFilename,
|
||||
height: fullHeight,
|
||||
width: fullWidth,
|
||||
} = resource
|
||||
|
||||
width = fullWidth || undefined
|
||||
@@ -44,7 +49,7 @@ export const Image: React.FC<MediaProps> = (props) => {
|
||||
|
||||
const filename = fullFilename
|
||||
|
||||
src = `${PAYLOAD_SERVER_URL}/media/${filename}`
|
||||
src = `${PAYLOAD_SERVER_URL}/api/media/file/${filename}`
|
||||
}
|
||||
|
||||
// NOTE: this is used by the browser to determine which image to download at different screen sizes
|
||||
@@ -54,11 +59,12 @@ export const Image: React.FC<MediaProps> = (props) => {
|
||||
|
||||
return (
|
||||
<NextImage
|
||||
alt={alt || ''}
|
||||
className={[isLoading && classes.placeholder, classes.image, imgClassName]
|
||||
.filter(Boolean)
|
||||
.join(' ')}
|
||||
src={src}
|
||||
alt={alt || ''}
|
||||
fill={fill}
|
||||
height={!fill ? height : undefined}
|
||||
onClick={onClick}
|
||||
onLoad={() => {
|
||||
setIsLoading(false)
|
||||
@@ -66,11 +72,10 @@ export const Image: React.FC<MediaProps> = (props) => {
|
||||
onLoadFromProps()
|
||||
}
|
||||
}}
|
||||
fill={fill}
|
||||
width={!fill ? width : undefined}
|
||||
height={!fill ? height : undefined}
|
||||
sizes={sizes}
|
||||
priority={priority}
|
||||
sizes={sizes}
|
||||
src={src}
|
||||
width={!fill ? width : undefined}
|
||||
/>
|
||||
)
|
||||
}
|
||||
@@ -2,13 +2,13 @@
|
||||
|
||||
import React, { useEffect, useRef } from 'react'
|
||||
|
||||
import { Props as MediaProps } from '../types'
|
||||
import type { Props as MediaProps } from '../types.js'
|
||||
|
||||
import { PAYLOAD_SERVER_URL } from '../../../_api/serverURL.js'
|
||||
import classes from './index.module.scss'
|
||||
import { PAYLOAD_SERVER_URL } from '@/app/_api/serverURL'
|
||||
|
||||
export const Video: React.FC<MediaProps> = (props) => {
|
||||
const { videoClassName, resource, onClick } = props
|
||||
const { onClick, resource, videoClassName } = props
|
||||
|
||||
const videoRef = useRef<HTMLVideoElement>(null)
|
||||
// const [showFallback] = useState<boolean>()
|
||||
@@ -28,13 +28,13 @@ export const Video: React.FC<MediaProps> = (props) => {
|
||||
|
||||
return (
|
||||
<video
|
||||
playsInline
|
||||
autoPlay
|
||||
muted
|
||||
loop
|
||||
controls={false}
|
||||
className={[classes.video, videoClassName].filter(Boolean).join(' ')}
|
||||
controls={false}
|
||||
loop
|
||||
muted
|
||||
onClick={onClick}
|
||||
playsInline
|
||||
ref={videoRef}
|
||||
>
|
||||
<source src={`${PAYLOAD_SERVER_URL}/media/${filename}`} />
|
||||
@@ -1,11 +1,14 @@
|
||||
import React, { ElementType, Fragment } from 'react'
|
||||
import type { ElementType } from 'react'
|
||||
|
||||
import { Image } from './Image'
|
||||
import { Props } from './types'
|
||||
import { Video } from './Video'
|
||||
import React, { Fragment } from 'react'
|
||||
|
||||
import type { Props } from './types.js'
|
||||
|
||||
import { Image } from './Image/index.js'
|
||||
import { Video } from './Video/index.js'
|
||||
|
||||
export const Media: React.FC<Props> = (props) => {
|
||||
const { className, resource, htmlElement = 'div' } = props
|
||||
const { className, htmlElement = 'div', resource } = props
|
||||
|
||||
const isVideo = typeof resource !== 'string' && resource?.mimeType?.includes('video')
|
||||
const Tag = (htmlElement as ElementType) || Fragment
|
||||
@@ -1,20 +1,20 @@
|
||||
import type { ElementType, Ref } from 'react'
|
||||
import type { StaticImageData } from 'next/image'
|
||||
import type { ElementType, Ref } from 'react'
|
||||
|
||||
import type { Media as MediaType } from '../../../payload-types'
|
||||
|
||||
export interface Props {
|
||||
src?: StaticImageData // for static media
|
||||
alt?: string
|
||||
resource?: string | MediaType // for Payload media
|
||||
size?: string // for NextImage only
|
||||
priority?: boolean // for NextImage only
|
||||
fill?: boolean // for NextImage only
|
||||
className?: string
|
||||
imgClassName?: string
|
||||
videoClassName?: string
|
||||
fill?: boolean // for NextImage only
|
||||
htmlElement?: ElementType | null
|
||||
imgClassName?: string
|
||||
onClick?: () => void
|
||||
onLoad?: () => void
|
||||
ref?: Ref<null | HTMLImageElement | HTMLVideoElement>
|
||||
priority?: boolean // for NextImage only
|
||||
ref?: Ref<HTMLImageElement | HTMLVideoElement | null>
|
||||
resource?: MediaType | string // for Payload media
|
||||
size?: string // for NextImage only
|
||||
src?: StaticImageData // for static media
|
||||
videoClassName?: string
|
||||
}
|
||||
@@ -3,42 +3,42 @@ import React from 'react'
|
||||
import classes from './index.module.scss'
|
||||
|
||||
const defaultLabels = {
|
||||
singular: 'Doc',
|
||||
plural: 'Docs',
|
||||
singular: 'Doc',
|
||||
}
|
||||
|
||||
const defaultCollectionLabels = {
|
||||
products: {
|
||||
singular: 'Product',
|
||||
plural: 'Products',
|
||||
singular: 'Product',
|
||||
},
|
||||
}
|
||||
|
||||
export const PageRange: React.FC<{
|
||||
className?: string
|
||||
totalDocs?: number
|
||||
currentPage?: number
|
||||
collection?: string
|
||||
limit?: number
|
||||
collectionLabels?: {
|
||||
singular?: string
|
||||
plural?: string
|
||||
singular?: string
|
||||
}
|
||||
currentPage?: number
|
||||
limit?: number
|
||||
totalDocs?: number
|
||||
}> = (props) => {
|
||||
const {
|
||||
className,
|
||||
totalDocs,
|
||||
currentPage,
|
||||
collection,
|
||||
limit,
|
||||
collectionLabels: collectionLabelsFromProps,
|
||||
currentPage,
|
||||
limit,
|
||||
totalDocs,
|
||||
} = props
|
||||
|
||||
const indexStart = (currentPage ? currentPage - 1 : 1) * (limit || 1) + 1
|
||||
let indexEnd = (currentPage || 1) * (limit || 1)
|
||||
if (totalDocs && indexEnd > totalDocs) indexEnd = totalDocs
|
||||
|
||||
const { singular, plural } =
|
||||
const { plural, singular } =
|
||||
collectionLabelsFromProps || defaultCollectionLabels[collection || ''] || defaultLabels || {}
|
||||
|
||||
return (
|
||||
@@ -1,30 +1,29 @@
|
||||
import React from 'react'
|
||||
|
||||
import { Chevron } from '../Chevron'
|
||||
|
||||
import { Chevron } from '../Chevron/index.js'
|
||||
import classes from './index.module.scss'
|
||||
|
||||
export const Pagination: React.FC<{
|
||||
className?: string
|
||||
onClick: (page: number) => void
|
||||
page: number
|
||||
totalPages: number
|
||||
onClick: (page: number) => void
|
||||
className?: string
|
||||
}> = (props) => {
|
||||
const { page, totalPages, onClick, className } = props
|
||||
const { className, onClick, page, totalPages } = props
|
||||
const hasNextPage = page < totalPages
|
||||
const hasPrevPage = page > 1
|
||||
|
||||
return (
|
||||
<div className={[classes.pagination, className].filter(Boolean).join(' ')}>
|
||||
<button
|
||||
type="button"
|
||||
className={classes.button}
|
||||
disabled={!hasPrevPage}
|
||||
onClick={() => {
|
||||
onClick(page - 1)
|
||||
}}
|
||||
type="button"
|
||||
>
|
||||
<Chevron rotate={90} className={classes.icon} />
|
||||
<Chevron className={classes.icon} rotate={90} />
|
||||
</button>
|
||||
<div className={classes.pageRange}>
|
||||
<span className={classes.pageRangeLabel}>
|
||||
@@ -32,14 +31,14 @@ export const Pagination: React.FC<{
|
||||
</span>
|
||||
</div>
|
||||
<button
|
||||
type="button"
|
||||
className={classes.button}
|
||||
disabled={!hasNextPage}
|
||||
onClick={() => {
|
||||
onClick(page + 1)
|
||||
}}
|
||||
type="button"
|
||||
>
|
||||
<Chevron rotate={-90} className={classes.icon} />
|
||||
<Chevron className={classes.icon} rotate={-90} />
|
||||
</button>
|
||||
</div>
|
||||
)
|
||||
@@ -1,9 +1,8 @@
|
||||
import React from 'react'
|
||||
|
||||
import serializeSlate from './serializeSlate'
|
||||
import serializeLexical from './serializeLexical'
|
||||
|
||||
import classes from './index.module.scss'
|
||||
import serializeLexical from './serializeLexical.js'
|
||||
import serializeSlate from './serializeSlate.js'
|
||||
|
||||
const RichText: React.FC<{
|
||||
className?: string
|
||||
@@ -1,6 +1,9 @@
|
||||
import type { SerializedEditorState } from 'lexical'
|
||||
import { CMSLink } from '../Link'
|
||||
import { Media } from '../Media'
|
||||
|
||||
import React from 'react'
|
||||
|
||||
import { CMSLink } from '../Link/index.js'
|
||||
import { Media } from '../Media/index.js'
|
||||
|
||||
const serializer = (
|
||||
content?: SerializedEditorState['root']['children'],
|
||||
@@ -55,10 +58,10 @@ const serializer = (
|
||||
return (
|
||||
<CMSLink
|
||||
key={i}
|
||||
newTab={Boolean(node?.newTab)}
|
||||
reference={node.doc as any}
|
||||
type={node.linkType === 'internal' ? 'reference' : 'custom'}
|
||||
url={node.url}
|
||||
reference={node.doc as any}
|
||||
newTab={Boolean(node?.newTab)}
|
||||
>
|
||||
{serializer(node?.children, renderUploadFilenameOnly)}
|
||||
</CMSLink>
|
||||
@@ -1,18 +1,19 @@
|
||||
import React, { Fragment } from 'react'
|
||||
import escapeHTML from 'escape-html'
|
||||
import React, { Fragment } from 'react'
|
||||
import { Text } from 'slate'
|
||||
import { CMSLink } from '../Link'
|
||||
import { Media } from '../Media'
|
||||
|
||||
import { CMSLink } from '../Link/index.js'
|
||||
import { Media } from '../Media/index.js'
|
||||
|
||||
// eslint-disable-next-line no-use-before-define
|
||||
type Children = Leaf[]
|
||||
|
||||
type Leaf = {
|
||||
type: string
|
||||
value?: any
|
||||
children?: Children
|
||||
url?: string
|
||||
[key: string]: unknown
|
||||
children?: Children
|
||||
type: string
|
||||
url?: string
|
||||
value?: any
|
||||
}
|
||||
|
||||
const serializeSlate = (
|
||||
@@ -37,7 +38,7 @@ const serializeSlate = (
|
||||
|
||||
if (node.underline) {
|
||||
text = (
|
||||
<span style={{ textDecoration: 'underline' }} key={i}>
|
||||
<span key={i} style={{ textDecoration: 'underline' }}>
|
||||
{text}
|
||||
</span>
|
||||
)
|
||||
@@ -45,7 +46,7 @@ const serializeSlate = (
|
||||
|
||||
if (node.strikethrough) {
|
||||
text = (
|
||||
<span style={{ textDecoration: 'line-through' }} key={i}>
|
||||
<span key={i} style={{ textDecoration: 'line-through' }}>
|
||||
{text}
|
||||
</span>
|
||||
)
|
||||
@@ -106,10 +107,10 @@ const serializeSlate = (
|
||||
return (
|
||||
<CMSLink
|
||||
key={i}
|
||||
newTab={Boolean(node?.newTab)}
|
||||
reference={node.doc as any}
|
||||
type={node.linkType === 'internal' ? 'reference' : 'custom'}
|
||||
url={node.url}
|
||||
reference={node.doc as any}
|
||||
newTab={Boolean(node?.newTab)}
|
||||
>
|
||||
{serializeSlate(node?.children, renderUploadFilenameOnly)}
|
||||
</CMSLink>
|
||||
@@ -5,17 +5,17 @@ import classes from './index.module.scss'
|
||||
export type VerticalPaddingOptions = 'large' | 'medium' | 'none'
|
||||
|
||||
type Props = {
|
||||
top?: VerticalPaddingOptions
|
||||
bottom?: VerticalPaddingOptions
|
||||
children: React.ReactNode
|
||||
className?: string
|
||||
top?: VerticalPaddingOptions
|
||||
}
|
||||
|
||||
export const VerticalPadding: React.FC<Props> = ({
|
||||
top = 'medium',
|
||||
bottom = 'medium',
|
||||
className,
|
||||
children,
|
||||
className,
|
||||
top = 'medium',
|
||||
}) => {
|
||||
return (
|
||||
<div
|
||||
@@ -92,6 +92,10 @@ p {
|
||||
}
|
||||
}
|
||||
|
||||
#page-title {
|
||||
@extend %h6;
|
||||
}
|
||||
|
||||
ul,
|
||||
ol {
|
||||
padding-left: var(--base);
|
||||
@@ -1,13 +1,13 @@
|
||||
import React, { Fragment } from 'react'
|
||||
|
||||
import { Page } from '../../../payload-types'
|
||||
import { Gutter } from '../../_components/Gutter'
|
||||
import { Media } from '../../_components/Media'
|
||||
import RichText from '../../_components/RichText'
|
||||
import type { Page } from '../../../../test/live-preview/payload-types.js'
|
||||
|
||||
import { Gutter } from '../../_components/Gutter/index.js'
|
||||
import { Media } from '../../_components/Media/index.js'
|
||||
import RichText from '../../_components/RichText/index.js'
|
||||
import classes from './index.module.scss'
|
||||
|
||||
export const HighImpactHero: React.FC<Page['hero']> = ({ richText, media }) => {
|
||||
export const HighImpactHero: React.FC<Page['hero']> = ({ media, richText }) => {
|
||||
return (
|
||||
<Gutter className={classes.hero}>
|
||||
<div className={classes.content}>
|
||||
@@ -17,12 +17,12 @@ export const HighImpactHero: React.FC<Page['hero']> = ({ richText, media }) => {
|
||||
{typeof media === 'object' && media !== null && (
|
||||
<Fragment>
|
||||
<Media
|
||||
resource={media}
|
||||
// fill
|
||||
imgClassName={classes.image}
|
||||
priority
|
||||
resource={media}
|
||||
/>
|
||||
{media?.caption && <RichText content={media.caption} className={classes.caption} />}
|
||||
{media?.caption && <RichText className={classes.caption} content={media.caption} />}
|
||||
</Fragment>
|
||||
)}
|
||||
</div>
|
||||
@@ -1,10 +1,10 @@
|
||||
import React from 'react'
|
||||
|
||||
import { Page } from '../../../payload-types'
|
||||
import { Gutter } from '../../_components/Gutter'
|
||||
import RichText from '../../_components/RichText'
|
||||
import { VerticalPadding } from '../../_components/VerticalPadding'
|
||||
import type { Page } from '../../../../test/live-preview/payload-types.js'
|
||||
|
||||
import { Gutter } from '../../_components/Gutter/index.js'
|
||||
import RichText from '../../_components/RichText/index.js'
|
||||
import { VerticalPadding } from '../../_components/VerticalPadding/index.js'
|
||||
import classes from './index.module.scss'
|
||||
|
||||
export const LowImpactHero: React.FC<Page['hero']> = ({ richText }) => {
|
||||
@@ -1,25 +1,27 @@
|
||||
import LinkWithDefault from 'next/link.js'
|
||||
import React, { Fragment } from 'react'
|
||||
import Link from 'next/link'
|
||||
|
||||
import { Post } from '../../../payload-types'
|
||||
import { Gutter } from '../../_components/Gutter'
|
||||
import { Media } from '../../_components/Media'
|
||||
import RichText from '../../_components/RichText'
|
||||
import { formatDateTime } from '../../_utilities/formatDateTime'
|
||||
import type { Post } from '../../../../test/live-preview/payload-types.js'
|
||||
|
||||
import { PAYLOAD_SERVER_URL } from '../../_api/serverURL.js'
|
||||
import { Gutter } from '../../_components/Gutter/index.js'
|
||||
import { Media } from '../../_components/Media/index.js'
|
||||
import RichText from '../../_components/RichText/index.js'
|
||||
import { formatDateTime } from '../../_utilities/formatDateTime.js'
|
||||
import classes from './index.module.scss'
|
||||
import { PAYLOAD_SERVER_URL } from '@/app/_api/serverURL'
|
||||
|
||||
const Link = (LinkWithDefault.default || LinkWithDefault) as typeof LinkWithDefault.default
|
||||
|
||||
export const PostHero: React.FC<{
|
||||
post: Post
|
||||
}> = ({ post }) => {
|
||||
const { id, meta: { image: metaImage, description } = {}, createdAt } = post
|
||||
const { id, createdAt, meta: { description, image: metaImage } = {} } = post
|
||||
|
||||
return (
|
||||
<Fragment>
|
||||
<Gutter className={classes.postHero}>
|
||||
<div className={classes.content}>
|
||||
<RichText content={post?.hero?.richText} className={classes.richText} />
|
||||
<RichText className={classes.richText} content={post?.hero?.richText} />
|
||||
<p className={classes.meta}>
|
||||
{createdAt && (
|
||||
<Fragment>
|
||||
@@ -34,7 +36,7 @@ export const PostHero: React.FC<{
|
||||
<Link href={`${PAYLOAD_SERVER_URL}/admin/collections/posts/${id}`}>
|
||||
navigate to the admin dashboard
|
||||
</Link>
|
||||
{'.'}
|
||||
.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
@@ -42,11 +44,11 @@ export const PostHero: React.FC<{
|
||||
<div className={classes.mediaWrapper}>
|
||||
{!metaImage && <div className={classes.placeholder}>No image</div>}
|
||||
{metaImage && typeof metaImage !== 'string' && (
|
||||
<Media imgClassName={classes.image} resource={metaImage} fill />
|
||||
<Media fill imgClassName={classes.image} resource={metaImage} />
|
||||
)}
|
||||
</div>
|
||||
{metaImage && typeof metaImage !== 'string' && metaImage?.caption && (
|
||||
<RichText content={metaImage.caption} className={classes.caption} />
|
||||
<RichText className={classes.caption} content={metaImage.caption} />
|
||||
)}
|
||||
</div>
|
||||
</Gutter>
|
||||
@@ -1,6 +1,5 @@
|
||||
// Keep these in sync with the CSS variables in the `_css` directory
|
||||
|
||||
module.exports = {
|
||||
export default {
|
||||
breakpoints: {
|
||||
s: 768,
|
||||
m: 1024,
|
||||
@@ -1,11 +1,14 @@
|
||||
import { Footer } from './_components/Footer'
|
||||
import { Header } from './_components/Header'
|
||||
import './_css/app.scss'
|
||||
import type { Metadata } from 'next'
|
||||
|
||||
import React from 'react'
|
||||
|
||||
import { Footer } from './_components/Footer/index.js'
|
||||
import { Header } from './_components/Header/index.js'
|
||||
import './_css/app.scss'
|
||||
|
||||
export const metadata: Metadata = {
|
||||
title: 'Payload Live Preview',
|
||||
description: 'Payload Live Preview',
|
||||
title: 'Payload Live Preview',
|
||||
}
|
||||
|
||||
export default function RootLayout({ children }: { children: React.ReactNode }) {
|
||||
@@ -1,13 +1,14 @@
|
||||
'use client'
|
||||
|
||||
import React from 'react'
|
||||
import { Gutter } from './_components/Gutter'
|
||||
import { VerticalPadding } from './_components/VerticalPadding'
|
||||
|
||||
import { Gutter } from './_components/Gutter/index.js'
|
||||
import { VerticalPadding } from './_components/VerticalPadding/index.js'
|
||||
|
||||
export default function NotFound() {
|
||||
return (
|
||||
<main>
|
||||
<VerticalPadding top="none" bottom="medium">
|
||||
<VerticalPadding bottom="medium" top="none">
|
||||
<Gutter>
|
||||
<h1>404</h1>
|
||||
<p>This page could not be found.</p>
|
||||
3
app/live-preview/page.tsx
Normal file
3
app/live-preview/page.tsx
Normal file
@@ -0,0 +1,3 @@
|
||||
import PageTemplate from './(pages)/[slug]/page.js'
|
||||
|
||||
export default PageTemplate
|
||||
@@ -33,7 +33,7 @@ import { webpackBundler } from '@payloadcms/bundler-webpack'
|
||||
export default buildConfig({
|
||||
// highlight-start
|
||||
admin: {
|
||||
bundler: webpackBundler() // or viteBundler()
|
||||
bundler: webpackBundler(), // or viteBundler()
|
||||
},
|
||||
// highlight-end
|
||||
})
|
||||
@@ -48,7 +48,7 @@ Since the bundled file is sent to the browser, it can't include any server-only
|
||||
<Banner type="warning">
|
||||
<strong>Using environment variables in the admin UI</strong>
|
||||
<br />
|
||||
Bundles should not contain sensitive information. By default, Payload
|
||||
excludes env variables from the bundle. If you need to use env variables in your payload config,
|
||||
you need to prefix them with `PAYLOAD_PUBLIC_` to make them available to the client-side code.
|
||||
Bundles should not contain sensitive information. By default, Payload excludes env variables from
|
||||
the bundle. If you need to use env variables in your payload config, you need to prefix them with
|
||||
`PAYLOAD_PUBLIC_` to make them available to the client-side code.
|
||||
</Banner>
|
||||
|
||||
@@ -13,29 +13,29 @@ To swap in your own React component, first, consult the list of available compon
|
||||
<Banner type="success">
|
||||
<strong>Tip:</strong>
|
||||
<br />
|
||||
Custom components will automatically be provided with all props that the default component normally
|
||||
accepts.
|
||||
Custom components will automatically be provided with all props that the default component
|
||||
normally accepts.
|
||||
</Banner>
|
||||
|
||||
### Base Component Overrides
|
||||
|
||||
You can override a set of admin panel-wide components by providing a component to your base Payload config's `admin.components` property. The following options are available:
|
||||
|
||||
| Path | Description |
|
||||
| --------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| **`Nav`** | Contains the sidebar / mobile menu in its entirety. |
|
||||
| **`BeforeNavLinks`** | Array of components to inject into the built-in Nav, _before_ the links themselves. |
|
||||
| **`AfterNavLinks`** | Array of components to inject into the built-in Nav, _after_ the links. |
|
||||
| **`BeforeDashboard`** | Array of components to inject into the built-in Dashboard, _before_ the default dashboard contents. |
|
||||
| **`AfterDashboard`** | Array of components to inject into the built-in Dashboard, _after_ the default dashboard contents. [Demo](https://github.com/payloadcms/payload/tree/main/test/admin/components/AfterDashboard/index.tsx) |
|
||||
| **`BeforeLogin`** | Array of components to inject into the built-in Login, _before_ the default login form. |
|
||||
| **`AfterLogin`** | Array of components to inject into the built-in Login, _after_ the default login form. |
|
||||
| **`logout.Button`** | A custom React component. |
|
||||
| **`graphics.Icon`** | Used as a graphic within the `Nav` component. Often represents a condensed version of a full logo. |
|
||||
| **`graphics.Logo`** | The full logo to be used in contexts like the `Login` view. |
|
||||
| **`providers`** | Define your own provider components that will wrap the Payload Admin UI. [More](#custom-providers) |
|
||||
| **`actions`** | Array of custom components to be rendered in the Payload Admin UI header, providing additional interactivity and functionality. |
|
||||
| **`views`** | Override or create new views within the Payload Admin UI. [More](#views) |
|
||||
| Path | Description |
|
||||
| --------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| **`Nav`** | Contains the sidebar / mobile menu in its entirety. |
|
||||
| **`BeforeNavLinks`** | Array of components to inject into the built-in Nav, _before_ the links themselves. |
|
||||
| **`AfterNavLinks`** | Array of components to inject into the built-in Nav, _after_ the links. |
|
||||
| **`BeforeDashboard`** | Array of components to inject into the built-in Dashboard, _before_ the default dashboard contents. |
|
||||
| **`AfterDashboard`** | Array of components to inject into the built-in Dashboard, _after_ the default dashboard contents. [Demo](https://github.com/payloadcms/payload/tree/main/test/admin/components/AfterDashboard/index.tsx) |
|
||||
| **`BeforeLogin`** | Array of components to inject into the built-in Login, _before_ the default login form. |
|
||||
| **`AfterLogin`** | Array of components to inject into the built-in Login, _after_ the default login form. |
|
||||
| **`logout.Button`** | A custom React component. |
|
||||
| **`graphics.Icon`** | Used as a graphic within the `Nav` component. Often represents a condensed version of a full logo. |
|
||||
| **`graphics.Logo`** | The full logo to be used in contexts like the `Login` view. |
|
||||
| **`providers`** | Define your own provider components that will wrap the Payload Admin UI. [More](#custom-providers) |
|
||||
| **`actions`** | Array of custom components to be rendered in the Payload Admin UI header, providing additional interactivity and functionality. |
|
||||
| **`views`** | Override or create new views within the Payload Admin UI. [More](#views) |
|
||||
|
||||
Here is a full example showing how to swap some of these components for your own.
|
||||
|
||||
@@ -77,10 +77,10 @@ export default buildConfig({
|
||||
|
||||
You can easily swap entire views with your own by using the `admin.components.views` property. At the root level, Payload renders the following views by default, all of which can be overridden:
|
||||
|
||||
| Property | Description |
|
||||
| ------------------ | ---------------------------------------------------------------------------------------------------------------------------- |
|
||||
| **`Account`** | The Account view is used to show the currently logged in user's Account page. |
|
||||
| **`Dashboard`** | The main landing page of the Admin panel. |
|
||||
| Property | Description |
|
||||
| --------------- | ----------------------------------------------------------------------------- |
|
||||
| **`Account`** | The Account view is used to show the currently logged in user's Account page. |
|
||||
| **`Dashboard`** | The main landing page of the Admin panel. |
|
||||
|
||||
To swap out any of these views, simply pass in your custom component to the `admin.components.views` property of your Payload config. For example:
|
||||
|
||||
@@ -135,7 +135,10 @@ To add a _new_ view to the Admin Panel, simply add another key to the `views` ob
|
||||
<Banner type="warning">
|
||||
<strong>Note:</strong>
|
||||
<br />
|
||||
Routes are cascading. This means that unless explicitly given the `exact` property, they will match on URLs that simply _start_ with the route's path. This is helpful when creating catch-all routes in your application. Alternatively, you could define your nested route _before_ your parent route.
|
||||
Routes are cascading. This means that unless explicitly given the `exact` property, they will
|
||||
match on URLs that simply _start_ with the route's path. This is helpful when creating catch-all
|
||||
routes in your application. Alternatively, you could define your nested route _before_ your parent
|
||||
route.
|
||||
</Banner>
|
||||
|
||||
_For more examples regarding how to customize components, look at the following [examples](https://github.com/payloadcms/payload/tree/main/test/admin/components)._
|
||||
@@ -214,7 +217,7 @@ export const MyCollection: SanitizedCollectionConfig = {
|
||||
PreviewButton: CustomPreviewButton,
|
||||
},
|
||||
},
|
||||
}
|
||||
},
|
||||
}
|
||||
```
|
||||
|
||||
@@ -222,10 +225,10 @@ export const MyCollection: SanitizedCollectionConfig = {
|
||||
|
||||
To swap out entire views on collections, you can use the `admin.components.views` property on the collection's config. Payload renders the following views by default, all of which can be overridden:
|
||||
|
||||
| Property | Description |
|
||||
| ------------------ | ---------------------------------------------------------------------------------------------------------------------------- |
|
||||
| **`Edit`** | The Edit view is used to edit a single document for a given collection. |
|
||||
| **`List`** | The List view is used to show a list of documents for a given collection. |
|
||||
| Property | Description |
|
||||
| ---------- | ------------------------------------------------------------------------- |
|
||||
| **`Edit`** | The Edit view is used to edit a single document for a given collection. |
|
||||
| **`List`** | The List view is used to show a list of documents for a given collection. |
|
||||
|
||||
To swap out any of these views, simply pass in your custom component to the `admin.components.views` property of your Payload config. This will replace the entire view, including the page breadcrumbs, title, tabs, etc, _as well as all nested routes_.
|
||||
|
||||
@@ -310,9 +313,9 @@ As with Collections, you can override components on a global-by-global basis via
|
||||
|
||||
To swap out views for globals, you can use the `admin.components.views` property on the global's config. Payload renders the following views by default, all of which can be overridden:
|
||||
|
||||
| Property | Description |
|
||||
| ------------------ | ---------------------------------------------------------------------------------------------------------------------------- |
|
||||
| **`Edit`** | The Edit view is used to edit a single document for a given Global. |
|
||||
| Property | Description |
|
||||
| ---------- | ------------------------------------------------------------------- |
|
||||
| **`Edit`** | The Edit view is used to edit a single document for a given Global. |
|
||||
|
||||
To swap out any of these views, simply pass in your custom component to the `admin.components.views` property of your Payload config. This will replace the entire view, including the page breadcrumbs, title, and tabs, _as well as all nested views_.
|
||||
|
||||
@@ -379,13 +382,13 @@ You can also add _new_ tabs to the `Edit` view by adding another key to the `com
|
||||
|
||||
You can easily swap individual collection or global edit views. To do this, pass an _object_ to the `admin.components.views.Edit` property of the config. Payload renders the following views by default, all of which can be overridden:
|
||||
|
||||
| Property | Description |
|
||||
| ------------------ | ---------------------------------------------------------------------------------------------------------------------------- |
|
||||
| **`Default`** | The Default view is the primary view in which your document is edited. |
|
||||
| **`Versions`** | The Versions view is used to view the version history of a single document. [More details](../versions) |
|
||||
| **`Version`** | The Version view is used to view a single version of a single document for a given collection. [More details](../versions). |
|
||||
| **`API`** | The API view is used to display the REST API JSON response for a given document. |
|
||||
| **`LivePreview`** | The LivePreview view is used to display the Live Preview interface. [More details](../live-preview) |
|
||||
| Property | Description |
|
||||
| ----------------- | --------------------------------------------------------------------------------------------------------------------------- |
|
||||
| **`Default`** | The Default view is the primary view in which your document is edited. |
|
||||
| **`Versions`** | The Versions view is used to view the version history of a single document. [More details](../versions) |
|
||||
| **`Version`** | The Version view is used to view a single version of a single document for a given collection. [More details](../versions). |
|
||||
| **`API`** | The API view is used to display the REST API JSON response for a given document. |
|
||||
| **`LivePreview`** | The LivePreview view is used to display the Live Preview interface. [More details](../live-preview) |
|
||||
|
||||
Here is an example:
|
||||
|
||||
@@ -396,7 +399,8 @@ export const MyCollection: SanitizedCollectionConfig = {
|
||||
admin: {
|
||||
components: {
|
||||
views: {
|
||||
Edit: { // You can also define `components.views.Edit` as a component, this will override _all_ nested views
|
||||
Edit: {
|
||||
// You can also define `components.views.Edit` as a component, this will override _all_ nested views
|
||||
Default: MyCustomDefaultTab,
|
||||
Versions: MyCustomVersionsTab,
|
||||
Version: MyCustomVersionTab,
|
||||
@@ -423,7 +427,7 @@ export const MyCollection: SanitizedCollectionConfig = {
|
||||
Component: MyCustomTab,
|
||||
path: '/my-custom-tab',
|
||||
// You an swap the entire tab component out for your own
|
||||
Tab: MyCustomTab
|
||||
Tab: MyCustomTab,
|
||||
},
|
||||
AnotherCustomView: {
|
||||
Component: AnotherCustomView,
|
||||
@@ -432,7 +436,7 @@ export const MyCollection: SanitizedCollectionConfig = {
|
||||
Tab: {
|
||||
label: 'Another Custom View',
|
||||
href: '/another-custom-view',
|
||||
}
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -539,7 +543,6 @@ const CustomTextField: React.FC<{ path: string }> = ({ path }) => {
|
||||
const { value, setValue } = useField<string>({ path })
|
||||
// highlight-end
|
||||
|
||||
|
||||
return <input onChange={(e) => setValue(e.target.value)} value={value} />
|
||||
}
|
||||
```
|
||||
@@ -553,11 +556,11 @@ const CustomTextField: React.FC<{ path: string }> = ({ path }) => {
|
||||
|
||||
These are the props that will be passed to your custom Label.
|
||||
|
||||
| Property | Description |
|
||||
| ---------------- | ---------------------------------------------------------------- |
|
||||
| **`htmlFor`** | Property used to set `for` attribute for label. |
|
||||
| **`label`** | Label value provided in field, it can be used with i18n. |
|
||||
| **`required`** | A boolean value that represents if the field is required or not. |
|
||||
| Property | Description |
|
||||
| -------------- | ---------------------------------------------------------------- |
|
||||
| **`htmlFor`** | Property used to set `for` attribute for label. |
|
||||
| **`label`** | Label value provided in field, it can be used with i18n. |
|
||||
| **`required`** | A boolean value that represents if the field is required or not. |
|
||||
|
||||
#### Example
|
||||
|
||||
@@ -579,10 +582,12 @@ const CustomLabel: React.FC<Props> = (props) => {
|
||||
const { i18n } = useTranslation()
|
||||
|
||||
if (label) {
|
||||
return (<span>
|
||||
{getTranslation(label, i18n)}
|
||||
{required && <span className="required">*</span>}
|
||||
</span>);
|
||||
return (
|
||||
<span>
|
||||
{getTranslation(label, i18n)}
|
||||
{required && <span className="required">*</span>}
|
||||
</span>
|
||||
)
|
||||
}
|
||||
|
||||
return null
|
||||
@@ -593,10 +598,10 @@ const CustomLabel: React.FC<Props> = (props) => {
|
||||
|
||||
These are the props that will be passed to your custom Error.
|
||||
|
||||
| Property | Description |
|
||||
| ---------------- | ------------------------------------------------------------- |
|
||||
| **`message`** | The error message. |
|
||||
| **`showError`** | A boolean value that represents if the error should be shown. |
|
||||
| Property | Description |
|
||||
| --------------- | ------------------------------------------------------------- |
|
||||
| **`message`** | The error message. |
|
||||
| **`showError`** | A boolean value that represents if the error should be shown. |
|
||||
|
||||
#### Example
|
||||
|
||||
@@ -612,8 +617,8 @@ const CustomError: React.FC<Props> = (props) => {
|
||||
const { message, showError } = props
|
||||
|
||||
if (showError) {
|
||||
return <p style={{color: 'red'}}>{message}</p>
|
||||
} else return null;
|
||||
return <p style={{ color: 'red' }}>{message}</p>
|
||||
} else return null
|
||||
}
|
||||
```
|
||||
|
||||
@@ -630,7 +635,15 @@ import { Field } from 'payload/types'
|
||||
import './style.scss'
|
||||
|
||||
const ClearButton: React.FC = () => {
|
||||
return <button onClick={() => {/* ... */}}>X</button>
|
||||
return (
|
||||
<button
|
||||
onClick={() => {
|
||||
/* ... */
|
||||
}}
|
||||
>
|
||||
X
|
||||
</button>
|
||||
)
|
||||
}
|
||||
|
||||
const titleField: Field = {
|
||||
@@ -638,12 +651,12 @@ const titleField: Field = {
|
||||
type: 'text',
|
||||
admin: {
|
||||
components: {
|
||||
afterInput: [ClearButton]
|
||||
}
|
||||
}
|
||||
afterInput: [ClearButton],
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
export default titleField;
|
||||
export default titleField
|
||||
```
|
||||
|
||||
## Custom providers
|
||||
|
||||
@@ -104,6 +104,7 @@ By default the browser bundle will now include all the code from that file and a
|
||||
To fix this, we need to alias the `createStripeSubscription` file to a different file that can safely be included in the browser bundle.
|
||||
|
||||
First, we will create a mock file to replace the server-only file when bundling:
|
||||
|
||||
```js
|
||||
// mocks/modules.js
|
||||
|
||||
@@ -131,7 +132,7 @@ import { Subscriptions } from './collections/Subscriptions'
|
||||
const mockModulePath = path.resolve(__dirname, 'mocks/emptyObject.js')
|
||||
const fullFilePath = path.resolve(
|
||||
__dirname,
|
||||
'collections/Subscriptions/hooks/createStripeSubscription'
|
||||
'collections/Subscriptions/hooks/createStripeSubscription',
|
||||
)
|
||||
|
||||
export default buildConfig({
|
||||
@@ -173,24 +174,23 @@ export default buildConfig({
|
||||
admin: {
|
||||
bundler: viteBundler(),
|
||||
vite: (incomingViteConfig) => {
|
||||
const existingAliases = incomingViteConfig?.resolve?.alias || {};
|
||||
let aliasArray: { find: string | RegExp; replacement: string; }[] = [];
|
||||
const existingAliases = incomingViteConfig?.resolve?.alias || {}
|
||||
let aliasArray: { find: string | RegExp; replacement: string }[] = []
|
||||
|
||||
// Pass the existing Vite aliases
|
||||
if (Array.isArray(existingAliases)) {
|
||||
aliasArray = existingAliases;
|
||||
aliasArray = existingAliases
|
||||
} else {
|
||||
aliasArray = Object.values(existingAliases);
|
||||
aliasArray = Object.values(existingAliases)
|
||||
}
|
||||
|
||||
|
||||
// highlight-start
|
||||
// Add your own aliases using the find and replacement keys
|
||||
// remember, vite aliases are exact-match only
|
||||
aliasArray.push({
|
||||
find: '../server-only-module',
|
||||
replacement: path.resolve(__dirname, './path/to/browser-safe-module.js')
|
||||
});
|
||||
replacement: path.resolve(__dirname, './path/to/browser-safe-module.js'),
|
||||
})
|
||||
// highlight-end
|
||||
|
||||
return {
|
||||
@@ -198,8 +198,8 @@ export default buildConfig({
|
||||
resolve: {
|
||||
...(incomingViteConfig?.resolve || {}),
|
||||
alias: aliasArray,
|
||||
}
|
||||
};
|
||||
},
|
||||
}
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
@@ -639,12 +639,12 @@ export const CustomArrayManager = () => {
|
||||
|
||||
The `useCollapsible` hook allows you to control parent collapsibles:
|
||||
|
||||
| Property | Description |
|
||||
|---------------------------|--------------------------------------------------------------------------------------------------------------------|
|
||||
| **`collapsed`** | State of the collapsible. `true` if open, `false` if collapsed |
|
||||
| **`isVisible`** | If nested, determine if the nearest collapsible is visible. `true` if no parent is closed, `false` otherwise |
|
||||
| **`toggle`** | Toggles the state of the nearest collapsible |
|
||||
| **`withinCollapsible`** | Determine when you are within another collaspible | |
|
||||
| Property | Description |
|
||||
| ----------------------- | ------------------------------------------------------------------------------------------------------------ | --- |
|
||||
| **`collapsed`** | State of the collapsible. `true` if open, `false` if collapsed |
|
||||
| **`isVisible`** | If nested, determine if the nearest collapsible is visible. `true` if no parent is closed, `false` otherwise |
|
||||
| **`toggle`** | Toggles the state of the nearest collapsible |
|
||||
| **`withinCollapsible`** | Determine when you are within another collaspible | |
|
||||
|
||||
**Example:**
|
||||
|
||||
@@ -671,7 +671,7 @@ const CustomComponent: React.FC = () => {
|
||||
The `useDocumentInfo` hook provides lots of information about the document currently being edited, including the following:
|
||||
|
||||
| Property | Description |
|
||||
|---------------------------|--------------------------------------------------------------------------------------------------------------------|
|
||||
| ------------------------- | ------------------------------------------------------------------------------------------------------------------ |
|
||||
| **`collection`** | If the doc is a collection, its collection config will be returned |
|
||||
| **`global`** | If the doc is a global, its global config will be returned |
|
||||
| **`id`** | If the doc is a collection, its ID will be returned |
|
||||
@@ -804,15 +804,17 @@ const MyComponent: React.FC = () => {
|
||||
|
||||
return (
|
||||
<>
|
||||
<span>The current theme is {theme} and autoMode is {autoMode}</span>
|
||||
<span>
|
||||
The current theme is {theme} and autoMode is {autoMode}
|
||||
</span>
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => setTheme(prev => prev === "light" ? "dark" : "light")}
|
||||
onClick={() => setTheme((prev) => (prev === 'light' ? 'dark' : 'light'))}
|
||||
>
|
||||
Toggle theme
|
||||
</button>
|
||||
</>
|
||||
)
|
||||
)
|
||||
}
|
||||
```
|
||||
|
||||
@@ -833,10 +835,7 @@ const MyComponent: React.FC = () => {
|
||||
// highlight-end
|
||||
|
||||
return (
|
||||
<button
|
||||
type="button"
|
||||
onClick={resetColumns}
|
||||
>
|
||||
<button type="button" onClick={resetColumns}>
|
||||
Reset columns
|
||||
</button>
|
||||
)
|
||||
@@ -847,10 +846,10 @@ const MyComponent: React.FC = () => {
|
||||
|
||||
The `useDocumentEvents` hook provides a way of subscribing to cross-document events, such as updates made to nested documents within a drawer. This hook will report document events that are outside the scope of the document currently being edited. This hook provides the following:
|
||||
|
||||
| Property | Description |
|
||||
|---------------------------|-------------------------------------------------------------------------------------------------------------------------------------------|
|
||||
| **`mostRecentUpdate`** | An object containing the most recently updated document. It contains the `entitySlug`, `id` (if collection), and `updatedAt` properties |
|
||||
| **`reportUpdate`** | A method used to report updates to documents. It accepts the same arguments as the `mostRecentUpdate` property. |
|
||||
| Property | Description |
|
||||
| ---------------------- | --------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| **`mostRecentUpdate`** | An object containing the most recently updated document. It contains the `entitySlug`, `id` (if collection), and `updatedAt` properties |
|
||||
| **`reportUpdate`** | A method used to report updates to documents. It accepts the same arguments as the `mostRecentUpdate` property. |
|
||||
|
||||
**Example:**
|
||||
|
||||
@@ -860,14 +859,11 @@ import { useDocumentEvents } from 'payload/components/hooks'
|
||||
const ListenForUpdates: React.FC = () => {
|
||||
const { mostRecentUpdate } = useDocumentEvents()
|
||||
|
||||
return (
|
||||
<span>
|
||||
{JSON.stringify(mostRecentUpdate)}
|
||||
</span>
|
||||
)
|
||||
return <span>{JSON.stringify(mostRecentUpdate)}</span>
|
||||
}
|
||||
```
|
||||
|
||||
<Banner type="info">
|
||||
Right now the `useDocumentEvents` hook only tracks recently updated documents, but in the future it will track more document-related events as needed, such as document creation, deletion, etc.
|
||||
Right now the `useDocumentEvents` hook only tracks recently updated documents, but in the future
|
||||
it will track more document-related events as needed, such as document creation, deletion, etc.
|
||||
</Banner>
|
||||
|
||||
@@ -6,7 +6,8 @@ desc: NEEDS TO BE WRITTEN
|
||||
---
|
||||
|
||||
<Banner type="info">
|
||||
The Vite bundler is currently in beta. If you would like to help us test this package, we'd love to hear from you if you find any [bugs or issues](https://github.com/payloadcms/payload/issues/)!
|
||||
The Vite bundler is currently in beta. If you would like to help us test this package, we'd love
|
||||
to hear from you if you find any [bugs or issues](https://github.com/payloadcms/payload/issues/)!
|
||||
</Banner>
|
||||
|
||||
Payload has a Vite bundler that you can install and bundle the Admin Panel with. This is an alternative to the [Webpack](/docs/admin/webpack) bundler and might give some performance boosts to your development workflow.
|
||||
@@ -27,7 +28,7 @@ export default buildConfig({
|
||||
collections: [],
|
||||
admin: {
|
||||
bundler: viteBundler(),
|
||||
}
|
||||
},
|
||||
})
|
||||
```
|
||||
|
||||
@@ -36,7 +37,8 @@ Vite works fundamentally differently than Webpack. In development mode, it will
|
||||
It then uses Rollup to create production builds of your admin UI. With Vite, you should see a decent performance boost—especially after your first cold start. However, that first cold start might take a few more seconds.
|
||||
|
||||
<Banner type="warning">
|
||||
In most cases, Vite should work out of the box. But existing Payload plugins may need to make compatibility changes to support Vite.
|
||||
In most cases, Vite should work out of the box. But existing Payload plugins may need to make
|
||||
compatibility changes to support Vite.
|
||||
</Banner>
|
||||
|
||||
This is because Vite aliases work fundamentally differently than Webpack aliases, and Payload relies on aliasing server-only code out of the Payload config to ensure that the bundled admin JS works within your browser.
|
||||
|
||||
@@ -27,7 +27,7 @@ import { webpackBundler } from '@payloadcms/bundler-webpack'
|
||||
export default buildConfig({
|
||||
// highlight-start
|
||||
admin: {
|
||||
bundler: webpackBundler()
|
||||
bundler: webpackBundler(),
|
||||
},
|
||||
// highlight-end
|
||||
})
|
||||
|
||||
@@ -49,7 +49,8 @@ To enable API keys on a collection, set the `useAPIKey` auth option to `true`. F
|
||||
<strong>Important:</strong>
|
||||
If you change your `PAYLOAD_SECRET`, you will need to regenerate your API keys.
|
||||
<br />
|
||||
The secret key is used to encrypt the API keys, so if you change the secret, existing API keys will no longer be valid.
|
||||
The secret key is used to encrypt the API keys, so if you change the secret, existing API keys will
|
||||
no longer be valid.
|
||||
</Banner>
|
||||
|
||||
#### Authenticating via API Key
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user