fulldev-ui 0.2.13 → 0.3.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (102) hide show
  1. package/.astro/settings.json +5 -0
  2. package/.astro/types.d.ts +3 -12
  3. package/.env +1 -0
  4. package/astro.config.mjs +1 -2
  5. package/package.json +4 -7
  6. package/src/_archive/Childmorphic.ts +8 -0
  7. package/src/_archive/getAllCollections.ts +10 -0
  8. package/src/_archive/getCollectionCascade.ts +33 -0
  9. package/src/_archive/getPathname.ts +18 -0
  10. package/src/_archive/staticPageSchema.ts +124 -0
  11. package/src/_archive/transform/transform.ts +25 -0
  12. package/src/_archive/transform/transformCasing.ts +24 -0
  13. package/src/_archive/transform/transformReferences.ts +54 -0
  14. package/src/_archive/transform/transformSelfs.ts +20 -0
  15. package/src/_archive/transform/transformUnderscores.ts +19 -0
  16. package/src/components/_Block.astro +2 -0
  17. package/src/components/{_Tag.astro → _Component.astro} +18 -9
  18. package/src/components/{segment → _archive}/Body.astro +7 -5
  19. package/src/components/{segment → _archive}/Main.astro +4 -4
  20. package/src/components/{segment → _archive}/Nav.astro +4 -4
  21. package/src/components/{structure → _archive}/Row.astro +4 -4
  22. package/src/components/_todo/Footer.astro +66 -0
  23. package/src/components/{segment → _todo}/Form.astro +6 -6
  24. package/src/components/{segment → _todo}/Prose.astro +10 -10
  25. package/src/components/{segment → _todo}/Writeup.astro +4 -4
  26. package/src/components/{segment → _todo}/todo.md +3 -1
  27. package/src/components/base/Badge.astro +6 -6
  28. package/src/components/base/Button.astro +37 -28
  29. package/src/components/base/Checkbox.astro +3 -4
  30. package/src/components/base/Icon.astro +5 -5
  31. package/src/components/base/Image.astro +19 -52
  32. package/src/components/base/Input.astro +12 -7
  33. package/src/components/base/Logo.astro +4 -4
  34. package/src/components/base/Radio.astro +3 -4
  35. package/src/components/base/Rating.astro +5 -5
  36. package/src/components/base/Select.astro +6 -6
  37. package/src/components/base/SelectOption.astro +1 -1
  38. package/src/components/base/Switch.astro +8 -7
  39. package/src/components/base/Textarea.astro +4 -3
  40. package/src/components/segment/Box.astro +41 -0
  41. package/src/components/segment/Card.astro +21 -35
  42. package/src/components/segment/Deck.astro +20 -16
  43. package/src/components/{structure → segment}/Group.astro +8 -7
  44. package/src/components/segment/Header.astro +18 -7
  45. package/src/components/segment/Section.astro +39 -37
  46. package/src/components/typography/Heading.astro +24 -26
  47. package/src/components/typography/Label.astro +17 -11
  48. package/src/components/typography/Link.astro +5 -5
  49. package/src/components/typography/List.astro +9 -6
  50. package/src/components/typography/ListItem.astro +5 -5
  51. package/src/components/typography/Paragraph.astro +17 -11
  52. package/src/components/typography/Tagline.astro +6 -5
  53. package/src/components/typography/Text.astro +40 -0
  54. package/src/{layouts → components/utility}/Layout.astro +6 -6
  55. package/src/content/config.ts +14 -0
  56. package/src/content/pages/index.md +1 -0
  57. package/src/css/color.css +88 -0
  58. package/src/css/props/align.scss +20 -0
  59. package/src/css/props/frame.scss +153 -0
  60. package/src/css/props/mask +1 -0
  61. package/src/css/props/position.scss +33 -0
  62. package/src/css/props/ratio +1 -0
  63. package/src/css/props/structure.scss +228 -0
  64. package/src/css/props/variant.scss +130 -0
  65. package/src/css/radix.css +281 -0
  66. package/src/css/size.css +334 -0
  67. package/src/css/styles.css +2 -2
  68. package/src/index.ts +13 -34
  69. package/src/integration/integration.ts +45 -0
  70. package/src/schemas/collection.ts +87 -0
  71. package/src/blocks/todo.md +0 -12
  72. package/src/components/_Plural.astro +0 -27
  73. package/src/components/base/Buttons.astro +0 -15
  74. package/src/components/base/Images.astro +0 -15
  75. package/src/components/segment/Footer.astro +0 -14
  76. package/src/components/structure/Bento.astro +0 -35
  77. package/src/components/structure/Carousel.astro +0 -43
  78. package/src/components/structure/Grid.astro +0 -30
  79. package/src/components/structure/Masonry.astro +0 -39
  80. package/src/components/structure/Split.astro +0 -41
  81. package/src/components/structure/Spread.astro +0 -48
  82. package/src/components/structure/Stack.astro +0 -90
  83. package/src/components/structure/todo.md +0 -5
  84. package/src/css/colors.css +0 -197
  85. package/src/css/main.css +0 -3
  86. package/src/css/sizes.css +0 -217
  87. package/src/layouts/todo.md +0 -2
  88. package/src/schemas/attributesSchema.ts +0 -125
  89. package/src/schemas/htmlAttributesSchema.ts +0 -126
  90. package/src/schemas/pageSchema.ts +0 -185
  91. package/src/schemas/staticPageSchema.ts +0 -124
  92. package/src/types/Childmorphic.ts +0 -8
  93. package/src/types/Pluralmorphic.ts +0 -7
  94. package/src/types/Structuremorphic.ts +0 -18
  95. package/src/utils/getAllCollections.ts +0 -10
  96. package/src/utils/getCollectionCascade.ts +0 -33
  97. package/src/utils/getPathname.ts +0 -18
  98. package/src/utils/transform/transform.ts +0 -25
  99. package/src/utils/transform/transformCasing.ts +0 -24
  100. package/src/utils/transform/transformReferences.ts +0 -54
  101. package/src/utils/transform/transformSelfs.ts +0 -20
  102. package/src/utils/transform/transformUnderscores.ts +0 -19
package/src/css/sizes.css DELETED
@@ -1,217 +0,0 @@
1
- :root,
2
- .density-base {
3
- --space-sm-1: 3px;
4
- --space-sm-2: 6px;
5
- --space-sm-3: 12px;
6
- --space-sm-4: 24px;
7
- --space-sm-5: 48px;
8
- --space-sm-6: 96px;
9
- --space-md-1: 4px;
10
- --space-md-2: 8px;
11
- --space-md-3: 16px;
12
- --space-md-4: 32px;
13
- --space-md-5: 64px;
14
- --space-md-6: 128px;
15
- --space-lg-1: 5px;
16
- --space-lg-2: 10px;
17
- --space-lg-3: 20px;
18
- --space-lg-4: 40px;
19
- --space-lg-5: 80px;
20
- --space-lg-6: 160px;
21
-
22
- --element-sm-1: 6px;
23
- --element-sm-2: 9px;
24
- --element-sm-3: 12px;
25
- --element-md-1: 8px;
26
- --element-md-2: 12px;
27
- --element-md-3: 16px;
28
- --element-lg-1: 10px;
29
- --element-lg-2: 16px;
30
- --element-lg-3: 20px;
31
-
32
- --text-sm-1: 12px;
33
- --text-sm-2: 14px;
34
- --text-sm-3: 20px;
35
- --text-sm-4: 24px;
36
- --text-sm-5: 30px;
37
- --text-md-1: 14px;
38
- --text-md-2: 16px;
39
- --text-md-3: 24px;
40
- --text-md-4: 30px;
41
- --text-md-5: 36px;
42
- --text-lg-1: 16px;
43
- --text-lg-2: 18px;
44
- --text-lg-3: 30px;
45
- --text-lg-4: 36px;
46
- --text-lg-5: 36px;
47
-
48
- @media (min-width: 1024px) {
49
- --text-sm-1: 14px;
50
- --text-sm-2: 16px;
51
- --text-sm-3: 24px;
52
- --text-sm-4: 30px;
53
- --text-sm-5: 36px;
54
- --text-md-1: 16px;
55
- --text-md-2: 18px;
56
- --text-md-3: 30px;
57
- --text-md-4: 36px;
58
- --text-md-5: 48px;
59
- --text-lg-1: 16px;
60
- --text-lg-2: 20px;
61
- --text-lg-3: 36px;
62
- --text-lg-4: 48px;
63
- --text-lg-5: 60px;
64
- }
65
- }
66
-
67
- .density-compact {
68
- --space-sm-1: 3px;
69
- --space-sm-2: 6px;
70
- --space-sm-3: 9px;
71
- --space-sm-4: 12px;
72
- --space-sm-5: 15px;
73
- --space-sm-6: 18px;
74
- --space-md-1: 4px;
75
- --space-md-2: 8px;
76
- --space-md-3: 12px;
77
- --space-md-4: 16px;
78
- --space-md-5: 20px;
79
- --space-md-6: 24px;
80
- --space-lg-1: 5px;
81
- --space-lg-2: 10px;
82
- --space-lg-3: 15px;
83
- --space-lg-4: 20px;
84
- --space-lg-5: 25px;
85
- --space-lg-6: 30px;
86
-
87
- --element-sm-1: 6px;
88
- --element-sm-2: 8px;
89
- --element-sm-3: 10px;
90
- --element-md-1: 8px;
91
- --element-md-2: 10px;
92
- --element-md-3: 12px;
93
- --element-lg-1: 10px;
94
- --element-lg-2: 12px;
95
- --element-lg-3: 14px;
96
-
97
- --text-sm-1: 12px;
98
- --text-sm-2: 12px;
99
- --text-sm-3: 12px;
100
- --text-sm-4: 14px;
101
- --text-sm-5: 16px;
102
- --text-md-1: 14px;
103
- --text-md-2: 14px;
104
- --text-md-3: 14px;
105
- --text-md-4: 16px;
106
- --text-md-5: 18px;
107
- --text-lg-1: 14px;
108
- --text-lg-2: 16px;
109
- --text-lg-3: 16px;
110
- --text-lg-4: 18px;
111
- --text-lg-5: 20px;
112
-
113
- @media (min-width: 1024px) {
114
- --text-sm-1: 12px;
115
- --text-sm-2: 14px;
116
- --text-sm-3: 14px;
117
- --text-sm-4: 16px;
118
- --text-sm-5: 18px;
119
- --text-md-1: 14px;
120
- --text-md-2: 16px;
121
- --text-md-3: 16px;
122
- --text-md-4: 18px;
123
- --text-md-5: 20px;
124
- --text-lg-1: 16px;
125
- --text-lg-2: 18px;
126
- --text-lg-3: 18px;
127
- --text-lg-4: 20px;
128
- --text-lg-5: 24px;
129
- }
130
- }
131
-
132
- /* --------------------------- */
133
- /* Generate sizes */
134
- /* --------------------------- */
135
-
136
- .size-sm,
137
- .size-sm
138
- [class*='density-']:not(.size-sm [class*='size-'] [class*='density-']):not(
139
- .size-sm [class*='size-'][class*='density-']
140
- ) {
141
- --space-1: var(--space-sm-1);
142
- --space-2: var(--space-sm-2);
143
- --space-3: var(--space-sm-3);
144
- --space-4: var(--space-sm-4);
145
- --space-5: var(--space-sm-5);
146
- --space-6: var(--space-sm-6);
147
-
148
- --element-1: var(--element-sm-1);
149
- --element-2: var(--element-sm-2);
150
- --element-3: var(--element-sm-3);
151
-
152
- --text-1: var(--text-sm-1);
153
- --text-2: var(--text-sm-2);
154
- --text-3: var(--text-sm-3);
155
- --text-4: var(--text-sm-4);
156
- --text-5: var(--text-sm-5);
157
-
158
- --radius-1: calc(var(--border-radius, 1) * var(--element-sm-1));
159
- --radius-2: calc(var(--border-radius, 1) * var(--element-sm-2));
160
- --radius-3: calc(var(--border-radius, 1) * var(--element-sm-3));
161
- }
162
-
163
- :where(:root),
164
- :where([class*='density-']),
165
- .size-md,
166
- .size-md
167
- [class*='density-']:not(.size-md [class*='size-'] [class*='density-']):not(
168
- .size-md [class*='size-'][class*='density-']
169
- ) {
170
- --space-1: var(--space-md-1);
171
- --space-2: var(--space-md-2);
172
- --space-3: var(--space-md-3);
173
- --space-4: var(--space-md-4);
174
- --space-5: var(--space-md-5);
175
- --space-6: var(--space-md-6);
176
-
177
- --element-1: var(--element-md-1);
178
- --element-2: var(--element-md-2);
179
- --element-3: var(--element-md-3);
180
-
181
- --text-1: var(--text-md-1);
182
- --text-2: var(--text-md-2);
183
- --text-3: var(--text-md-3);
184
- --text-4: var(--text-md-4);
185
- --text-5: var(--text-md-5);
186
-
187
- --radius-1: calc(var(--border-radius, 1) * var(--element-md-1));
188
- --radius-2: calc(var(--border-radius, 1) * var(--element-md-2));
189
- --radius-3: calc(var(--border-radius, 1) * var(--element-md-3));
190
- }
191
-
192
- .size-lg,
193
- .size-lg
194
- [class*='density-']:not(.size-lg [class*='size-'] [class*='density-']):not(
195
- .size-lg [class*='size-'][class*='density-']
196
- ) {
197
- --space-1: var(--space-lg-1);
198
- --space-2: var(--space-lg-2);
199
- --space-3: var(--space-lg-3);
200
- --space-4: var(--space-lg-4);
201
- --space-5: var(--space-lg-5);
202
- --space-6: var(--space-lg-6);
203
-
204
- --element-1: var(--element-lg-1);
205
- --element-2: var(--element-lg-2);
206
- --element-3: var(--element-lg-3);
207
-
208
- --text-1: var(--text-lg-1);
209
- --text-2: var(--text-lg-2);
210
- --text-3: var(--text-lg-3);
211
- --text-4: var(--text-lg-4);
212
- --text-5: var(--text-lg-5);
213
-
214
- --radius-1: calc(var(--border-radius, 1) * var(--element-lg-1));
215
- --radius-2: calc(var(--border-radius, 1) * var(--element-lg-2));
216
- --radius-3: calc(var(--border-radius, 1) * var(--element-lg-3));
217
- }
@@ -1,2 +0,0 @@
1
- example:
2
- Layout component should choose which layout. Could also be a local hero. similar behaviour as blocks, but then only layouts.
@@ -1,125 +0,0 @@
1
- import { z } from 'astro:content'
2
-
3
- export const attributesSchema = z.object({
4
- abbr: z.any(),
5
- accept: z.any(),
6
- acceptCharset: z.any(),
7
- accessKey: z.any(),
8
- allowFullScreen: z.any(),
9
- allowTransparency: z.any(),
10
- alt: z.any(),
11
- async: z.any(),
12
- autoComplete: z.any(),
13
- autoFocus: z.any(),
14
- autoPlay: z.any(),
15
- cellPadding: z.any(),
16
- cellSpacing: z.any(),
17
- challenge: z.any(),
18
- charset: z.any(),
19
- checked: z.any(),
20
- cite: z.any(),
21
- class: z.any(),
22
- className: z.any(),
23
- cols: z.any(),
24
- colSpan: z.any(),
25
- command: z.any(),
26
- content: z.any(),
27
- contentEditable: z.any(),
28
- contextMenu: z.any(),
29
- controls: z.any(),
30
- coords: z.any(),
31
- crossOrigin: z.any(),
32
- data: z.any(),
33
- dateTime: z.any(),
34
- default: z.any(),
35
- defer: z.any(),
36
- dir: z.any(),
37
- disabled: z.any(),
38
- download: z.any(),
39
- draggable: z.any(),
40
- dropzone: z.any(),
41
- encType: z.any(),
42
- for: z.any(),
43
- form: z.any(),
44
- action: z.any(),
45
- formEncType: z.any(),
46
- method: z.any(),
47
- formNoValidate: z.any(),
48
- target: z.any(),
49
- frameBorder: z.any(),
50
- headers: z.any(),
51
- height: z.any(),
52
- hidden: z.any(),
53
- high: z.any(),
54
- href: z.any(),
55
- hrefLang: z.any(),
56
- htmlFor: z.any(),
57
- httpEquiv: z.any(),
58
- id: z.any(),
59
- inputMode: z.any(),
60
- isMap: z.any(),
61
- itemId: z.any(),
62
- itemProp: z.any(),
63
- itemRef: z.any(),
64
- itemScope: z.any(),
65
- itemType: z.any(),
66
- kind: z.any(),
67
- label: z.any(),
68
- lang: z.any(),
69
- list: z.any(),
70
- loop: z.any(),
71
- manifest: z.any(),
72
- max: z.any(),
73
- maxLength: z.any(),
74
- media: z.any(),
75
- mediaGroup: z.any(),
76
- min: z.any(),
77
- minLength: z.any(),
78
- multiple: z.any(),
79
- muted: z.any(),
80
- name: z.any(),
81
- noValidate: z.any(),
82
- open: z.any(),
83
- optimum: z.any(),
84
- pattern: z.any(),
85
- ping: z.any(),
86
- placeholder: z.any(),
87
- poster: z.any(),
88
- preload: z.any(),
89
- rel: z.any(),
90
- required: z.any(),
91
- rows: z.any(),
92
- sizes: z.any(),
93
-
94
- // role: z.any(),
95
- // radioGroup: z.any(),
96
- // readOnly: z.any(),
97
- // rowSpan: z.any(),
98
- // sandbox: z.any(),
99
- // scope: z.any(),
100
- // scoped: z.any(),
101
- // scrolling: z.any(),
102
- // seamless: z.any(),
103
- // selected: z.any(),
104
- // shape: z.any(),
105
- // size: z.any(),
106
- // sortable: z.any(),
107
- // span: z.any(),
108
- // spellCheck: z.any(),
109
- src: z.any(),
110
- // srcDoc: z.any(),
111
- srcset: z.any(),
112
- // start: z.any(),
113
- // step: z.any(),
114
- style: z.any(),
115
- tabIndex: z.any(),
116
- title: z.any(),
117
- // translate: z.any(),
118
- type: z.any(),
119
- // typeMustMatch: z.any(),
120
- // useMap: z.any(),
121
- value: z.any(),
122
- width: z.any(),
123
- // wmode: z.any(),
124
- // wrap: z.any(),
125
- })
@@ -1,126 +0,0 @@
1
- const arr = [
2
- 'abbr',
3
- 'accept',
4
- 'acceptCharset',
5
- 'accessKey',
6
- 'action',
7
- 'allowFullScreen',
8
- 'allowTransparency',
9
- 'alt',
10
- 'async',
11
- 'autoComplete',
12
- 'autoFocus',
13
- 'autoPlay',
14
- 'cellPadding',
15
- 'cellSpacing',
16
- 'challenge',
17
- 'charset',
18
- 'checked',
19
- 'cite',
20
- 'class',
21
- 'className',
22
- 'cols',
23
- 'colSpan',
24
- 'command',
25
- 'content',
26
- 'contentEditable',
27
- 'contextMenu',
28
- 'controls',
29
- 'coords',
30
- 'crossOrigin',
31
- 'data',
32
- 'dateTime',
33
- 'default',
34
- 'defer',
35
- 'dir',
36
- 'disabled',
37
- 'download',
38
- 'draggable',
39
- 'dropzone',
40
- 'encType',
41
- 'for',
42
- 'form',
43
- 'formAction',
44
- 'formEncType',
45
- 'formMethod',
46
- 'formNoValidate',
47
- 'formTarget',
48
- 'frameBorder',
49
- 'headers',
50
- 'height',
51
- 'hidden',
52
- 'high',
53
- 'href',
54
- 'hrefLang',
55
- 'htmlFor',
56
- 'httpEquiv',
57
- 'icon',
58
- 'id',
59
- 'inputMode',
60
- 'isMap',
61
- 'itemId',
62
- 'itemProp',
63
- 'itemRef',
64
- 'itemScope',
65
- 'itemType',
66
- 'kind',
67
- 'label',
68
- 'lang',
69
- 'list',
70
- 'loop',
71
- 'manifest',
72
- 'max',
73
- 'maxLength',
74
- 'media',
75
- 'mediaGroup',
76
- 'method',
77
- 'min',
78
- 'minLength',
79
- 'multiple',
80
- 'muted',
81
- 'name',
82
- 'noValidate',
83
- 'open',
84
- 'optimum',
85
- 'pattern',
86
- 'ping',
87
- 'placeholder',
88
- 'poster',
89
- 'preload',
90
- 'radioGroup',
91
- 'readOnly',
92
- 'rel',
93
- 'required',
94
- 'role',
95
- 'rows',
96
- 'rowSpan',
97
- 'sandbox',
98
- 'scope',
99
- 'scoped',
100
- 'scrolling',
101
- 'seamless',
102
- 'selected',
103
- 'shape',
104
- 'size',
105
- 'sizes',
106
- 'sortable',
107
- 'span',
108
- 'spellCheck',
109
- 'src',
110
- 'srcDoc',
111
- 'srcSet',
112
- 'start',
113
- 'step',
114
- 'style',
115
- 'tabIndex',
116
- 'target',
117
- 'title',
118
- 'translate',
119
- 'type',
120
- 'typeMustMatch',
121
- 'useMap',
122
- 'value',
123
- 'width',
124
- 'wmode',
125
- 'wrap',
126
- ]
@@ -1,185 +0,0 @@
1
- import {
2
- getCollection,
3
- getEntries,
4
- getEntry,
5
- z,
6
- type CollectionEntry,
7
- type CollectionKey,
8
- } from 'astro:content'
9
- import { flatten, unflatten } from 'flat'
10
- import {
11
- all,
12
- camel,
13
- construct,
14
- get,
15
- isString,
16
- mapValues,
17
- objectify,
18
- } from 'radash'
19
- import { mapKeys, merge } from 'remeda'
20
-
21
- interface Options {
22
- casing: boolean
23
- layouts: boolean
24
- references: boolean
25
- selfs: boolean
26
- }
27
-
28
- const defaults: Options = {
29
- casing: true,
30
- layouts: true,
31
- references: true,
32
- selfs: true,
33
- }
34
-
35
- let cascade: any = {}
36
-
37
- const transformReferences = async (data: object) =>
38
- await all(
39
- mapValues(flatten(data) as any, async (value) => {
40
- if (!isString(value)) return value
41
- const parts = (value as string).split(' ')
42
- const results = await all(
43
- parts.map(async (valuePart) => {
44
- if (!valuePart.startsWith('$')) return valuePart
45
- if (valuePart.startsWith('$self')) return valuePart
46
-
47
- const reference = valuePart.split('.')[0].replace('$', '')
48
- const collection = reference.split('/')[0]
49
- const slug = reference.split('/').slice(1).join('/')
50
- const path = valuePart.split('.').slice(1).join('.')
51
-
52
- if (collection && slug) {
53
- let response = await getEntry(collection as CollectionKey, slug)
54
- const parsed = await pageSchema().parseAsync(response?.data)
55
- // let response: any = get(cascade, `${collection}/${slug}`)
56
- const result = get(parsed, path)
57
- response = undefined
58
- return result
59
- } else if (collection) {
60
- const response = await getCollection(collection as CollectionKey)
61
- // const response: any = get(cascade, collection)
62
- const result = response?.map((entry: any) => get(entry?.data, path))
63
- return result
64
- }
65
-
66
- return valuePart
67
- })
68
- )
69
- if (results.length == 1) return results[0]
70
- return results.join(' ')
71
- })
72
- )
73
-
74
- const transformLayouts = (data: object) => {
75
- const flat: any = flatten(data)
76
- let store: any = {}
77
- let i: number = 0
78
-
79
- const merged = mapKeys(flat, (key) => {
80
- if (!isString(key)) return key
81
- const parts = key.split('.')
82
- const result = parts.map((part) => {
83
- return part.replace(/^_+/, '')
84
- })
85
- const filtered = result.filter(Boolean)
86
- const joined = filtered.join('.')
87
- return joined
88
- })
89
- const nested = construct(merged)
90
- return nested
91
- }
92
-
93
- const transformSelfs = (data: object) => {
94
- const flat = flatten(data) as any
95
- const mapped = mapValues(flat, (value) => {
96
- if (!isString(value)) return value
97
- const parts = (value as string).split(' ')
98
- const result = parts.map((part) => {
99
- if (!part.startsWith('$self')) return part
100
- const pathParts = part.split('.').slice(1)
101
- const camelCased = pathParts.map((part) => camel(part))
102
- const path = camelCased.join('.')
103
- const result = get(data, path)
104
- return result ? result : part
105
- })
106
- return result.join(' ')
107
- })
108
- return unflatten(mapped)
109
- }
110
-
111
- const transformCasing = (object: object) => {
112
- const flat = flatten(object)
113
- const mapped = mapKeys(flat, (key) => {
114
- if (!isString(key)) return key
115
- const parts = (key as string).split('.')
116
- const result = parts.map((part) => camel(part))
117
- return result.join('.')
118
- })
119
- return unflatten(mapped)
120
- }
121
-
122
- const buildCascade = async (data: any) => {
123
- const flat: any = flatten(data)
124
- const values = Object.values(flat)
125
- const strings = values.filter(isString)
126
- const parts = strings.map((value: any) => value.split(' ')).flat()
127
- const fullpaths = parts.filter(
128
- (value) => value.startsWith('$') && !value.startsWith('$self')
129
- )
130
- const filepaths = fullpaths.map((f) => f.replace('$', '').split('.')[0])
131
-
132
- const collections = filepaths.filter((f) => !f.includes('/'))
133
- const collectionsNew = collections.filter((c) => !cascade[c])
134
- // console.log('collectionsNew', collectionsNew)
135
- const collectionsPromises = collectionsNew.map((c) => getCollection(c))
136
- const collectionsResponses = await Promise.all(collectionsPromises)
137
- const collectionsCascade = objectify(
138
- collectionsResponses,
139
- (c: any) => c[0]?.collection
140
- )
141
-
142
- const entries = filepaths.filter((f) => f.includes('/'))
143
- const entriesNew = entries.filter(
144
- (e) => !cascade[e.split('/').slice(1).join('/')]
145
- )
146
- // console.log('entriesNew', entriesNew)
147
- const entriesResponses = await getEntries(
148
- entriesNew.map((e) => ({
149
- collection: e.split('/')[0],
150
- slug: e.split('/').slice(1).join('/'),
151
- }))
152
- )
153
- const entriesCascade = objectify(
154
- entriesResponses,
155
- (e: any) => `${e?.collection}/${e?.slug || e?.id}`
156
- )
157
-
158
- cascade = { ...cascade, ...collectionsCascade, ...entriesCascade }
159
- }
160
-
161
- let doIStay = false
162
-
163
- export const pageSchema = (options: Partial<Options> = {}) =>
164
- z.any().transform(async (data: CollectionEntry<CollectionKey>['data']) => {
165
- const { layouts, casing, references, selfs } = merge(defaults, options)
166
-
167
- // console.log('doIStay', doIStay)
168
- // console.log('cascade', Object.keys(cascade))
169
- doIStay = true
170
- // await buildCascade(data)
171
-
172
- if (references) data = await transformReferences(data)
173
- // console.log('references', data)
174
-
175
- if (layouts) data = transformLayouts(data)
176
- // console.log('layouts', data)
177
-
178
- if (casing) data = transformCasing(data)
179
- // console.log('casing', data)
180
-
181
- if (selfs) data = transformSelfs(data)
182
- // console.log('selfs', data)
183
-
184
- return data
185
- })