@mui/internal-docs-infra 0.3.1-canary.3 → 0.3.1-canary.4

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/esm/CodeControllerContext/CodeControllerContext.js +2 -2
  2. package/esm/CodeExternalsContext/CodeExternalsContext.js +1 -1
  3. package/esm/CodeHighlighter/CodeHighlighter.js +247 -329
  4. package/esm/CodeHighlighter/CodeHighlighterClient.js +447 -653
  5. package/esm/CodeHighlighter/CodeHighlighterContext.js +2 -2
  6. package/esm/CodeHighlighter/CodeHighlighterFallbackContext.js +2 -2
  7. package/esm/CodeHighlighter/codeToFallbackProps.js +21 -37
  8. package/esm/CodeHighlighter/errors.js +248 -400
  9. package/esm/CodeHighlighter/parseControlledCode.js +12 -20
  10. package/esm/CodeProvider/CodeContext.js +3 -3
  11. package/esm/CodeProvider/CodeProvider.js +31 -40
  12. package/esm/abstractCreateDemo/abstractCreateDemo.js +13 -17
  13. package/esm/abstractCreateDemoClient/abstractCreateDemoClient.js +12 -12
  14. package/esm/cli/index.js +1 -1
  15. package/esm/cli/runValidate.js +160 -264
  16. package/esm/createDemoData/createDemoData.js +11 -12
  17. package/esm/createSitemap/createSitemap.js +2 -2
  18. package/esm/pipeline/getFileConventions/fileConventions.js +1 -1
  19. package/esm/pipeline/getFileConventions/getFileConventions.js +2 -15
  20. package/esm/pipeline/hastUtils/hastUtils.js +16 -17
  21. package/esm/pipeline/loadCodeVariant/addCodeVariantPaths.js +24 -24
  22. package/esm/pipeline/loadCodeVariant/applyCodeTransform.js +12 -22
  23. package/esm/pipeline/loadCodeVariant/calculateMainFilePath.js +30 -37
  24. package/esm/pipeline/loadCodeVariant/computeHastDeltas.js +107 -185
  25. package/esm/pipeline/loadCodeVariant/diffHast.js +18 -53
  26. package/esm/pipeline/loadCodeVariant/examineCodeVariant.js +24 -27
  27. package/esm/pipeline/loadCodeVariant/flattenCodeVariant.js +9 -10
  28. package/esm/pipeline/loadCodeVariant/hasAllCodeVariants.js +5 -5
  29. package/esm/pipeline/loadCodeVariant/loadCodeFallback.js +516 -731
  30. package/esm/pipeline/loadCodeVariant/loadCodeVariant.js +679 -1079
  31. package/esm/pipeline/loadCodeVariant/maybeCodeInitialData.js +14 -20
  32. package/esm/pipeline/loadCodeVariant/mergeCodeMetadata.js +53 -63
  33. package/esm/pipeline/loadCodeVariant/parseCode.js +40 -48
  34. package/esm/pipeline/loadCodeVariant/pathUtils.js +43 -64
  35. package/esm/pipeline/loadCodeVariant/transformSource.js +55 -125
  36. package/esm/pipeline/loadPrecomputedCodeHighlighter/loadPrecomputedCodeHighlighter.js +160 -221
  37. package/esm/pipeline/loadPrecomputedCodeHighlighter/parseCreateFactoryCall.js +377 -479
  38. package/esm/pipeline/loadPrecomputedCodeHighlighter/parseFunctionArguments.js +171 -173
  39. package/esm/pipeline/loadPrecomputedCodeHighlighter/performanceLogger.js +14 -30
  40. package/esm/pipeline/loadPrecomputedCodeHighlighter/replacePrecomputeValue.js +19 -21
  41. package/esm/pipeline/loadPrecomputedCodeHighlighter/serializeFunctionArguments.js +37 -71
  42. package/esm/pipeline/loadPrecomputedCodeHighlighterClient/filterRuntimeExternals.js +3 -9
  43. package/esm/pipeline/loadPrecomputedCodeHighlighterClient/generateImportStatements.js +54 -80
  44. package/esm/pipeline/loadPrecomputedCodeHighlighterClient/generateResolvedExternals.js +71 -98
  45. package/esm/pipeline/loadPrecomputedCodeHighlighterClient/injectImportsIntoSource.js +5 -5
  46. package/esm/pipeline/loadPrecomputedCodeHighlighterClient/loadPrecomputedCodeHighlighterClient.js +161 -211
  47. package/esm/pipeline/loadPrecomputedSitemap/loadPrecomputedSitemap.js +159 -207
  48. package/esm/pipeline/loadServerCodeMeta/loadServerCodeMeta.js +42 -64
  49. package/esm/pipeline/loadServerCodeMeta/resolveModulePathWithFs.js +20 -96
  50. package/esm/pipeline/loadServerPageIndex/loadServerPageIndex.js +66 -85
  51. package/esm/pipeline/loadServerSitemap/loadServerSitemap.js +71 -118
  52. package/esm/pipeline/loadServerSource/loadServerSource.js +121 -148
  53. package/esm/pipeline/loaderUtils/externalsToPackages.js +7 -7
  54. package/esm/pipeline/loaderUtils/extractNameAndSlugFromUrl.js +8 -12
  55. package/esm/pipeline/loaderUtils/fileUrlToPortablePath.js +5 -5
  56. package/esm/pipeline/loaderUtils/getFileNameFromUrl.js +19 -29
  57. package/esm/pipeline/loaderUtils/getLanguageFromExtension.js +3 -4
  58. package/esm/pipeline/loaderUtils/mergeExternals.js +15 -35
  59. package/esm/pipeline/loaderUtils/parseImportsAndComments.js +413 -433
  60. package/esm/pipeline/loaderUtils/processRelativeImports.js +153 -239
  61. package/esm/pipeline/loaderUtils/resolveModulePath.js +544 -1303
  62. package/esm/pipeline/loaderUtils/rewriteImports.js +73 -111
  63. package/esm/pipeline/parseSource/addLineGutters.js +33 -45
  64. package/esm/pipeline/parseSource/grammars.js +3 -3
  65. package/esm/pipeline/parseSource/parseSource.js +13 -31
  66. package/esm/pipeline/syncPageIndex/createMarkdownNodes.js +32 -55
  67. package/esm/pipeline/syncPageIndex/mergeMetadataMarkdown.js +107 -160
  68. package/esm/pipeline/syncPageIndex/metadataToMarkdown.js +846 -1033
  69. package/esm/pipeline/syncPageIndex/syncPageIndex.js +291 -438
  70. package/esm/pipeline/transformHtmlCodePrecomputed/transformHtmlCodePrecomputed.js +213 -311
  71. package/esm/pipeline/transformMarkdownBlockquoteCallouts/transformMarkdownBlockquoteCallouts.js +10 -10
  72. package/esm/pipeline/transformMarkdownCode/transformMarkdownCode.js +133 -193
  73. package/esm/pipeline/transformMarkdownDemoLinks/transformMarkdownDemoLinks.js +25 -27
  74. package/esm/pipeline/transformMarkdownMetadata/transformMarkdownMetadata.js +572 -717
  75. package/esm/pipeline/transformMarkdownRelativePaths/transformMarkdownRelativePaths.js +8 -8
  76. package/esm/pipeline/transformTypescriptToJavascript/removeTypes.js +84 -113
  77. package/esm/pipeline/transformTypescriptToJavascript/transformTypescriptToJavascript.js +10 -26
  78. package/esm/useCode/Pre.js +58 -62
  79. package/esm/useCode/useCode.js +59 -61
  80. package/esm/useCode/useCodeUtils.js +54 -63
  81. package/esm/useCode/useCopyFunctionality.js +10 -9
  82. package/esm/useCode/useFileNavigation.js +150 -212
  83. package/esm/useCode/useSourceEditing.js +17 -14
  84. package/esm/useCode/useTransformManagement.js +23 -26
  85. package/esm/useCode/useUIState.js +12 -20
  86. package/esm/useCode/useVariantSelection.js +62 -79
  87. package/esm/useCopier/index.js +29 -56
  88. package/esm/useDemo/createCodeSandbox.js +12 -15
  89. package/esm/useDemo/createStackBlitz.js +14 -20
  90. package/esm/useDemo/exportVariant.js +200 -180
  91. package/esm/useDemo/exportVariantAsCra.js +22 -25
  92. package/esm/useDemo/useDemo.js +80 -84
  93. package/esm/useErrors/ErrorsContext.js +1 -1
  94. package/esm/useErrors/useErrors.js +3 -3
  95. package/esm/useLocalStorageState/useLocalStorageState.js +23 -39
  96. package/esm/usePreference/PreferencesProvider.js +1 -1
  97. package/esm/usePreference/usePreference.js +9 -11
  98. package/esm/useSearch/useSearch.js +290 -387
  99. package/esm/useUrlHashState/useUrlHashState.js +11 -14
  100. package/esm/withDocsInfra/withDeploymentConfig.js +26 -21
  101. package/esm/withDocsInfra/withDocsInfra.js +99 -101
  102. package/package.json +7 -4
@@ -1,9 +1,3 @@
1
- import _regenerator from "@babel/runtime/helpers/esm/regenerator";
2
- import _extends from "@babel/runtime/helpers/esm/extends";
3
- import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
4
- import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
5
- import _typeof from "@babel/runtime/helpers/esm/typeof";
6
- import _createForOfIteratorHelper from "@babel/runtime/helpers/esm/createForOfIteratorHelper";
7
1
  import { visit } from 'unist-util-visit';
8
2
  import { dirname, relative } from 'node:path';
9
3
  import { syncPageIndex } from "../syncPageIndex/index.js";
@@ -12,28 +6,19 @@ import { markdownToMetadata } from "../syncPageIndex/metadataToMarkdown.js";
12
6
  * Extracts text content from paragraph nodes
13
7
  */
14
8
  function extractParagraphText(node) {
15
- var text = '';
16
- var _iterator = _createForOfIteratorHelper(node.children),
17
- _step;
18
- try {
19
- for (_iterator.s(); !(_step = _iterator.n()).done;) {
20
- var child = _step.value;
21
- if (child.type === 'text') {
22
- text += child.value;
23
- } else if (child.type === 'inlineCode') {
24
- // Preserve backticks for inline code
25
- text += "`".concat(child.value, "`");
26
- } else if ('children' in child) {
27
- // Handle nested elements like strong, emphasis, etc.
28
- text += extractTextFromChildren(child.children);
29
- }
9
+ let text = '';
10
+ for (const child of node.children) {
11
+ if (child.type === 'text') {
12
+ text += child.value;
13
+ } else if (child.type === 'inlineCode') {
14
+ // Preserve backticks for inline code
15
+ text += `\`${child.value}\``;
16
+ } else if ('children' in child) {
17
+ // Handle nested elements like strong, emphasis, etc.
18
+ text += extractTextFromChildren(child.children);
30
19
  }
31
- // Replace newlines with spaces and normalize whitespace, preserving non-breaking spaces
32
- } catch (err) {
33
- _iterator.e(err);
34
- } finally {
35
- _iterator.f();
36
20
  }
21
+ // Replace newlines with spaces and normalize whitespace, preserving non-breaking spaces
37
22
  return text.replace(/[ \t\n\r]+/g, ' ').trim();
38
23
  }
39
24
 
@@ -41,26 +26,17 @@ function extractParagraphText(node) {
41
26
  * Recursively extracts text from children nodes
42
27
  */
43
28
  function extractTextFromChildren(children) {
44
- var text = '';
45
- var _iterator2 = _createForOfIteratorHelper(children),
46
- _step2;
47
- try {
48
- for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
49
- var child = _step2.value;
50
- if (child.type === 'text') {
51
- text += child.value;
52
- } else if (child.type === 'inlineCode') {
53
- // Preserve backticks for inline code
54
- text += "`".concat(child.value, "`");
55
- } else if ('children' in child) {
56
- // Recursively extract from nested elements (strong, emphasis, etc.)
57
- text += extractTextFromChildren(child.children);
58
- }
29
+ let text = '';
30
+ for (const child of children) {
31
+ if (child.type === 'text') {
32
+ text += child.value;
33
+ } else if (child.type === 'inlineCode') {
34
+ // Preserve backticks for inline code
35
+ text += `\`${child.value}\``;
36
+ } else if ('children' in child) {
37
+ // Recursively extract from nested elements (strong, emphasis, etc.)
38
+ text += extractTextFromChildren(child.children);
59
39
  }
60
- } catch (err) {
61
- _iterator2.e(err);
62
- } finally {
63
- _iterator2.f();
64
40
  }
65
41
  return text;
66
42
  }
@@ -69,26 +45,17 @@ function extractTextFromChildren(children) {
69
45
  * Extracts plain text from children nodes (without formatting markers)
70
46
  */
71
47
  function extractPlainTextFromChildren(children) {
72
- var text = '';
73
- var _iterator3 = _createForOfIteratorHelper(children),
74
- _step3;
75
- try {
76
- for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
77
- var child = _step3.value;
78
- if (child.type === 'text') {
79
- text += child.value;
80
- } else if (child.type === 'inlineCode') {
81
- // Include inline code without backticks
82
- text += child.value;
83
- } else if ('children' in child) {
84
- // Recursively extract from nested elements
85
- text += extractPlainTextFromChildren(child.children);
86
- }
48
+ let text = '';
49
+ for (const child of children) {
50
+ if (child.type === 'text') {
51
+ text += child.value;
52
+ } else if (child.type === 'inlineCode') {
53
+ // Include inline code without backticks
54
+ text += child.value;
55
+ } else if ('children' in child) {
56
+ // Recursively extract from nested elements
57
+ text += extractPlainTextFromChildren(child.children);
87
58
  }
88
- } catch (err) {
89
- _iterator3.e(err);
90
- } finally {
91
- _iterator3.f();
92
59
  }
93
60
  return text;
94
61
  }
@@ -107,51 +74,42 @@ function slugify(text) {
107
74
  */
108
75
  function buildHeadingHierarchy(headings) {
109
76
  // Skip the first heading (H1 - page title)
110
- var contentHeadings = headings.slice(1);
77
+ const contentHeadings = headings.slice(1);
111
78
  if (contentHeadings.length === 0) {
112
79
  return {};
113
80
  }
114
- var root = {};
115
- var stack = [{
81
+ const root = {};
82
+ const stack = [{
116
83
  depth: 0,
117
84
  node: root
118
85
  }];
119
- var _iterator4 = _createForOfIteratorHelper(contentHeadings),
120
- _step4;
121
- try {
122
- for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
123
- var heading = _step4.value;
124
- // Pop from stack until we find the parent level
125
- while (stack.length > 0 && stack[stack.length - 1].depth >= heading.depth) {
126
- stack.pop();
127
- }
86
+ for (const heading of contentHeadings) {
87
+ // Pop from stack until we find the parent level
88
+ while (stack.length > 0 && stack[stack.length - 1].depth >= heading.depth) {
89
+ stack.pop();
90
+ }
128
91
 
129
- // Get the current parent node
130
- var parent = stack[stack.length - 1].node;
92
+ // Get the current parent node
93
+ const parent = stack[stack.length - 1].node;
131
94
 
132
- // Create slug from heading text using the provided slugify function
133
- var slug = slugify(heading.text);
95
+ // Create slug from heading text using the provided slugify function
96
+ const slug = slugify(heading.text);
134
97
 
135
- // Create new node for this heading
136
- var newNode = {
137
- title: heading.text,
138
- // Plain text for display
139
- titleMarkdown: heading.children,
140
- // AST nodes preserving formatting
141
- children: {}
142
- };
143
- parent[slug] = newNode;
98
+ // Create new node for this heading
99
+ const newNode = {
100
+ title: heading.text,
101
+ // Plain text for display
102
+ titleMarkdown: heading.children,
103
+ // AST nodes preserving formatting
104
+ children: {}
105
+ };
106
+ parent[slug] = newNode;
144
107
 
145
- // Push this heading onto the stack
146
- stack.push({
147
- depth: heading.depth,
148
- node: newNode.children
149
- });
150
- }
151
- } catch (err) {
152
- _iterator4.e(err);
153
- } finally {
154
- _iterator4.f();
108
+ // Push this heading onto the stack
109
+ stack.push({
110
+ depth: heading.depth,
111
+ node: newNode.children
112
+ });
155
113
  }
156
114
  return root;
157
115
  }
@@ -161,37 +119,17 @@ function buildHeadingHierarchy(headings) {
161
119
  */
162
120
  function parseMetadataFromEstree(estree) {
163
121
  try {
164
- var body = (estree == null ? void 0 : estree.body) || [];
165
- var _iterator5 = _createForOfIteratorHelper(body),
166
- _step5;
167
- try {
168
- for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
169
- var _node$declaration;
170
- var node = _step5.value;
171
- if (node.type === 'ExportNamedDeclaration' && ((_node$declaration = node.declaration) == null ? void 0 : _node$declaration.type) === 'VariableDeclaration') {
172
- var declarations = node.declaration.declarations || [];
173
- var _iterator6 = _createForOfIteratorHelper(declarations),
174
- _step6;
175
- try {
176
- for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) {
177
- var _decl$id, _decl$init;
178
- var decl = _step6.value;
179
- if (((_decl$id = decl.id) == null ? void 0 : _decl$id.type) === 'Identifier' && decl.id.name === 'metadata' && ((_decl$init = decl.init) == null ? void 0 : _decl$init.type) === 'ObjectExpression') {
180
- // Convert ESTree ObjectExpression to plain object
181
- return convertEstreeObjectToPlain(decl.init);
182
- }
183
- }
184
- } catch (err) {
185
- _iterator6.e(err);
186
- } finally {
187
- _iterator6.f();
122
+ const body = estree?.body || [];
123
+ for (const node of body) {
124
+ if (node.type === 'ExportNamedDeclaration' && node.declaration?.type === 'VariableDeclaration') {
125
+ const declarations = node.declaration.declarations || [];
126
+ for (const decl of declarations) {
127
+ if (decl.id?.type === 'Identifier' && decl.id.name === 'metadata' && decl.init?.type === 'ObjectExpression') {
128
+ // Convert ESTree ObjectExpression to plain object
129
+ return convertEstreeObjectToPlain(decl.init);
188
130
  }
189
131
  }
190
132
  }
191
- } catch (err) {
192
- _iterator5.e(err);
193
- } finally {
194
- _iterator5.f();
195
133
  }
196
134
  } catch (error) {
197
135
  console.error('Error parsing metadata from estree:', error);
@@ -203,43 +141,32 @@ function parseMetadataFromEstree(estree) {
203
141
  * Converts an ESTree ObjectExpression to a plain JavaScript object
204
142
  */
205
143
  function convertEstreeObjectToPlain(node) {
206
- if (_typeof(node) === 'object' && node !== null && 'type' in node && node.type === 'ObjectExpression') {
207
- var obj = {};
144
+ if (typeof node === 'object' && node !== null && 'type' in node && node.type === 'ObjectExpression') {
145
+ const obj = {};
208
146
  if ('properties' in node && Array.isArray(node.properties)) {
209
- var _iterator7 = _createForOfIteratorHelper(node.properties),
210
- _step7;
211
- try {
212
- for (_iterator7.s(); !(_step7 = _iterator7.n()).done;) {
213
- var prop = _step7.value;
214
- if (_typeof(prop) === 'object' && prop !== null && 'type' in prop && prop.type === 'Property' && 'key' in prop && prop.key) {
215
- var key = '';
216
- if ('name' in prop.key && typeof prop.key.name === 'string') {
217
- key = prop.key.name;
218
- } else if ('value' in prop.key) {
219
- key = String(prop.key.value);
220
- }
221
- if (key && 'value' in prop) {
222
- obj[key] = convertEstreeObjectToPlain(prop.value);
223
- }
147
+ for (const prop of node.properties) {
148
+ if (typeof prop === 'object' && prop !== null && 'type' in prop && prop.type === 'Property' && 'key' in prop && prop.key) {
149
+ let key = '';
150
+ if ('name' in prop.key && typeof prop.key.name === 'string') {
151
+ key = prop.key.name;
152
+ } else if ('value' in prop.key) {
153
+ key = String(prop.key.value);
154
+ }
155
+ if (key && 'value' in prop) {
156
+ obj[key] = convertEstreeObjectToPlain(prop.value);
224
157
  }
225
158
  }
226
- } catch (err) {
227
- _iterator7.e(err);
228
- } finally {
229
- _iterator7.f();
230
159
  }
231
160
  }
232
161
  return obj;
233
162
  }
234
- if (_typeof(node) === 'object' && node !== null && 'type' in node && node.type === 'ArrayExpression' && 'elements' in node && Array.isArray(node.elements)) {
235
- return node.elements.map(function (el) {
236
- return convertEstreeObjectToPlain(el);
237
- });
163
+ if (typeof node === 'object' && node !== null && 'type' in node && node.type === 'ArrayExpression' && 'elements' in node && Array.isArray(node.elements)) {
164
+ return node.elements.map(el => convertEstreeObjectToPlain(el));
238
165
  }
239
- if (_typeof(node) === 'object' && node !== null && 'type' in node && node.type === 'Literal' && 'value' in node) {
166
+ if (typeof node === 'object' && node !== null && 'type' in node && node.type === 'Literal' && 'value' in node) {
240
167
  return node.value;
241
168
  }
242
- if (_typeof(node) === 'object' && node !== null && 'type' in node && node.type === 'Identifier' && 'name' in node) {
169
+ if (typeof node === 'object' && node !== null && 'type' in node && node.type === 'Identifier' && 'name' in node) {
243
170
  return node.name;
244
171
  }
245
172
  return undefined;
@@ -255,9 +182,8 @@ function isRouteGroup(dirName) {
255
182
  /**
256
183
  * Gets the parent directory, skipping over Next.js route groups if requested
257
184
  */
258
- function getParentDir(path) {
259
- var skipRouteGroups = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
260
- var parent = dirname(path);
185
+ function getParentDir(path, skipRouteGroups = false) {
186
+ let parent = dirname(path);
261
187
  if (skipRouteGroups) {
262
188
  while (parent !== dirname(parent) && isRouteGroup(parent.split('/').pop() || '')) {
263
189
  parent = dirname(parent);
@@ -268,19 +194,17 @@ function getParentDir(path) {
268
194
  /**
269
195
  * Converts extracted metadata to PageMetadata format for index updates
270
196
  */
271
- function toPageMetadata(metadata, filePath) {
272
- var _options$visibleDescr, _options$visibleDescr2;
273
- var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
197
+ function toPageMetadata(metadata, filePath, options = {}) {
274
198
  // Extract the slug from the file path (directory name containing the page)
275
- var parts = filePath.split('/');
276
- var pageFileName = parts[parts.length - 1]; // e.g., 'page.mdx'
199
+ const parts = filePath.split('/');
200
+ const pageFileName = parts[parts.length - 1]; // e.g., 'page.mdx'
277
201
 
278
202
  // Get the directory containing the page file
279
- var pageDir = dirname(filePath);
203
+ const pageDir = dirname(filePath);
280
204
 
281
205
  // Find the directory name by looking backwards for the first non-route-group directory
282
- var dirName = '';
283
- for (var i = parts.length - 2; i >= 0; i -= 1) {
206
+ let dirName = '';
207
+ for (let i = parts.length - 2; i >= 0; i -= 1) {
284
208
  if (!isRouteGroup(parts[i])) {
285
209
  dirName = parts[i];
286
210
  break;
@@ -289,20 +213,20 @@ function toPageMetadata(metadata, filePath) {
289
213
 
290
214
  // Generate slug from title if available, otherwise from directory name
291
215
  // This ensures consistency with section slug generation (kebab-case for multi-word, lowercase for camelCase)
292
- var slug = metadata.title ? metadata.title.toLowerCase().replace(/[^a-z0-9]+/g, '-').replace(/^-|-$/g, '') : dirName;
216
+ const slug = metadata.title ? metadata.title.toLowerCase().replace(/[^a-z0-9]+/g, '-').replace(/^-|-$/g, '') : dirName;
293
217
 
294
218
  // Calculate parent directory (skipping route groups, matching syncPageIndex behavior)
295
- var parentDir = getParentDir(pageDir, true);
219
+ const parentDir = getParentDir(pageDir, true);
296
220
 
297
221
  // Create relative path from parent to page
298
- var relativePath = relative(parentDir, pageDir);
299
- var path = "./".concat(relativePath, "/").concat(pageFileName);
222
+ const relativePath = relative(parentDir, pageDir);
223
+ const path = `./${relativePath}/${pageFileName}`;
300
224
  return {
301
- slug: slug,
302
- path: path,
225
+ slug,
226
+ path,
303
227
  title: metadata.title,
304
- description: (_options$visibleDescr = options.visibleDescription) != null ? _options$visibleDescr : metadata.description,
305
- descriptionMarkdown: (_options$visibleDescr2 = options.visibleDescriptionMarkdown) != null ? _options$visibleDescr2 : metadata.descriptionMarkdown,
228
+ description: options.visibleDescription ?? metadata.description,
229
+ descriptionMarkdown: options.visibleDescriptionMarkdown ?? metadata.descriptionMarkdown,
306
230
  keywords: metadata.keywords,
307
231
  sections: metadata.sections,
308
232
  embeddings: metadata.embeddings,
@@ -323,30 +247,21 @@ function valueToEstree(value) {
323
247
  if (typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean') {
324
248
  return {
325
249
  type: 'Literal',
326
- value: value
250
+ value
327
251
  };
328
252
  }
329
253
  if (Array.isArray(value)) {
330
254
  return {
331
255
  type: 'ArrayExpression',
332
- elements: value.map(function (item) {
333
- return valueToEstree(item);
334
- })
256
+ elements: value.map(item => valueToEstree(item))
335
257
  };
336
258
  }
337
- if (_typeof(value) === 'object') {
259
+ if (typeof value === 'object') {
338
260
  return {
339
261
  type: 'ObjectExpression',
340
- properties: Object.entries(value).filter(function (_ref) {
341
- var _ref2 = _slicedToArray(_ref, 2),
342
- val = _ref2[1];
343
- return val !== undefined;
344
- }).map(function (_ref3) {
345
- var _ref4 = _slicedToArray(_ref3, 2),
346
- key = _ref4[0],
347
- val = _ref4[1];
262
+ properties: Object.entries(value).filter(([, val]) => val !== undefined).map(([key, val]) => {
348
263
  // Check if key is a valid JavaScript identifier
349
- var isValidIdentifier = /^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(key);
264
+ const isValidIdentifier = /^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(key);
350
265
  return {
351
266
  type: 'Property',
352
267
  key: isValidIdentifier ? {
@@ -375,71 +290,40 @@ function valueToEstree(value) {
375
290
  * Updates the metadata object in an existing ESTree
376
291
  */
377
292
  function updateMetadataInEstree(estree, metadata) {
378
- var body = (estree == null ? void 0 : estree.body) || [];
379
- var _iterator8 = _createForOfIteratorHelper(body),
380
- _step8;
381
- try {
382
- for (_iterator8.s(); !(_step8 = _iterator8.n()).done;) {
383
- var _node$declaration2;
384
- var node = _step8.value;
385
- if (node.type === 'ExportNamedDeclaration' && ((_node$declaration2 = node.declaration) == null ? void 0 : _node$declaration2.type) === 'VariableDeclaration') {
386
- var declarations = node.declaration.declarations || [];
387
- var _iterator9 = _createForOfIteratorHelper(declarations),
388
- _step9;
389
- try {
390
- for (_iterator9.s(); !(_step9 = _iterator9.n()).done;) {
391
- var _decl$id2, _decl$init2;
392
- var decl = _step9.value;
393
- if (((_decl$id2 = decl.id) == null ? void 0 : _decl$id2.type) === 'Identifier' && decl.id.name === 'metadata' && ((_decl$init2 = decl.init) == null ? void 0 : _decl$init2.type) === 'ObjectExpression') {
394
- // Merge new metadata into existing object
395
- var existingProps = decl.init.properties || [];
396
- var existingKeys = new Set(existingProps.filter(function (prop) {
397
- return prop.type === 'Property';
398
- }).map(function (prop) {
399
- if ('name' in prop.key) {
400
- return prop.key.name;
401
- }
402
- if ('value' in prop.key) {
403
- return String(prop.key.value || '');
404
- }
405
- return '';
406
- }));
407
-
408
- // Add missing properties
409
- var metadataObj = valueToEstree(metadata);
410
- if (_typeof(metadataObj) === 'object' && metadataObj !== null && 'properties' in metadataObj && Array.isArray(metadataObj.properties)) {
411
- var _iterator0 = _createForOfIteratorHelper(metadataObj.properties),
412
- _step0;
413
- try {
414
- for (_iterator0.s(); !(_step0 = _iterator0.n()).done;) {
415
- var prop = _step0.value;
416
- if (_typeof(prop) === 'object' && prop !== null && 'key' in prop && _typeof(prop.key) === 'object' && prop.key !== null && 'name' in prop.key) {
417
- var key = prop.key.name;
418
- if (key && !existingKeys.has(String(key))) {
419
- existingProps.push(prop);
420
- }
421
- }
422
- }
423
- } catch (err) {
424
- _iterator0.e(err);
425
- } finally {
426
- _iterator0.f();
293
+ const body = estree?.body || [];
294
+ for (const node of body) {
295
+ if (node.type === 'ExportNamedDeclaration' && node.declaration?.type === 'VariableDeclaration') {
296
+ const declarations = node.declaration.declarations || [];
297
+ for (const decl of declarations) {
298
+ if (decl.id?.type === 'Identifier' && decl.id.name === 'metadata' && decl.init?.type === 'ObjectExpression') {
299
+ // Merge new metadata into existing object
300
+ const existingProps = decl.init.properties || [];
301
+ const existingKeys = new Set(existingProps.filter(prop => prop.type === 'Property').map(prop => {
302
+ if ('name' in prop.key) {
303
+ return prop.key.name;
304
+ }
305
+ if ('value' in prop.key) {
306
+ return String(prop.key.value || '');
307
+ }
308
+ return '';
309
+ }));
310
+
311
+ // Add missing properties
312
+ const metadataObj = valueToEstree(metadata);
313
+ if (typeof metadataObj === 'object' && metadataObj !== null && 'properties' in metadataObj && Array.isArray(metadataObj.properties)) {
314
+ for (const prop of metadataObj.properties) {
315
+ if (typeof prop === 'object' && prop !== null && 'key' in prop && typeof prop.key === 'object' && prop.key !== null && 'name' in prop.key) {
316
+ const key = prop.key.name;
317
+ if (key && !existingKeys.has(String(key))) {
318
+ existingProps.push(prop);
427
319
  }
428
320
  }
429
- return;
430
321
  }
431
322
  }
432
- } catch (err) {
433
- _iterator9.e(err);
434
- } finally {
435
- _iterator9.f();
323
+ return;
436
324
  }
437
325
  }
438
326
  }
439
- } catch (err) {
440
- _iterator8.e(err);
441
- } finally {
442
- _iterator8.f();
443
327
  }
444
328
  }
445
329
 
@@ -447,7 +331,7 @@ function updateMetadataInEstree(estree, metadata) {
447
331
  * Creates a new metadata export node
448
332
  */
449
333
  function createMetadataExport(metadata) {
450
- var metadataObj = valueToEstree(metadata);
334
+ const metadataObj = valueToEstree(metadata);
451
335
  return {
452
336
  type: 'mdxjsEsm',
453
337
  value: '',
@@ -477,510 +361,481 @@ function createMetadataExport(metadata) {
477
361
  }
478
362
  };
479
363
  }
480
- export var transformMarkdownMetadata = function transformMarkdownMetadata() {
481
- var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
482
- return /*#__PURE__*/function () {
483
- var _ref5 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(tree, file) {
484
- var root, headings, metadata, firstH1, firstParagraphAfterH1, metadataNode, metaDescription, metaKeywords, foundFirstH1, nextNodeAfterH1, firstParagraphMarkdown, fullTextParts, shouldUpdateMetadata, mutableMetadata, hasSections, _esmNode$data, esmNode, exportMetadata, descriptionValue, descriptionMarkdownValue, _exportMetadata, metadataExport, wrapperComponent, extractBaseDir, fileContent, pagesMetadata, prefix, filePath, dirPath, segments, srcIndex, appIndex, sitemapData, shouldExtract, _options$extractToInd, _options$extractToInd2, include, _options$extractToInd3, exclude, baseDir, _filePath, normalizedPath, isIndexFile, matchedIncludePattern, isIncluded, matchedExcludePattern, isExcluded, useVisibleDescription, pageMetadataOptions, pageMetadata, updateOptions, _t;
485
- return _regenerator().w(function (_context) {
486
- while (1) switch (_context.p = _context.n) {
487
- case 0:
488
- root = tree;
489
- headings = [];
490
- metadata = null;
491
- firstH1 = null;
492
- firstParagraphAfterH1 = null;
493
- metadataNode = null; // Track the ESM node containing metadata
494
- metaDescription = null; // Track meta tag description
495
- metaKeywords = null; // Track meta tag keywords
496
- foundFirstH1 = false;
497
- nextNodeAfterH1 = null;
498
- fullTextParts = []; // Collect text parts for fullText - headings and content alternating
499
- // Single pass: extract metadata export, meta tags, headings, first paragraph, and full text
500
- visit(root, function (node, index, parent) {
501
- // Extract metadata export if it exists
502
- if (node.type === 'mdxjsEsm' && 'data' in node && node.data && _typeof(node.data) === 'object' && 'estree' in node.data && node.data.estree) {
503
- var extracted = parseMetadataFromEstree(node.data.estree);
504
- if (extracted) {
505
- metadata = extracted;
506
- metadataNode = node;
507
- }
364
+ export const transformMarkdownMetadata = (options = {}) => {
365
+ return async (tree, file) => {
366
+ const root = tree;
367
+ const headings = [];
368
+ let metadata = null;
369
+ let firstH1 = null;
370
+ let firstParagraphAfterH1 = null;
371
+ let metadataNode = null; // Track the ESM node containing metadata
372
+ let metaDescription = null; // Track meta tag description
373
+ let metaKeywords = null; // Track meta tag keywords
374
+ let foundFirstH1 = false;
375
+ let nextNodeAfterH1 = null;
376
+ let firstParagraphMarkdown;
377
+ const fullTextParts = []; // Collect text parts for fullText - headings and content alternating
378
+
379
+ // Single pass: extract metadata export, meta tags, headings, first paragraph, and full text
380
+ visit(root, (node, index, parent) => {
381
+ // Extract metadata export if it exists
382
+ if (node.type === 'mdxjsEsm' && 'data' in node && node.data && typeof node.data === 'object' && 'estree' in node.data && node.data.estree) {
383
+ const extracted = parseMetadataFromEstree(node.data.estree);
384
+ if (extracted) {
385
+ metadata = extracted;
386
+ metadataNode = node;
387
+ }
388
+ }
389
+
390
+ // Look for meta tags (can appear anywhere in the document)
391
+ if ((node.type === 'mdxJsxFlowElement' || node.type === 'mdxJsxTextElement') && 'name' in node && (node.name === 'meta' || node.name === 'Meta')) {
392
+ // Check attributes to find the meta tag type
393
+ const attributes = 'attributes' in node && Array.isArray(node.attributes) ? node.attributes : [];
394
+ let metaName = null;
395
+ let contentValue = null;
396
+ for (const attr of attributes) {
397
+ if (typeof attr === 'object' && attr !== null && 'type' in attr && attr.type === 'mdxJsxAttribute' && 'name' in attr) {
398
+ if (attr.name === 'name' && 'value' in attr) {
399
+ metaName = typeof attr.value === 'string' ? attr.value : null;
400
+ }
401
+ if (attr.name === 'content' && 'value' in attr) {
402
+ // Extract the content value
403
+ if (typeof attr.value === 'string') {
404
+ contentValue = attr.value;
405
+ } else if (typeof attr.value === 'object' && attr.value !== null && 'type' in attr.value && attr.value.type === 'mdxJsxAttributeValueExpression' && 'value' in attr.value && typeof attr.value.value === 'string') {
406
+ // Handle expression values if needed
407
+ contentValue = attr.value.value;
508
408
  }
409
+ }
410
+ }
411
+ }
509
412
 
510
- // Look for meta tags (can appear anywhere in the document)
511
- if ((node.type === 'mdxJsxFlowElement' || node.type === 'mdxJsxTextElement') && 'name' in node && (node.name === 'meta' || node.name === 'Meta')) {
512
- // Check attributes to find the meta tag type
513
- var attributes = 'attributes' in node && Array.isArray(node.attributes) ? node.attributes : [];
514
- var metaName = null;
515
- var contentValue = null;
516
- var _iterator1 = _createForOfIteratorHelper(attributes),
517
- _step1;
518
- try {
519
- for (_iterator1.s(); !(_step1 = _iterator1.n()).done;) {
520
- var attr = _step1.value;
521
- if (_typeof(attr) === 'object' && attr !== null && 'type' in attr && attr.type === 'mdxJsxAttribute' && 'name' in attr) {
522
- if (attr.name === 'name' && 'value' in attr) {
523
- metaName = typeof attr.value === 'string' ? attr.value : null;
524
- }
525
- if (attr.name === 'content' && 'value' in attr) {
526
- // Extract the content value
527
- if (typeof attr.value === 'string') {
528
- contentValue = attr.value;
529
- } else if (_typeof(attr.value) === 'object' && attr.value !== null && 'type' in attr.value && attr.value.type === 'mdxJsxAttributeValueExpression' && 'value' in attr.value && typeof attr.value.value === 'string') {
530
- // Handle expression values if needed
531
- contentValue = attr.value.value;
532
- }
533
- }
534
- }
535
- }
413
+ // Process based on meta tag name
414
+ if (metaName === 'description' && contentValue) {
415
+ metaDescription = contentValue;
416
+ } else if (metaName === 'keywords' && contentValue) {
417
+ // Parse keywords CSV into array
418
+ metaKeywords = contentValue.split(',').map(keyword => keyword.trim());
419
+ }
420
+ }
536
421
 
537
- // Process based on meta tag name
538
- } catch (err) {
539
- _iterator1.e(err);
540
- } finally {
541
- _iterator1.f();
542
- }
543
- if (metaName === 'description' && contentValue) {
544
- metaDescription = contentValue;
545
- } else if (metaName === 'keywords' && contentValue) {
546
- // Parse keywords CSV into array
547
- metaKeywords = contentValue.split(',').map(function (keyword) {
548
- return keyword.trim();
549
- });
550
- }
551
- }
422
+ // Extract headings
423
+ if (node.type === 'heading') {
424
+ const heading = node;
425
+ const text = extractTextFromChildren(heading.children);
426
+ headings.push({
427
+ depth: heading.depth,
428
+ text,
429
+ children: heading.children // Preserve AST nodes for formatting
430
+ });
431
+
432
+ // Track first h1
433
+ if (heading.depth === 1 && !foundFirstH1) {
434
+ firstH1 = text;
435
+ foundFirstH1 = true;
436
+
437
+ // Mark that we need to check the next node
438
+ if (parent && index !== undefined && 'children' in parent && Array.isArray(parent.children)) {
439
+ if (index + 1 < parent.children.length) {
440
+ nextNodeAfterH1 = parent.children[index + 1];
441
+ }
442
+ }
443
+ }
444
+ }
552
445
 
553
- // Extract headings
554
- if (node.type === 'heading') {
555
- var heading = node;
556
- var text = extractTextFromChildren(heading.children);
557
- headings.push({
558
- depth: heading.depth,
559
- text: text,
560
- children: heading.children // Preserve AST nodes for formatting
561
- });
562
-
563
- // Track first h1
564
- if (heading.depth === 1 && !foundFirstH1) {
565
- firstH1 = text;
566
- foundFirstH1 = true;
567
-
568
- // Mark that we need to check the next node
569
- if (parent && index !== undefined && 'children' in parent && Array.isArray(parent.children)) {
570
- if (index + 1 < parent.children.length) {
571
- nextNodeAfterH1 = parent.children[index + 1];
572
- }
573
- }
574
- }
575
- }
446
+ // Check if this is the paragraph right after the first h1
447
+ if (foundFirstH1 && !firstParagraphAfterH1 && nextNodeAfterH1 && node === nextNodeAfterH1 && node.type === 'paragraph') {
448
+ const paragraphNode = node;
449
+ firstParagraphAfterH1 = extractParagraphText(paragraphNode);
450
+
451
+ // If the paragraph contains a single JSX element wrapper, unwrap it
452
+ // This handles cases like <Description>text</Description>
453
+ if (paragraphNode.children.length === 1 && paragraphNode.children[0].type === 'mdxJsxTextElement' && 'children' in paragraphNode.children[0] && Array.isArray(paragraphNode.children[0].children)) {
454
+ // Use the children of the JSX element instead of the wrapper
455
+ firstParagraphMarkdown = paragraphNode.children[0].children;
456
+ } else {
457
+ // Preserve AST nodes for formatting
458
+ firstParagraphMarkdown = paragraphNode.children;
459
+ }
460
+ nextNodeAfterH1 = null; // Clear the marker
461
+ }
576
462
 
577
- // Check if this is the paragraph right after the first h1
578
- if (foundFirstH1 && !firstParagraphAfterH1 && nextNodeAfterH1 && node === nextNodeAfterH1 && node.type === 'paragraph') {
579
- var paragraphNode = node;
580
- firstParagraphAfterH1 = extractParagraphText(paragraphNode);
581
-
582
- // If the paragraph contains a single JSX element wrapper, unwrap it
583
- // This handles cases like <Description>text</Description>
584
- if (paragraphNode.children.length === 1 && paragraphNode.children[0].type === 'mdxJsxTextElement' && 'children' in paragraphNode.children[0] && Array.isArray(paragraphNode.children[0].children)) {
585
- // Use the children of the JSX element instead of the wrapper
586
- firstParagraphMarkdown = paragraphNode.children[0].children;
587
- } else {
588
- // Preserve AST nodes for formatting
589
- firstParagraphMarkdown = paragraphNode.children;
590
- }
591
- nextNodeAfterH1 = null; // Clear the marker
592
- }
463
+ // Check if this is a JSX flow element right after the first h1 (multi-line JSX like <Subtitle>...</Subtitle>)
464
+ // This handles cases where the JSX element spans multiple lines and becomes a block-level element
465
+ if (foundFirstH1 && !firstParagraphAfterH1 && nextNodeAfterH1 && node === nextNodeAfterH1 && node.type === 'mdxJsxFlowElement' && 'name' in node && node.name !== 'meta' && node.name !== 'Meta' && 'children' in node && Array.isArray(node.children)) {
466
+ // Extract text from the JSX element's children, preserving non-breaking spaces
467
+ const textContent = extractPlainTextFromChildren(node.children).replace(/[ \t\n\r]+/g, ' ').trim();
468
+ if (textContent) {
469
+ firstParagraphAfterH1 = textContent;
470
+ firstParagraphMarkdown = node.children;
471
+ }
472
+ nextNodeAfterH1 = null; // Clear the marker
473
+ }
593
474
 
594
- // Check if this is a JSX flow element right after the first h1 (multi-line JSX like <Subtitle>...</Subtitle>)
595
- // This handles cases where the JSX element spans multiple lines and becomes a block-level element
596
- if (foundFirstH1 && !firstParagraphAfterH1 && nextNodeAfterH1 && node === nextNodeAfterH1 && node.type === 'mdxJsxFlowElement' && 'name' in node && node.name !== 'meta' && node.name !== 'Meta' && 'children' in node && Array.isArray(node.children)) {
597
- // Extract text from the JSX element's children, preserving non-breaking spaces
598
- var textContent = extractPlainTextFromChildren(node.children).replace(/[ \t\n\r]+/g, ' ').trim();
599
- if (textContent) {
600
- firstParagraphAfterH1 = textContent;
601
- firstParagraphMarkdown = node.children;
602
- }
603
- nextNodeAfterH1 = null; // Clear the marker
604
- }
475
+ // Extract full text content (excluding code blocks and metadata)
476
+ // When we encounter a heading, push the heading text and then create a new empty slot for content
477
+ if (node.type === 'heading') {
478
+ const heading = node;
479
+ // Preserve non-breaking spaces in heading text
480
+ const text = extractPlainTextFromChildren(heading.children).replace(/[ \t\n\r]+/g, ' ').trim();
481
+ if (text) {
482
+ fullTextParts.push(text); // Add heading
483
+ fullTextParts.push(''); // Create slot for content after this heading
484
+ }
485
+ return;
486
+ }
605
487
 
606
- // Extract full text content (excluding code blocks and metadata)
607
- // When we encounter a heading, push the heading text and then create a new empty slot for content
608
- if (node.type === 'heading') {
609
- var _heading = node;
610
- // Preserve non-breaking spaces in heading text
611
- var _text = extractPlainTextFromChildren(_heading.children).replace(/[ \t\n\r]+/g, ' ').trim();
612
- if (_text) {
613
- fullTextParts.push(_text); // Add heading
614
- fullTextParts.push(''); // Create slot for content after this heading
615
- }
616
- return;
617
- }
488
+ // Skip multiline code blocks
489
+ if (node.type === 'code') {
490
+ return;
491
+ }
618
492
 
619
- // Skip multiline code blocks
620
- if (node.type === 'code') {
621
- return;
622
- }
493
+ // Skip metadata exports
494
+ if (node.type === 'mdxjsEsm') {
495
+ return;
496
+ }
623
497
 
624
- // Skip metadata exports
625
- if (node.type === 'mdxjsEsm') {
626
- return;
627
- }
498
+ // Skip meta tags (they don't contribute to page content)
499
+ if ((node.type === 'mdxJsxFlowElement' || node.type === 'mdxJsxTextElement') && 'name' in node && (node.name === 'meta' || node.name === 'Meta')) {
500
+ return;
501
+ }
628
502
 
629
- // Skip meta tags (they don't contribute to page content)
630
- if ((node.type === 'mdxJsxFlowElement' || node.type === 'mdxJsxTextElement') && 'name' in node && (node.name === 'meta' || node.name === 'Meta')) {
631
- return;
632
- }
503
+ // Handle paragraphs for full text, preserving non-breaking spaces
504
+ if (node.type === 'paragraph') {
505
+ const text = extractPlainTextFromChildren(node.children).replace(/[ \t\n\r]+/g, ' ').trim();
506
+ if (text) {
507
+ // Append to the last slot (current section's content)
508
+ if (fullTextParts.length === 0) {
509
+ fullTextParts.push(text);
510
+ } else {
511
+ const lastIndex = fullTextParts.length - 1;
512
+ fullTextParts[lastIndex] = fullTextParts[lastIndex] ? `${fullTextParts[lastIndex]} ${text}` : text;
513
+ }
514
+ }
515
+ }
633
516
 
634
- // Handle paragraphs for full text, preserving non-breaking spaces
635
- if (node.type === 'paragraph') {
636
- var _text2 = extractPlainTextFromChildren(node.children).replace(/[ \t\n\r]+/g, ' ').trim();
637
- if (_text2) {
638
- // Append to the last slot (current section's content)
639
- if (fullTextParts.length === 0) {
640
- fullTextParts.push(_text2);
641
- } else {
642
- var lastIndex = fullTextParts.length - 1;
643
- fullTextParts[lastIndex] = fullTextParts[lastIndex] ? "".concat(fullTextParts[lastIndex], " ").concat(_text2) : _text2;
644
- }
645
- }
646
- }
517
+ // Handle lists - condense into comma-separated items
518
+ if (node.type === 'list' && 'children' in node && Array.isArray(node.children)) {
519
+ const listItems = [];
520
+ for (const item of node.children) {
521
+ if (item.type === 'listItem' && 'children' in item && Array.isArray(item.children)) {
522
+ // Preserve non-breaking spaces in list item text
523
+ const itemText = extractPlainTextFromChildren(item.children).replace(/[ \t\n\r]+/g, ' ').trim();
524
+ if (itemText) {
525
+ listItems.push(itemText);
526
+ }
527
+ }
528
+ }
529
+ if (listItems.length > 0) {
530
+ const text = listItems.join(', ');
531
+ // Append to the last slot (current section's content)
532
+ if (fullTextParts.length === 0) {
533
+ fullTextParts.push(text);
534
+ } else {
535
+ const lastIndex = fullTextParts.length - 1;
536
+ fullTextParts[lastIndex] = fullTextParts[lastIndex] ? `${fullTextParts[lastIndex]} ${text}` : text;
537
+ }
538
+ }
539
+ }
647
540
 
648
- // Handle lists - condense into comma-separated items
649
- if (node.type === 'list' && 'children' in node && Array.isArray(node.children)) {
650
- var listItems = [];
651
- var _iterator10 = _createForOfIteratorHelper(node.children),
652
- _step10;
653
- try {
654
- for (_iterator10.s(); !(_step10 = _iterator10.n()).done;) {
655
- var item = _step10.value;
656
- if (item.type === 'listItem' && 'children' in item && Array.isArray(item.children)) {
657
- // Preserve non-breaking spaces in list item text
658
- var itemText = extractPlainTextFromChildren(item.children).replace(/[ \t\n\r]+/g, ' ').trim();
659
- if (itemText) {
660
- listItems.push(itemText);
661
- }
662
- }
663
- }
664
- } catch (err) {
665
- _iterator10.e(err);
666
- } finally {
667
- _iterator10.f();
668
- }
669
- if (listItems.length > 0) {
670
- var _text3 = listItems.join(', ');
671
- // Append to the last slot (current section's content)
672
- if (fullTextParts.length === 0) {
673
- fullTextParts.push(_text3);
674
- } else {
675
- var _lastIndex = fullTextParts.length - 1;
676
- fullTextParts[_lastIndex] = fullTextParts[_lastIndex] ? "".concat(fullTextParts[_lastIndex], " ").concat(_text3) : _text3;
677
- }
678
- }
679
- }
541
+ // Handle blockquotes - their paragraphs will be picked up by the paragraph handler above
542
+ });
680
543
 
681
- // Handle blockquotes - their paragraphs will be picked up by the paragraph handler above
682
- });
544
+ // Fill in missing title and description if we have them from content
545
+ let shouldUpdateMetadata = false;
546
+ if (metadata) {
547
+ const mutableMetadata = metadata;
683
548
 
684
- // Fill in missing title and description if we have them from content
685
- shouldUpdateMetadata = false;
686
- if (metadata) {
687
- mutableMetadata = metadata; // Add title if missing
688
- if (firstH1 && !mutableMetadata.title) {
689
- mutableMetadata.title = firstH1;
690
- shouldUpdateMetadata = true;
691
- }
549
+ // Add title if missing
550
+ if (firstH1 && !mutableMetadata.title) {
551
+ mutableMetadata.title = firstH1;
552
+ shouldUpdateMetadata = true;
553
+ }
692
554
 
693
- // Add description - prioritize meta tag over paragraph
694
- if (!mutableMetadata.description) {
695
- if (metaDescription) {
696
- mutableMetadata.description = metaDescription;
697
- shouldUpdateMetadata = true;
698
- } else if (firstParagraphAfterH1) {
699
- mutableMetadata.description = firstParagraphAfterH1;
700
- shouldUpdateMetadata = true;
701
- }
702
- }
555
+ // Add description - prioritize meta tag over paragraph
556
+ if (!mutableMetadata.description) {
557
+ if (metaDescription) {
558
+ mutableMetadata.description = metaDescription;
559
+ shouldUpdateMetadata = true;
560
+ } else if (firstParagraphAfterH1) {
561
+ mutableMetadata.description = firstParagraphAfterH1;
562
+ shouldUpdateMetadata = true;
563
+ }
564
+ }
703
565
 
704
- // Add descriptionMarkdown if missing
705
- // If we used meta tag, set to empty array since meta has no children
706
- // Otherwise use the paragraph markdown nodes
707
- if (!mutableMetadata.descriptionMarkdown) {
708
- if (metaDescription) {
709
- mutableMetadata.descriptionMarkdown = [];
710
- shouldUpdateMetadata = true;
711
- } else if (firstParagraphMarkdown) {
712
- mutableMetadata.descriptionMarkdown = firstParagraphMarkdown;
713
- shouldUpdateMetadata = true;
714
- }
715
- }
566
+ // Add descriptionMarkdown if missing
567
+ // If we used meta tag, set to empty array since meta has no children
568
+ // Otherwise use the paragraph markdown nodes
569
+ if (!mutableMetadata.descriptionMarkdown) {
570
+ if (metaDescription) {
571
+ mutableMetadata.descriptionMarkdown = [];
572
+ shouldUpdateMetadata = true;
573
+ } else if (firstParagraphMarkdown) {
574
+ mutableMetadata.descriptionMarkdown = firstParagraphMarkdown;
575
+ shouldUpdateMetadata = true;
576
+ }
577
+ }
716
578
 
717
- // Add keywords from meta tag if present
718
- if (metaKeywords && !mutableMetadata.keywords) {
719
- mutableMetadata.keywords = metaKeywords;
720
- shouldUpdateMetadata = true;
721
- }
579
+ // Add keywords from meta tag if present
580
+ if (metaKeywords && !mutableMetadata.keywords) {
581
+ mutableMetadata.keywords = metaKeywords;
582
+ shouldUpdateMetadata = true;
583
+ }
722
584
 
723
- // Add sections hierarchy if we have headings
724
- hasSections = mutableMetadata.sections && Object.keys(mutableMetadata.sections).length > 0;
725
- if (headings.length > 1 && !hasSections) {
726
- mutableMetadata.sections = buildHeadingHierarchy(headings);
727
- shouldUpdateMetadata = true;
728
- }
585
+ // Add sections hierarchy if we have headings
586
+ const hasSections = mutableMetadata.sections && Object.keys(mutableMetadata.sections).length > 0;
587
+ if (headings.length > 1 && !hasSections) {
588
+ mutableMetadata.sections = buildHeadingHierarchy(headings);
589
+ shouldUpdateMetadata = true;
590
+ }
729
591
 
730
- // Update the metadata in the ESTree if we added any fields
731
- if (shouldUpdateMetadata && metadataNode) {
732
- esmNode = metadataNode;
733
- if ((_esmNode$data = esmNode.data) != null && _esmNode$data.estree) {
734
- // Apply titleSuffix only to the exported metadata, not to the internal metadata
735
- exportMetadata = options.titleSuffix && mutableMetadata.title ? _extends(_extends({}, mutableMetadata), {}, {
736
- title: mutableMetadata.title + options.titleSuffix
737
- }) : mutableMetadata;
738
- updateMetadataInEstree(esmNode.data.estree, exportMetadata);
739
- }
740
- }
741
- } else if (firstH1 || firstParagraphAfterH1 || metaDescription || metaKeywords) {
742
- // Create metadata if we found h1, paragraph, or meta tags but no metadata export exists
743
- // Prioritize meta tag description over paragraph
744
- descriptionValue = metaDescription || firstParagraphAfterH1 || undefined;
745
- descriptionMarkdownValue = metaDescription ? [] : firstParagraphMarkdown || undefined;
746
- metadata = {
747
- title: firstH1 || undefined,
748
- description: descriptionValue,
749
- descriptionMarkdown: descriptionMarkdownValue,
750
- keywords: metaKeywords || undefined,
751
- sections: headings.length > 1 ? buildHeadingHierarchy(headings) : undefined
752
- };
592
+ // Update the metadata in the ESTree if we added any fields
593
+ if (shouldUpdateMetadata && metadataNode) {
594
+ const esmNode = metadataNode;
595
+ if (esmNode.data?.estree) {
596
+ // Apply titleSuffix only to the exported metadata, not to the internal metadata
597
+ const exportMetadata = options.titleSuffix && mutableMetadata.title ? {
598
+ ...mutableMetadata,
599
+ title: mutableMetadata.title + options.titleSuffix
600
+ } : mutableMetadata;
601
+ updateMetadataInEstree(esmNode.data.estree, exportMetadata);
602
+ }
603
+ }
604
+ } else if (firstH1 || firstParagraphAfterH1 || metaDescription || metaKeywords) {
605
+ // Create metadata if we found h1, paragraph, or meta tags but no metadata export exists
606
+ // Prioritize meta tag description over paragraph
607
+ const descriptionValue = metaDescription || firstParagraphAfterH1 || undefined;
608
+ const descriptionMarkdownValue = metaDescription ? [] : firstParagraphMarkdown || undefined;
609
+ metadata = {
610
+ title: firstH1 || undefined,
611
+ description: descriptionValue,
612
+ descriptionMarkdown: descriptionMarkdownValue,
613
+ keywords: metaKeywords || undefined,
614
+ sections: headings.length > 1 ? buildHeadingHierarchy(headings) : undefined
615
+ };
753
616
 
754
- // Create a new metadata export and add it to the tree
755
- // Apply titleSuffix only to the exported metadata, not to the internal metadata
756
- _exportMetadata = options.titleSuffix && metadata.title ? _extends(_extends({}, metadata), {}, {
757
- title: metadata.title + options.titleSuffix
758
- }) : metadata;
759
- metadataExport = createMetadataExport(_exportMetadata);
760
- root.children.unshift(metadataExport);
761
- }
617
+ // Create a new metadata export and add it to the tree
618
+ // Apply titleSuffix only to the exported metadata, not to the internal metadata
619
+ const exportMetadata = options.titleSuffix && metadata.title ? {
620
+ ...metadata,
621
+ title: metadata.title + options.titleSuffix
622
+ } : metadata;
623
+ const metadataExport = createMetadataExport(exportMetadata);
624
+ root.children.unshift(metadataExport);
625
+ }
762
626
 
763
- // Inject sitemap data into wrapper components in autogenerated index files
764
- // This uses the indexWrapperComponent from extractToIndex options
765
- wrapperComponent = _typeof(options.extractToIndex) === 'object' ? options.extractToIndex.indexWrapperComponent : undefined;
766
- extractBaseDir = _typeof(options.extractToIndex) === 'object' ? options.extractToIndex.baseDir : undefined;
767
- if (!(wrapperComponent && file.path)) {
768
- _context.n = 2;
769
- break;
627
+ // Inject sitemap data into wrapper components in autogenerated index files
628
+ // This uses the indexWrapperComponent from extractToIndex options
629
+ const wrapperComponent = typeof options.extractToIndex === 'object' ? options.extractToIndex.indexWrapperComponent : undefined;
630
+ const extractBaseDir = typeof options.extractToIndex === 'object' ? options.extractToIndex.baseDir : undefined;
631
+ if (wrapperComponent && file.path) {
632
+ let fileContent = null;
633
+ if (typeof file.value === 'string') {
634
+ fileContent = file.value;
635
+ } else if (file.value instanceof Buffer) {
636
+ fileContent = file.value.toString('utf-8');
637
+ }
638
+
639
+ // Check if this is an autogenerated index file
640
+ if (fileContent && fileContent.includes("[//]: # 'This file is autogenerated")) {
641
+ // Parse the page list metadata from the markdown
642
+ const pagesMetadata = await markdownToMetadata(fileContent);
643
+ if (pagesMetadata) {
644
+ // Compute prefix from file path
645
+ let prefix = '/';
646
+ let filePath = file.path;
647
+ // Strip baseDir if provided
648
+ if (extractBaseDir && filePath.startsWith(extractBaseDir)) {
649
+ filePath = filePath.substring(extractBaseDir.length);
650
+ if (filePath.startsWith('/')) {
651
+ filePath = filePath.substring(1);
770
652
  }
771
- fileContent = null;
772
- if (typeof file.value === 'string') {
773
- fileContent = file.value;
774
- } else if (file.value instanceof Buffer) {
775
- fileContent = file.value.toString('utf-8');
653
+ }
654
+ // Get directory path and convert to URL prefix
655
+ const dirPath = dirname(filePath);
656
+ // Filter out src, app, and route groups from the path
657
+ // First, split and filter to find meaningful segments
658
+ const segments = dirPath.split('/').filter(seg => {
659
+ if (seg.startsWith('(') && seg.endsWith(')')) {
660
+ return false;
776
661
  }
777
-
778
- // Check if this is an autogenerated index file
779
- if (!(fileContent && fileContent.includes("[//]: # 'This file is autogenerated"))) {
780
- _context.n = 2;
781
- break;
662
+ if (seg === '.' || seg === '') {
663
+ return false;
782
664
  }
783
- _context.n = 1;
784
- return markdownToMetadata(fileContent);
785
- case 1:
786
- pagesMetadata = _context.v;
787
- if (pagesMetadata) {
788
- // Compute prefix from file path
789
- prefix = '/';
790
- filePath = file.path; // Strip baseDir if provided
791
- if (extractBaseDir && filePath.startsWith(extractBaseDir)) {
792
- filePath = filePath.substring(extractBaseDir.length);
793
- if (filePath.startsWith('/')) {
794
- filePath = filePath.substring(1);
795
- }
796
- }
797
- // Get directory path and convert to URL prefix
798
- dirPath = dirname(filePath); // Filter out src, app, and route groups from the path
799
- // First, split and filter to find meaningful segments
800
- segments = dirPath.split('/').filter(function (seg) {
801
- if (seg.startsWith('(') && seg.endsWith(')')) {
802
- return false;
803
- }
804
- if (seg === '.' || seg === '') {
805
- return false;
806
- }
807
- return true;
808
- }); // Find and remove 'src' followed by 'app' pattern (common in Next.js projects)
809
- srcIndex = segments.indexOf('src');
810
- if (srcIndex !== -1) {
811
- // Remove 'src'
812
- segments.splice(srcIndex, 1);
813
- // Check if 'app' now follows where 'src' was
814
- if (segments[srcIndex] === 'app') {
815
- segments.splice(srcIndex, 1);
816
- }
817
- } else {
818
- // No 'src', check for standalone 'app' at the same position pattern
819
- appIndex = segments.indexOf('app');
820
- if (appIndex !== -1 && (appIndex === 0 || appIndex === srcIndex)) {
821
- segments.splice(appIndex, 1);
822
- }
823
- }
824
- prefix = segments.length > 0 ? "/".concat(segments.join('/'), "/") : '/';
825
-
826
- // Convert PagesMetadata to SitemapSectionData
827
- sitemapData = {
828
- title: pagesMetadata.title,
829
- prefix: prefix,
830
- pages: pagesMetadata.pages.map(function (page) {
831
- return {
832
- title: page.title,
833
- slug: page.slug,
834
- path: page.path,
835
- description: page.description,
836
- keywords: page.keywords,
837
- sections: page.sections,
838
- parts: page.parts,
839
- exports: page.exports,
840
- tags: page.tags,
841
- skipDetailSection: page.skipDetailSection,
842
- image: page.image
843
- };
844
- })
845
- }; // Find and update the wrapper component in the AST
846
- visit(root, function (node) {
847
- if (node.type === 'mdxJsxFlowElement' && 'name' in node && node.name === wrapperComponent) {
848
- // Create the data attribute with expression value
849
- var dataAttr = {
850
- type: 'mdxJsxAttribute',
851
- name: 'data',
852
- value: {
853
- type: 'mdxJsxAttributeValueExpression',
854
- value: JSON.stringify(sitemapData),
855
- data: {
856
- estree: {
857
- type: 'Program',
858
- sourceType: 'module',
859
- body: [{
860
- type: 'ExpressionStatement',
861
- expression: valueToEstree(sitemapData)
862
- }]
863
- }
864
- }
865
- }
866
- };
867
-
868
- // Add the attribute to the element
869
- if ('attributes' in node && Array.isArray(node.attributes)) {
870
- // Remove existing data attribute if present
871
- var existingIndex = node.attributes.findIndex(function (attr) {
872
- return attr && _typeof(attr) === 'object' && 'type' in attr && attr.type === 'mdxJsxAttribute' && 'name' in attr && attr.name === 'data';
873
- });
874
- if (existingIndex !== -1) {
875
- node.attributes.splice(existingIndex, 1);
665
+ return true;
666
+ });
667
+ // Find and remove 'src' followed by 'app' pattern (common in Next.js projects)
668
+ const srcIndex = segments.indexOf('src');
669
+ if (srcIndex !== -1) {
670
+ // Remove 'src'
671
+ segments.splice(srcIndex, 1);
672
+ // Check if 'app' now follows where 'src' was
673
+ if (segments[srcIndex] === 'app') {
674
+ segments.splice(srcIndex, 1);
675
+ }
676
+ } else {
677
+ // No 'src', check for standalone 'app' at the same position pattern
678
+ const appIndex = segments.indexOf('app');
679
+ if (appIndex !== -1 && (appIndex === 0 || appIndex === srcIndex)) {
680
+ segments.splice(appIndex, 1);
681
+ }
682
+ }
683
+ prefix = segments.length > 0 ? `/${segments.join('/')}/` : '/';
684
+
685
+ // Convert PagesMetadata to SitemapSectionData
686
+ const sitemapData = {
687
+ title: pagesMetadata.title,
688
+ prefix,
689
+ pages: pagesMetadata.pages.map(page => ({
690
+ title: page.title,
691
+ slug: page.slug,
692
+ path: page.path,
693
+ description: page.description,
694
+ keywords: page.keywords,
695
+ sections: page.sections,
696
+ parts: page.parts,
697
+ exports: page.exports,
698
+ tags: page.tags,
699
+ skipDetailSection: page.skipDetailSection,
700
+ image: page.image
701
+ }))
702
+ };
703
+
704
+ // Find and update the wrapper component in the AST
705
+ visit(root, node => {
706
+ if (node.type === 'mdxJsxFlowElement' && 'name' in node && node.name === wrapperComponent) {
707
+ // Create the data attribute with expression value
708
+ const dataAttr = {
709
+ type: 'mdxJsxAttribute',
710
+ name: 'data',
711
+ value: {
712
+ type: 'mdxJsxAttributeValueExpression',
713
+ value: JSON.stringify(sitemapData),
714
+ data: {
715
+ estree: {
716
+ type: 'Program',
717
+ sourceType: 'module',
718
+ body: [{
719
+ type: 'ExpressionStatement',
720
+ expression: valueToEstree(sitemapData)
721
+ }]
876
722
  }
877
- node.attributes.push(dataAttr);
878
723
  }
879
724
  }
880
- });
881
- }
882
- case 2:
883
- if (!(options.extractToIndex && metadata && file.path)) {
884
- _context.n = 6;
885
- break;
886
- }
887
- // Normalize extractToIndex options
888
- shouldExtract = false;
889
- if (typeof options.extractToIndex === 'boolean') {
890
- shouldExtract = options.extractToIndex;
891
- } else {
892
- _options$extractToInd = options.extractToIndex, _options$extractToInd2 = _options$extractToInd.include, include = _options$extractToInd2 === void 0 ? [] : _options$extractToInd2, _options$extractToInd3 = _options$extractToInd.exclude, exclude = _options$extractToInd3 === void 0 ? [] : _options$extractToInd3, baseDir = _options$extractToInd.baseDir;
893
- _filePath = file.path; // Strip base directory if provided
894
- if (baseDir && _filePath.startsWith(baseDir)) {
895
- _filePath = _filePath.substring(baseDir.length);
896
- // Remove leading slash if present
897
- if (_filePath.startsWith('/')) {
898
- _filePath = _filePath.substring(1);
725
+ };
726
+
727
+ // Add the attribute to the element
728
+ if ('attributes' in node && Array.isArray(node.attributes)) {
729
+ // Remove existing data attribute if present
730
+ const existingIndex = node.attributes.findIndex(attr => attr && typeof attr === 'object' && 'type' in attr && attr.type === 'mdxJsxAttribute' && 'name' in attr && attr.name === 'data');
731
+ if (existingIndex !== -1) {
732
+ node.attributes.splice(existingIndex, 1);
899
733
  }
734
+ node.attributes.push(dataAttr);
900
735
  }
736
+ }
737
+ });
738
+ }
739
+ }
740
+ }
901
741
 
902
- // Normalize path by removing Next.js route groups (parentheses)
903
- // e.g., "app/(shared)/page.mdx" becomes "app/page.mdx"
904
- normalizedPath = _filePath.replace(/\/\([^)]+\)/g, ''); // Skip if the file is an index file (pattern/page.mdx)
905
- // This prevents index files from extracting metadata to their parent
906
- isIndexFile = include.some(function (pattern) {
907
- return normalizedPath === "".concat(pattern, "/page.mdx");
908
- });
909
- if (isIndexFile) {
910
- shouldExtract = false;
911
- } else {
912
- // Check if file matches any include pattern (must be inside the directory and not the index itself)
913
- // The file must start with "pattern/" to ensure it's a child, not a sibling
914
- // and must not be "pattern/page.mdx" to ensure it's not the index file itself
915
- matchedIncludePattern = include.find(function (pattern) {
916
- return normalizedPath.startsWith("".concat(pattern, "/")) && normalizedPath !== "".concat(pattern, "/page.mdx");
917
- });
918
- isIncluded = include.length === 0 || matchedIncludePattern !== undefined; // Check if file matches any exclude pattern
919
- matchedExcludePattern = exclude.find(function (pattern) {
920
- return normalizedPath.startsWith("".concat(pattern, "/"));
921
- });
922
- isExcluded = matchedExcludePattern !== undefined;
923
- shouldExtract = isIncluded && !isExcluded;
924
- }
742
+ // Update parent index if requested and file path matches filters
743
+ if (options.extractToIndex && metadata && file.path) {
744
+ // Normalize extractToIndex options
745
+ let shouldExtract = false;
746
+ if (typeof options.extractToIndex === 'boolean') {
747
+ shouldExtract = options.extractToIndex;
748
+ } else {
749
+ const {
750
+ include = [],
751
+ exclude = [],
752
+ baseDir
753
+ } = options.extractToIndex;
754
+ let filePath = file.path;
755
+
756
+ // Strip base directory if provided
757
+ if (baseDir && filePath.startsWith(baseDir)) {
758
+ filePath = filePath.substring(baseDir.length);
759
+ // Remove leading slash if present
760
+ if (filePath.startsWith('/')) {
761
+ filePath = filePath.substring(1);
762
+ }
763
+ }
764
+
765
+ // Normalize path by removing Next.js route groups (parentheses)
766
+ // e.g., "app/(shared)/page.mdx" becomes "app/page.mdx"
767
+ const normalizedPath = filePath.replace(/\/\([^)]+\)/g, '');
768
+
769
+ // Skip if the file is an index file (pattern/page.mdx)
770
+ // This prevents index files from extracting metadata to their parent
771
+ const isIndexFile = include.some(pattern => {
772
+ return normalizedPath === `${pattern}/page.mdx`;
773
+ });
774
+ if (isIndexFile) {
775
+ shouldExtract = false;
776
+ } else {
777
+ // Check if file matches any include pattern (must be inside the directory and not the index itself)
778
+ // The file must start with "pattern/" to ensure it's a child, not a sibling
779
+ // and must not be "pattern/page.mdx" to ensure it's not the index file itself
780
+ const matchedIncludePattern = include.find(pattern => {
781
+ return normalizedPath.startsWith(`${pattern}/`) && normalizedPath !== `${pattern}/page.mdx`;
782
+ });
783
+ const isIncluded = include.length === 0 || matchedIncludePattern !== undefined;
784
+
785
+ // Check if file matches any exclude pattern
786
+ const matchedExcludePattern = exclude.find(pattern => {
787
+ return normalizedPath.startsWith(`${pattern}/`);
788
+ });
789
+ const isExcluded = matchedExcludePattern !== undefined;
790
+ shouldExtract = isIncluded && !isExcluded;
791
+ }
792
+ }
793
+ if (shouldExtract) {
794
+ try {
795
+ // Determine if we should use visible description instead of meta tag
796
+ const useVisibleDescription = typeof options.extractToIndex !== 'boolean' && options.extractToIndex.useVisibleDescription;
797
+ const pageMetadataOptions = {};
798
+ if (useVisibleDescription && firstParagraphAfterH1) {
799
+ pageMetadataOptions.visibleDescription = firstParagraphAfterH1;
800
+ pageMetadataOptions.visibleDescriptionMarkdown = firstParagraphMarkdown;
801
+ }
802
+ const pageMetadata = toPageMetadata(metadata, file.path, pageMetadataOptions);
803
+ const updateOptions = {
804
+ pagePath: file.path,
805
+ metadata: pageMetadata,
806
+ updateParents: true
807
+ };
808
+
809
+ // Pass through baseDir, include, exclude, onlyUpdateIndexes, and markerDir if they were configured
810
+ if (typeof options.extractToIndex !== 'boolean') {
811
+ if (options.extractToIndex.baseDir) {
812
+ updateOptions.baseDir = options.extractToIndex.baseDir;
925
813
  }
926
- if (!shouldExtract) {
927
- _context.n = 6;
928
- break;
814
+ if (options.extractToIndex.include) {
815
+ updateOptions.include = options.extractToIndex.include;
929
816
  }
930
- _context.p = 3;
931
- // Determine if we should use visible description instead of meta tag
932
- useVisibleDescription = typeof options.extractToIndex !== 'boolean' && options.extractToIndex.useVisibleDescription;
933
- pageMetadataOptions = {};
934
- if (useVisibleDescription && firstParagraphAfterH1) {
935
- pageMetadataOptions.visibleDescription = firstParagraphAfterH1;
936
- pageMetadataOptions.visibleDescriptionMarkdown = firstParagraphMarkdown;
817
+ if (options.extractToIndex.exclude) {
818
+ updateOptions.exclude = options.extractToIndex.exclude;
937
819
  }
938
- pageMetadata = toPageMetadata(metadata, file.path, pageMetadataOptions);
939
- updateOptions = {
940
- pagePath: file.path,
941
- metadata: pageMetadata,
942
- updateParents: true
943
- }; // Pass through baseDir, include, exclude, onlyUpdateIndexes, and markerDir if they were configured
944
- if (typeof options.extractToIndex !== 'boolean') {
945
- if (options.extractToIndex.baseDir) {
946
- updateOptions.baseDir = options.extractToIndex.baseDir;
947
- }
948
- if (options.extractToIndex.include) {
949
- updateOptions.include = options.extractToIndex.include;
950
- }
951
- if (options.extractToIndex.exclude) {
952
- updateOptions.exclude = options.extractToIndex.exclude;
953
- }
954
- if (options.extractToIndex.onlyUpdateIndexes !== undefined) {
955
- updateOptions.onlyUpdateIndexes = options.extractToIndex.onlyUpdateIndexes;
956
- }
957
- if (options.extractToIndex.markerDir !== undefined) {
958
- updateOptions.markerDir = options.extractToIndex.markerDir;
959
- }
960
- if (options.extractToIndex.errorIfOutOfDate !== undefined) {
961
- updateOptions.errorIfOutOfDate = options.extractToIndex.errorIfOutOfDate;
962
- }
963
- if (options.extractToIndex.indexWrapperComponent) {
964
- updateOptions.indexWrapperComponent = options.extractToIndex.indexWrapperComponent;
965
- }
820
+ if (options.extractToIndex.onlyUpdateIndexes !== undefined) {
821
+ updateOptions.onlyUpdateIndexes = options.extractToIndex.onlyUpdateIndexes;
822
+ }
823
+ if (options.extractToIndex.markerDir !== undefined) {
824
+ updateOptions.markerDir = options.extractToIndex.markerDir;
825
+ }
826
+ if (options.extractToIndex.errorIfOutOfDate !== undefined) {
827
+ updateOptions.errorIfOutOfDate = options.extractToIndex.errorIfOutOfDate;
966
828
  }
967
- _context.n = 4;
968
- return syncPageIndex(updateOptions);
969
- case 4:
970
- _context.n = 6;
971
- break;
972
- case 5:
973
- _context.p = 5;
974
- _t = _context.v;
975
- // Don't fail the build if index update fails
976
- console.error('Failed to update page index for', file.path, _t);
977
- case 6:
978
- return _context.a(2);
829
+ if (options.extractToIndex.indexWrapperComponent) {
830
+ updateOptions.indexWrapperComponent = options.extractToIndex.indexWrapperComponent;
831
+ }
832
+ }
833
+ await syncPageIndex(updateOptions);
834
+ } catch (error) {
835
+ // Don't fail the build if index update fails
836
+ console.error('Failed to update page index for', file.path, error);
979
837
  }
980
- }, _callee, null, [[3, 5]]);
981
- }));
982
- return function (_x, _x2) {
983
- return _ref5.apply(this, arguments);
984
- };
985
- }();
838
+ }
839
+ }
840
+ };
986
841
  };