@schalkneethling/miyagi-core 4.4.2 → 4.4.3

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 (115) hide show
  1. package/README.md +7 -2
  2. package/api/app.js +16 -16
  3. package/api/index.js +263 -262
  4. package/bin/miyagi.js +1 -1
  5. package/dist/css/iframe.css +6 -30
  6. package/frontend/assets/css/iframe/accordion-tabs.css +39 -39
  7. package/frontend/assets/css/iframe/jsontree.js.css +149 -149
  8. package/frontend/assets/css/iframe/prism.css +45 -45
  9. package/frontend/assets/css/iframe/styleguide/colors.css +27 -27
  10. package/frontend/assets/css/iframe/styleguide/fonts.css +23 -23
  11. package/frontend/assets/css/iframe/styleguide/index.css +58 -58
  12. package/frontend/assets/css/iframe/styleguide/spacings.css +10 -10
  13. package/frontend/assets/css/iframe.css +191 -191
  14. package/frontend/assets/css/main/menu/config-switcher.css +21 -21
  15. package/frontend/assets/css/main/menu/config-switchers.css +34 -34
  16. package/frontend/assets/css/main/menu/goto.css +16 -16
  17. package/frontend/assets/css/main/menu/nav.css +49 -49
  18. package/frontend/assets/css/main/menu/search.css +34 -34
  19. package/frontend/assets/css/main/menu/title.css +18 -18
  20. package/frontend/assets/css/main/menu.css +89 -89
  21. package/frontend/assets/css/main/reset.css +47 -47
  22. package/frontend/assets/css/main.css +41 -41
  23. package/frontend/assets/css/shared.css +16 -16
  24. package/frontend/assets/css/tokens.css +108 -107
  25. package/frontend/assets/js/_accordion-tabs.js +392 -392
  26. package/frontend/assets/js/_goto.js +59 -59
  27. package/frontend/assets/js/_iframe-links.js +14 -14
  28. package/frontend/assets/js/_is-triggered.js +3 -3
  29. package/frontend/assets/js/_main.js +369 -369
  30. package/frontend/assets/js/_mock-data.js +8 -8
  31. package/frontend/assets/js/_prism.js +1082 -1081
  32. package/frontend/assets/js/_search.js +186 -186
  33. package/frontend/assets/js/_socket.js +44 -44
  34. package/frontend/assets/js/config-switcher/development-mode.js +38 -38
  35. package/frontend/assets/js/config-switcher/index.js +55 -55
  36. package/frontend/assets/js/config-switcher/text-direction.js +22 -22
  37. package/frontend/assets/js/config-switcher/theme.js +68 -68
  38. package/frontend/assets/js/iframe.build.js +25 -25
  39. package/frontend/assets/js/iframe.js +38 -38
  40. package/frontend/assets/js/jsontree.js +979 -976
  41. package/frontend/assets/js/main.build.js +29 -29
  42. package/frontend/assets/js/main.js +31 -31
  43. package/frontend/assets/js/styleguide/color-converter.js +652 -652
  44. package/frontend/assets/js/styleguide/index.js +100 -100
  45. package/lib/build/index.js +1014 -1020
  46. package/lib/cli/app.js +16 -16
  47. package/lib/cli/component.js +50 -50
  48. package/lib/cli/doctor.js +130 -121
  49. package/lib/cli/drupal-assets.js +163 -157
  50. package/lib/cli/lint.js +196 -196
  51. package/lib/cli/run.js +150 -146
  52. package/lib/config.js +86 -86
  53. package/lib/constants/lint-log-levels.js +6 -6
  54. package/lib/drupal/load-assets-config.js +59 -60
  55. package/lib/drupal/resolve-library-assets.js +132 -141
  56. package/lib/errors.js +20 -20
  57. package/lib/generator/component.js +124 -124
  58. package/lib/generator/mocks.js +156 -156
  59. package/lib/helpers.js +68 -68
  60. package/lib/i18n/en.js +93 -93
  61. package/lib/i18n/index.js +8 -8
  62. package/lib/index.js +13 -13
  63. package/lib/init/args.js +153 -153
  64. package/lib/init/config.js +452 -438
  65. package/lib/init/engines.js +41 -41
  66. package/lib/init/index.js +83 -83
  67. package/lib/init/rendering.js +3 -3
  68. package/lib/init/static.js +90 -90
  69. package/lib/init/twing/cache.js +27 -27
  70. package/lib/init/twing/functions.js +37 -37
  71. package/lib/init/views.js +5 -5
  72. package/lib/logger.js +72 -72
  73. package/lib/mocks/get.js +88 -88
  74. package/lib/mocks/index.js +2 -2
  75. package/lib/mocks/resolve/ref.js +447 -447
  76. package/lib/mocks/resolve/tpl.js +218 -218
  77. package/lib/mocks/resolve.js +154 -154
  78. package/lib/render/helpers/resolve-assets.js +29 -39
  79. package/lib/render/helpers.js +27 -27
  80. package/lib/render/index.js +18 -18
  81. package/lib/render/views/iframe/component.docs.js +50 -50
  82. package/lib/render/views/iframe/component.js +249 -248
  83. package/lib/render/views/iframe/design-tokens/colors.js +38 -38
  84. package/lib/render/views/iframe/design-tokens/index.js +3 -3
  85. package/lib/render/views/iframe/design-tokens/sizes.js +35 -35
  86. package/lib/render/views/iframe/design-tokens/typography.js +37 -37
  87. package/lib/render/views/iframe/docs.js +42 -42
  88. package/lib/render/views/iframe/index.js +28 -28
  89. package/lib/render/views/iframe/variation.js +89 -89
  90. package/lib/render/views/iframe/variation.standalone.js +69 -68
  91. package/lib/render/views/main/component.docs.js +38 -38
  92. package/lib/render/views/main/component.js +55 -55
  93. package/lib/render/views/main/design-tokens.js +38 -38
  94. package/lib/render/views/main/docs.js +33 -33
  95. package/lib/render/views/main/index.js +33 -33
  96. package/lib/state/components.js +99 -99
  97. package/lib/state/css.js +33 -33
  98. package/lib/state/docs.js +72 -72
  99. package/lib/state/file-contents.js +154 -154
  100. package/lib/state/helpers.js +53 -53
  101. package/lib/state/index.js +39 -39
  102. package/lib/state/menu/index.js +202 -202
  103. package/lib/state/menu/structure.js +84 -84
  104. package/lib/state/partials.js +12 -12
  105. package/lib/state/source-tree.js +51 -51
  106. package/lib/styleguide/color-names.js +148 -148
  107. package/lib/styleguide/colors.js +113 -113
  108. package/lib/styleguide/helpers.js +33 -33
  109. package/lib/styleguide/index.js +4 -4
  110. package/lib/styleguide/media-queries.js +18 -18
  111. package/lib/styleguide/spacings.js +22 -22
  112. package/lib/styleguide/typography.js +46 -46
  113. package/lib/validator/mocks.js +110 -83
  114. package/lib/validator/schemas.js +236 -227
  115. package/package.json +118 -117
@@ -9,35 +9,35 @@ import { extendTemplateData } from "../render/helpers.js";
9
9
  * @returns {Function}
10
10
  */
11
11
  function getMergeMethod(method) {
12
- const methods = {
13
- combine: (target, source, options) => {
14
- const destination = target.slice();
15
-
16
- source.forEach((item, index) => {
17
- if (options.isMergeableObject(item)) {
18
- if (typeof destination[index] === "undefined") {
19
- destination[index] = options.cloneUnlessOtherwiseSpecified(
20
- item,
21
- options,
22
- );
23
- } else {
24
- destination[index] = deepMerge(target[index], item, options);
25
- }
26
- } else {
27
- destination[index] = options.cloneUnlessOtherwiseSpecified(
28
- item,
29
- options,
30
- );
31
- }
32
- });
33
-
34
- return destination;
35
- },
36
-
37
- overwrite: (destinationArray, sourceArray) => sourceArray,
38
- };
39
-
40
- return methods[method];
12
+ const methods = {
13
+ combine: (target, source, options) => {
14
+ const destination = target.slice();
15
+
16
+ source.forEach((item, index) => {
17
+ if (options.isMergeableObject(item)) {
18
+ if (typeof destination[index] === "undefined") {
19
+ destination[index] = options.cloneUnlessOtherwiseSpecified(
20
+ item,
21
+ options,
22
+ );
23
+ } else {
24
+ destination[index] = deepMerge(target[index], item, options);
25
+ }
26
+ } else {
27
+ destination[index] = options.cloneUnlessOtherwiseSpecified(
28
+ item,
29
+ options,
30
+ );
31
+ }
32
+ });
33
+
34
+ return destination;
35
+ },
36
+
37
+ overwrite: (destinationArray, sourceArray) => sourceArray,
38
+ };
39
+
40
+ return methods[method];
41
41
  }
42
42
 
43
43
  /**
@@ -47,27 +47,27 @@ function getMergeMethod(method) {
47
47
  * @returns {Promise<{ merged, resolved, messages }>} the resolved data object
48
48
  */
49
49
  export const resolveData = async function (data, component, rootData) {
50
- const mergedWithGlobalData = mergeWithGlobalData(
51
- rootData ? mergeRootDataWithVariationData(rootData, data) : data,
52
- );
53
- const { data: refsResolved, messages: refMessages } = await resolveRefs(
54
- { ...mergedWithGlobalData },
55
- component,
56
- );
57
- const extended = await extendTemplateData(
58
- global.config,
59
- refsResolved,
60
- component,
61
- );
62
- const { data: tplsResolved, messages: tplMessages } =
63
- await resolveTpls(extended);
64
- const resolved = overwriteRenderKey(tplsResolved);
65
-
66
- return {
67
- merged: mergedWithGlobalData,
68
- resolved,
69
- messages: [...refMessages, ...tplMessages],
70
- };
50
+ const mergedWithGlobalData = mergeWithGlobalData(
51
+ rootData ? mergeRootDataWithVariationData(rootData, data) : data,
52
+ );
53
+ const { data: refsResolved, messages: refMessages } = await resolveRefs(
54
+ { ...mergedWithGlobalData },
55
+ component,
56
+ );
57
+ const extended = await extendTemplateData(
58
+ global.config,
59
+ refsResolved,
60
+ component,
61
+ );
62
+ const { data: tplsResolved, messages: tplMessages } =
63
+ await resolveTpls(extended);
64
+ const resolved = overwriteRenderKey(tplsResolved);
65
+
66
+ return {
67
+ merged: mergedWithGlobalData,
68
+ resolved,
69
+ messages: [...refMessages, ...tplMessages],
70
+ };
71
71
  };
72
72
 
73
73
  /**
@@ -75,69 +75,69 @@ export const resolveData = async function (data, component, rootData) {
75
75
  * @returns {object} the resolved data object
76
76
  */
77
77
  export const overwriteRenderKey = function (data) {
78
- let o;
79
-
80
- if (
81
- ["string", "number", "boolean"].includes(typeof data) ||
82
- data instanceof Map
83
- ) {
84
- return data;
85
- }
86
-
87
- if (Array.isArray(data)) {
88
- for (let item of data) {
89
- item = overwriteRenderKey(item);
90
- }
91
-
92
- return data;
93
- }
94
-
95
- if (data) {
96
- o = { ...data };
97
- const entries = Object.entries(o);
98
-
99
- for (const [key, val] of entries) {
100
- if (key === "$render") {
101
- let str = "";
102
-
103
- if (val) {
104
- for (const html of val) {
105
- str += html;
106
- }
107
- }
108
-
109
- o = str;
110
- } else {
111
- if (
112
- typeof val == "string" ||
113
- typeof val === "number" ||
114
- typeof val === "boolean" ||
115
- val instanceof Map ||
116
- val === null
117
- ) {
118
- o[key] = val;
119
- } else if (Array.isArray(val)) {
120
- val.forEach((v, i) => {
121
- if (
122
- typeof v == "string" ||
123
- typeof v === "number" ||
124
- typeof v === "boolean" ||
125
- v instanceof Map ||
126
- v === null
127
- ) {
128
- o[key][i] = v;
129
- } else {
130
- o[key][i] = overwriteRenderKey(v);
131
- }
132
- });
133
- } else {
134
- o[key] = overwriteRenderKey(val);
135
- }
136
- }
137
- }
138
- }
139
-
140
- return o;
78
+ let o;
79
+
80
+ if (
81
+ ["string", "number", "boolean"].includes(typeof data) ||
82
+ data instanceof Map
83
+ ) {
84
+ return data;
85
+ }
86
+
87
+ if (Array.isArray(data)) {
88
+ for (let item of data) {
89
+ item = overwriteRenderKey(item);
90
+ }
91
+
92
+ return data;
93
+ }
94
+
95
+ if (data) {
96
+ o = { ...data };
97
+ const entries = Object.entries(o);
98
+
99
+ for (const [key, val] of entries) {
100
+ if (key === "$render") {
101
+ let str = "";
102
+
103
+ if (val) {
104
+ for (const html of val) {
105
+ str += html;
106
+ }
107
+ }
108
+
109
+ o = str;
110
+ } else {
111
+ if (
112
+ typeof val == "string" ||
113
+ typeof val === "number" ||
114
+ typeof val === "boolean" ||
115
+ val instanceof Map ||
116
+ val === null
117
+ ) {
118
+ o[key] = val;
119
+ } else if (Array.isArray(val)) {
120
+ val.forEach((v, i) => {
121
+ if (
122
+ typeof v == "string" ||
123
+ typeof v === "number" ||
124
+ typeof v === "boolean" ||
125
+ v instanceof Map ||
126
+ v === null
127
+ ) {
128
+ o[key][i] = v;
129
+ } else {
130
+ o[key][i] = overwriteRenderKey(v);
131
+ }
132
+ });
133
+ } else {
134
+ o[key] = overwriteRenderKey(val);
135
+ }
136
+ }
137
+ }
138
+ }
139
+
140
+ return o;
141
141
  };
142
142
 
143
143
  /**
@@ -146,38 +146,38 @@ export const overwriteRenderKey = function (data) {
146
146
  * @returns {object} the merged data
147
147
  */
148
148
  export const mergeRootDataWithVariationData = function (
149
- rootData,
150
- variationData,
149
+ rootData,
150
+ variationData,
151
151
  ) {
152
- if (!rootData) {
153
- return variationData;
154
- }
152
+ if (!rootData) {
153
+ return variationData;
154
+ }
155
155
 
156
- if (!variationData) {
157
- return rootData;
158
- }
156
+ if (!variationData) {
157
+ return rootData;
158
+ }
159
159
 
160
- const merged = deepMerge(rootData, variationData, {
161
- customMerge: (key) => {
162
- const options = variationData.$opts || rootData.$opts;
160
+ const merged = deepMerge(rootData, variationData, {
161
+ customMerge: (key) => {
162
+ const options = variationData.$opts || rootData.$opts;
163
163
 
164
- if (options) {
165
- const option = options[key];
164
+ if (options) {
165
+ const option = options[key];
166
166
 
167
- if (option) {
168
- return getMergeMethod(option);
169
- }
170
- }
167
+ if (option) {
168
+ return getMergeMethod(option);
169
+ }
170
+ }
171
171
 
172
- return undefined;
173
- },
174
- });
172
+ return undefined;
173
+ },
174
+ });
175
175
 
176
- if (merged.$opts) {
177
- delete merged.$opts;
178
- }
176
+ if (merged.$opts) {
177
+ delete merged.$opts;
178
+ }
179
179
 
180
- return merged;
180
+ return merged;
181
181
  };
182
182
 
183
183
  /**
@@ -185,21 +185,21 @@ export const mergeRootDataWithVariationData = function (
185
185
  * @returns {object} the merged data object
186
186
  */
187
187
  function mergeWithGlobalData(data) {
188
- const defaultFile = helpers.getFullPathFromShortPath(
189
- `${global.config.files.mocks.name}.${global.config.files.mocks.extension[0]}`,
190
- );
191
- const jsFile = helpers.getFullPathFromShortPath(
192
- `${global.config.files.mocks.name}.${global.config.files.mocks.extension[1]}`,
193
- );
194
- const globalData = {
195
- ...(global.state.fileContents[defaultFile] ||
196
- global.state.fileContents[jsFile]),
197
- };
198
-
199
- delete globalData.$defs;
200
-
201
- return {
202
- ...globalData,
203
- ...data,
204
- };
188
+ const defaultFile = helpers.getFullPathFromShortPath(
189
+ `${global.config.files.mocks.name}.${global.config.files.mocks.extension[0]}`,
190
+ );
191
+ const jsFile = helpers.getFullPathFromShortPath(
192
+ `${global.config.files.mocks.name}.${global.config.files.mocks.extension[1]}`,
193
+ );
194
+ const globalData = {
195
+ ...(global.state.fileContents[defaultFile] ||
196
+ global.state.fileContents[jsFile]),
197
+ };
198
+
199
+ delete globalData.$defs;
200
+
201
+ return {
202
+ ...globalData,
203
+ ...data,
204
+ };
205
205
  }
@@ -12,47 +12,37 @@
12
12
  * @returns {{ cssFiles: string[], jsFilesHead: object[], jsFilesBody: object[] }}
13
13
  */
14
14
  export default function resolveAssets(componentAssets) {
15
- const { shared, isolateComponents, css, js } = global.config.assets;
15
+ const { shared, isolateComponents, css, js } = global.config.assets;
16
16
 
17
- if (componentAssets) {
18
- const mergedCss = [
19
- ...shared.css,
20
- ...(componentAssets.css || []),
21
- ];
22
- const mergedJs = [
23
- ...shared.js,
24
- ...(componentAssets.js || []),
25
- ];
17
+ if (componentAssets) {
18
+ const mergedCss = [...shared.css, ...(componentAssets.css || [])];
19
+ const mergedJs = [...shared.js, ...(componentAssets.js || [])];
26
20
 
27
- return {
28
- cssFiles: mergedCss,
29
- jsFilesHead: mergedJs.filter(
30
- (entry) => entry.position === "head" || !entry.position,
31
- ),
32
- jsFilesBody: mergedJs.filter(
33
- (entry) => entry.position === "body",
34
- ),
35
- };
36
- }
21
+ return {
22
+ cssFiles: mergedCss,
23
+ jsFilesHead: mergedJs.filter(
24
+ (entry) => entry.position === "head" || !entry.position,
25
+ ),
26
+ jsFilesBody: mergedJs.filter((entry) => entry.position === "body"),
27
+ };
28
+ }
37
29
 
38
- if (isolateComponents) {
39
- return {
40
- cssFiles: [...shared.css],
41
- jsFilesHead: shared.js.filter(
42
- (entry) => entry.position === "head" || !entry.position,
43
- ),
44
- jsFilesBody: shared.js.filter(
45
- (entry) => entry.position === "body",
46
- ),
47
- };
48
- }
30
+ if (isolateComponents) {
31
+ return {
32
+ cssFiles: [...shared.css],
33
+ jsFilesHead: shared.js.filter(
34
+ (entry) => entry.position === "head" || !entry.position,
35
+ ),
36
+ jsFilesBody: shared.js.filter((entry) => entry.position === "body"),
37
+ };
38
+ }
49
39
 
50
- // Legacy fallback: return all global assets
51
- return {
52
- cssFiles: css,
53
- jsFilesHead: js.filter(
54
- (entry) => entry.position === "head" || !entry.position,
55
- ),
56
- jsFilesBody: js.filter((entry) => entry.position === "body"),
57
- };
40
+ // Legacy fallback: return all global assets
41
+ return {
42
+ cssFiles: css,
43
+ jsFilesHead: js.filter(
44
+ (entry) => entry.position === "head" || !entry.position,
45
+ ),
46
+ jsFilesBody: js.filter((entry) => entry.position === "body"),
47
+ };
58
48
  }
@@ -12,40 +12,40 @@ import path from "path";
12
12
  * @returns {Promise<object>} the extended data object
13
13
  */
14
14
  export const extendTemplateData = async (config, data, component) => {
15
- for (const extension of config.extensions) {
16
- if (extension) {
17
- const ext = Array.isArray(extension) ? extension[0] : extension;
15
+ for (const extension of config.extensions) {
16
+ if (extension) {
17
+ const ext = Array.isArray(extension) ? extension[0] : extension;
18
18
 
19
- if (ext.extendTemplateData) {
20
- data = await ext.extendTemplateData(
21
- path.join(config.components.folder, component.paths.tpl.short),
22
- {},
23
- data,
24
- );
25
- }
26
- }
27
- }
19
+ if (ext.extendTemplateData) {
20
+ data = await ext.extendTemplateData(
21
+ path.join(config.components.folder, component.paths.tpl.short),
22
+ {},
23
+ data,
24
+ );
25
+ }
26
+ }
27
+ }
28
28
 
29
- return data;
29
+ return data;
30
30
  };
31
31
 
32
32
  export const getUserUiConfig = (cookies = {}) => {
33
- const projectName = global.config.projectName.replaceAll(" ", "-");
34
- const mode = cookies[`miyagi_${projectName}_mode`];
35
- const theme = cookies[`miyagi_${projectName}_theme`];
36
- const componentTextDirection =
37
- cookies[`miyagi_${projectName}_text_direction`];
33
+ const projectName = global.config.projectName.replaceAll(" ", "-");
34
+ const mode = cookies[`miyagi_${projectName}_mode`];
35
+ const theme = cookies[`miyagi_${projectName}_theme`];
36
+ const componentTextDirection =
37
+ cookies[`miyagi_${projectName}_text_direction`];
38
38
 
39
- return {
40
- mode: global.config.isBuild ? "presentation" : mode || "dev",
41
- theme: theme || global.config.ui.mode,
42
- componentTextDirection:
43
- componentTextDirection || global.config.components.textDirection,
44
- };
39
+ return {
40
+ mode: global.config.isBuild ? "presentation" : mode || "dev",
41
+ theme: theme || global.config.ui.mode,
42
+ componentTextDirection:
43
+ componentTextDirection || global.config.components.textDirection,
44
+ };
45
45
  };
46
46
 
47
47
  export const getThemeMode = (cookies = {}) => {
48
- return cookies[
49
- `miyagi_${global.config.projectName.replaceAll(" ", "-")}_theme`
50
- ];
48
+ return cookies[
49
+ `miyagi_${global.config.projectName.replaceAll(" ", "-")}_theme`
50
+ ];
51
51
  };
@@ -17,22 +17,22 @@ import iframeDesignTokens from "./views/iframe/design-tokens/index.js";
17
17
  import renderMainDesignTokens from "./views/main/design-tokens.js";
18
18
 
19
19
  export default {
20
- renderMainIndex,
21
- renderMainComponent,
22
- renderMainComponentDocs,
23
- renderMainDocs,
24
- renderIframeVariation,
25
- renderIframeVariationStandalone,
26
- renderIframeComponent,
27
- renderIframeComponentDocs,
28
- renderIframeDocs,
29
- renderIframeIndex,
30
- renderMainDesignTokens,
31
- iframe: {
32
- designTokens: {
33
- colors: iframeDesignTokens.colors,
34
- sizes: iframeDesignTokens.sizes,
35
- typography: iframeDesignTokens.typography,
36
- },
37
- },
20
+ renderMainIndex,
21
+ renderMainComponent,
22
+ renderMainComponentDocs,
23
+ renderMainDocs,
24
+ renderIframeVariation,
25
+ renderIframeVariationStandalone,
26
+ renderIframeComponent,
27
+ renderIframeComponentDocs,
28
+ renderIframeDocs,
29
+ renderIframeIndex,
30
+ renderMainDesignTokens,
31
+ iframe: {
32
+ designTokens: {
33
+ colors: iframeDesignTokens.colors,
34
+ sizes: iframeDesignTokens.sizes,
35
+ typography: iframeDesignTokens.typography,
36
+ },
37
+ },
38
38
  };
@@ -10,48 +10,48 @@ import { getUserUiConfig, getThemeMode } from "../../helpers.js";
10
10
  * @param {object} [object.cookies]
11
11
  */
12
12
  export default async function renderIframeComponentDocs({
13
- res,
14
- component,
15
- cb,
16
- cookies,
13
+ res,
14
+ component,
15
+ cb,
16
+ cookies,
17
17
  }) {
18
- const componentDocumentation =
19
- global.state.fileContents[component.paths.docs.full];
20
- const componentName = getHeadlineFromFileName(
21
- path.basename(
22
- component.paths.docs.full,
23
- path.extname(component.paths.docs.full),
24
- ),
25
- );
26
- const themeMode = getThemeMode(cookies);
18
+ const componentDocumentation =
19
+ global.state.fileContents[component.paths.docs.full];
20
+ const componentName = getHeadlineFromFileName(
21
+ path.basename(
22
+ component.paths.docs.full,
23
+ path.extname(component.paths.docs.full),
24
+ ),
25
+ );
26
+ const themeMode = getThemeMode(cookies);
27
27
 
28
- await res.render(
29
- "iframe_component.twig.miyagi",
30
- {
31
- lang: global.config.ui.lang,
32
- miyagiDev: !!process.env.MIYAGI_DEVELOPMENT,
33
- prod: process.env.NODE_ENV === "production",
34
- projectName: config.projectName,
35
- userProjectName: global.config.projectName,
36
- isBuild: global.config.isBuild,
37
- userUiConfig: getUserUiConfig(cookies),
38
- theme: themeMode
39
- ? Object.assign(global.config.ui.theme, { mode: themeMode })
40
- : global.config.ui.theme,
41
- documentation: componentDocumentation,
42
- name: componentDocumentation?.includes("<h1") ? null : componentName,
43
- uiTextDirection: global.config.ui.textDirection,
44
- },
45
- (html) => {
46
- if (res.send) {
47
- res.send(html);
48
- }
28
+ await res.render(
29
+ "iframe_component.twig.miyagi",
30
+ {
31
+ lang: global.config.ui.lang,
32
+ miyagiDev: !!process.env.MIYAGI_DEVELOPMENT,
33
+ prod: process.env.NODE_ENV === "production",
34
+ projectName: config.projectName,
35
+ userProjectName: global.config.projectName,
36
+ isBuild: global.config.isBuild,
37
+ userUiConfig: getUserUiConfig(cookies),
38
+ theme: themeMode
39
+ ? Object.assign(global.config.ui.theme, { mode: themeMode })
40
+ : global.config.ui.theme,
41
+ documentation: componentDocumentation,
42
+ name: componentDocumentation?.includes("<h1") ? null : componentName,
43
+ uiTextDirection: global.config.ui.textDirection,
44
+ },
45
+ (html) => {
46
+ if (res.send) {
47
+ res.send(html);
48
+ }
49
49
 
50
- if (cb) {
51
- cb(null, html);
52
- }
53
- },
54
- );
50
+ if (cb) {
51
+ cb(null, html);
52
+ }
53
+ },
54
+ );
55
55
  }
56
56
 
57
57
  /**
@@ -59,19 +59,19 @@ export default async function renderIframeComponentDocs({
59
59
  * @returns {string}
60
60
  */
61
61
  function getHeadlineFromFileName(file) {
62
- if (typeof file !== "string") return "";
62
+ if (typeof file !== "string") return "";
63
63
 
64
- let fileName = file;
64
+ let fileName = file;
65
65
 
66
- if (fileName.startsWith("/")) {
67
- fileName = fileName.slice(1);
68
- }
66
+ if (fileName.startsWith("/")) {
67
+ fileName = fileName.slice(1);
68
+ }
69
69
 
70
- if (file.endsWith("README.md") || file.endsWith("index.md")) {
71
- fileName = path.dirname(fileName);
72
- } else {
73
- fileName = path.basename(fileName, ".md");
74
- }
70
+ if (file.endsWith("README.md") || file.endsWith("index.md")) {
71
+ fileName = path.dirname(fileName);
72
+ } else {
73
+ fileName = path.basename(fileName, ".md");
74
+ }
75
75
 
76
- return fileName.replaceAll("-", " ");
76
+ return fileName.replaceAll("-", " ");
77
77
  }