@mui/internal-docs-infra 0.2.3-canary.8 → 0.3.1-canary.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -2
- package/esm/CodeHighlighter/CodeHighlighter.js +16 -16
- package/esm/CodeHighlighter/CodeHighlighterClient.js +33 -33
- package/esm/CodeHighlighter/errors.js +3 -3
- package/esm/CodeHighlighter/types.d.ts +1 -1
- package/esm/CodeProvider/CodeContext.d.ts +4 -4
- package/esm/CodeProvider/CodeProvider.js +7 -7
- package/esm/cli/index.d.ts +1 -0
- package/esm/cli/index.js +6 -0
- package/esm/cli/runValidate.d.ts +8 -0
- package/esm/cli/runValidate.js +297 -0
- package/esm/createSitemap/createSitemap.d.ts +23 -0
- package/esm/createSitemap/createSitemap.js +45 -0
- package/esm/createSitemap/index.d.ts +1 -0
- package/esm/createSitemap/index.js +1 -0
- package/esm/createSitemap/types.d.ts +68 -0
- package/esm/createSitemap/types.js +1 -0
- package/esm/pipeline/getFileConventions/fileConventions.d.ts +4 -0
- package/esm/pipeline/getFileConventions/fileConventions.js +4 -0
- package/esm/pipeline/getFileConventions/getFileConventions.d.ts +4 -0
- package/esm/pipeline/getFileConventions/getFileConventions.js +17 -0
- package/esm/pipeline/getFileConventions/index.d.ts +1 -0
- package/esm/pipeline/getFileConventions/index.js +1 -0
- package/esm/{CodeHighlighter/addPathsToVariant.d.ts → pipeline/loadCodeVariant/addCodeVariantPaths.d.ts} +1 -1
- package/esm/{CodeHighlighter/applyTransform.d.ts → pipeline/loadCodeVariant/applyCodeTransform.d.ts} +3 -3
- package/esm/{CodeHighlighter/applyTransform.js → pipeline/loadCodeVariant/applyCodeTransform.js} +4 -4
- package/esm/{CodeHighlighter → pipeline/loadCodeVariant}/calculateMainFilePath.js +1 -1
- package/esm/{CodeHighlighter/transformCode.d.ts → pipeline/loadCodeVariant/computeHastDeltas.d.ts} +9 -5
- package/esm/{CodeHighlighter/transformCode.js → pipeline/loadCodeVariant/computeHastDeltas.js} +20 -16
- package/esm/pipeline/loadCodeVariant/diffHast.d.ts +3 -0
- package/esm/{CodeHighlighter/transformParsedSource.js → pipeline/loadCodeVariant/diffHast.js} +5 -5
- package/esm/{CodeHighlighter/examineVariant.d.ts → pipeline/loadCodeVariant/examineCodeVariant.d.ts} +2 -2
- package/esm/{CodeHighlighter/examineVariant.js → pipeline/loadCodeVariant/examineCodeVariant.js} +1 -1
- package/esm/{useDemo/flattenVariant.d.ts → pipeline/loadCodeVariant/flattenCodeVariant.d.ts} +2 -2
- package/esm/{useDemo/flattenVariant.js → pipeline/loadCodeVariant/flattenCodeVariant.js} +3 -3
- package/esm/{CodeHighlighter/hasAllVariants.d.ts → pipeline/loadCodeVariant/hasAllCodeVariants.d.ts} +1 -1
- package/esm/pipeline/loadCodeVariant/index.d.ts +10 -0
- package/esm/pipeline/loadCodeVariant/index.js +17 -0
- package/esm/{CodeHighlighter/loadFallbackCode.d.ts → pipeline/loadCodeVariant/loadCodeFallback.d.ts} +2 -2
- package/esm/{CodeHighlighter/loadFallbackCode.js → pipeline/loadCodeVariant/loadCodeFallback.js} +180 -106
- package/esm/{CodeHighlighter/loadVariant.d.ts → pipeline/loadCodeVariant/loadCodeVariant.d.ts} +2 -2
- package/esm/{CodeHighlighter/loadVariant.js → pipeline/loadCodeVariant/loadCodeVariant.js} +122 -49
- package/esm/{CodeHighlighter/maybeInitialData.d.ts → pipeline/loadCodeVariant/maybeCodeInitialData.d.ts} +6 -6
- package/esm/{CodeHighlighter/maybeInitialData.js → pipeline/loadCodeVariant/maybeCodeInitialData.js} +6 -6
- package/esm/{CodeHighlighter/mergeMetadata.d.ts → pipeline/loadCodeVariant/mergeCodeMetadata.d.ts} +3 -3
- package/esm/{CodeHighlighter/mergeMetadata.js → pipeline/loadCodeVariant/mergeCodeMetadata.js} +3 -3
- package/esm/{CodeHighlighter → pipeline/loadCodeVariant}/parseCode.d.ts +1 -1
- package/esm/{CodeHighlighter → pipeline/loadCodeVariant}/transformSource.d.ts +1 -1
- package/esm/pipeline/loadPrecomputedCodeHighlighter/loadPrecomputedCodeHighlighter.d.ts +5 -0
- package/esm/pipeline/loadPrecomputedCodeHighlighter/loadPrecomputedCodeHighlighter.js +86 -13
- package/esm/pipeline/loadPrecomputedCodeHighlighter/performanceLogger.d.ts +30 -0
- package/esm/pipeline/loadPrecomputedCodeHighlighter/performanceLogger.js +77 -0
- package/esm/pipeline/loadPrecomputedCodeHighlighterClient/loadPrecomputedCodeHighlighterClient.js +7 -7
- package/esm/pipeline/loadPrecomputedSitemap/index.d.ts +2 -0
- package/esm/pipeline/loadPrecomputedSitemap/index.js +4 -0
- package/esm/pipeline/loadPrecomputedSitemap/loadPrecomputedSitemap.d.ts +10 -0
- package/esm/pipeline/loadPrecomputedSitemap/loadPrecomputedSitemap.js +213 -0
- package/esm/pipeline/loadServerCodeMeta/index.d.ts +2 -1
- package/esm/pipeline/loadServerCodeMeta/index.js +2 -1
- package/esm/pipeline/loadServerCodeMeta/loadServerCodeMeta.d.ts +1 -1
- package/esm/pipeline/loadServerCodeMeta/loadServerCodeMeta.js +2 -2
- package/esm/pipeline/{loaderUtils → loadServerCodeMeta}/resolveModulePathWithFs.d.ts +1 -1
- package/esm/pipeline/{loaderUtils → loadServerCodeMeta}/resolveModulePathWithFs.js +1 -1
- package/esm/pipeline/loadServerPageIndex/index.d.ts +2 -0
- package/esm/pipeline/loadServerPageIndex/index.js +1 -0
- package/esm/pipeline/loadServerPageIndex/loadServerPageIndex.d.ts +51 -0
- package/esm/pipeline/loadServerPageIndex/loadServerPageIndex.js +174 -0
- package/esm/pipeline/loadServerSitemap/index.d.ts +2 -0
- package/esm/pipeline/loadServerSitemap/index.js +1 -0
- package/esm/pipeline/loadServerSitemap/loadServerSitemap.d.ts +39 -0
- package/esm/pipeline/loadServerSitemap/loadServerSitemap.js +168 -0
- package/esm/pipeline/loadServerSource/loadServerSource.js +1 -1
- package/esm/pipeline/loaderUtils/externalsToPackages.js +1 -1
- package/esm/pipeline/loaderUtils/processRelativeImports.js +16 -3
- package/esm/pipeline/loaderUtils/rewriteImports.d.ts +36 -0
- package/esm/pipeline/loaderUtils/rewriteImports.js +139 -8
- package/esm/pipeline/syncPageIndex/createMarkdownNodes.d.ts +76 -0
- package/esm/pipeline/syncPageIndex/createMarkdownNodes.js +305 -0
- package/esm/pipeline/syncPageIndex/index.d.ts +1 -0
- package/esm/pipeline/syncPageIndex/index.js +1 -0
- package/esm/pipeline/syncPageIndex/mergeMetadataMarkdown.d.ts +58 -0
- package/esm/pipeline/syncPageIndex/mergeMetadataMarkdown.js +214 -0
- package/esm/pipeline/syncPageIndex/metadataToMarkdown.d.ts +67 -0
- package/esm/pipeline/syncPageIndex/metadataToMarkdown.js +1486 -0
- package/esm/pipeline/syncPageIndex/syncPageIndex.d.ts +108 -0
- package/esm/pipeline/syncPageIndex/syncPageIndex.js +540 -0
- package/esm/pipeline/transformHtmlCodePrecomputed/transformHtmlCodePrecomputed.d.ts +2 -2
- package/esm/pipeline/transformHtmlCodePrecomputed/transformHtmlCodePrecomputed.js +5 -5
- package/esm/pipeline/transformMarkdownBlockquoteCallouts/index.d.ts +2 -0
- package/esm/pipeline/transformMarkdownBlockquoteCallouts/index.js +4 -0
- package/esm/pipeline/transformMarkdownBlockquoteCallouts/transformMarkdownBlockquoteCallouts.d.ts +16 -0
- package/esm/pipeline/transformMarkdownBlockquoteCallouts/transformMarkdownBlockquoteCallouts.js +58 -0
- package/esm/pipeline/transformMarkdownDemoLinks/index.d.ts +2 -0
- package/esm/pipeline/transformMarkdownDemoLinks/index.js +4 -0
- package/esm/pipeline/transformMarkdownDemoLinks/transformMarkdownDemoLinks.d.ts +26 -0
- package/esm/pipeline/transformMarkdownDemoLinks/transformMarkdownDemoLinks.js +107 -0
- package/esm/pipeline/transformMarkdownMetadata/index.d.ts +2 -0
- package/esm/pipeline/transformMarkdownMetadata/index.js +4 -0
- package/esm/pipeline/transformMarkdownMetadata/transformMarkdownMetadata.d.ts +3 -0
- package/esm/pipeline/transformMarkdownMetadata/transformMarkdownMetadata.js +1010 -0
- package/esm/pipeline/transformMarkdownMetadata/types.d.ts +110 -0
- package/esm/pipeline/transformMarkdownMetadata/types.js +1 -0
- package/esm/pipeline/transformMarkdownRelativePaths/index.d.ts +2 -0
- package/esm/pipeline/transformMarkdownRelativePaths/index.js +4 -0
- package/esm/pipeline/transformMarkdownRelativePaths/transformMarkdownRelativePaths.d.ts +15 -0
- package/esm/pipeline/transformMarkdownRelativePaths/transformMarkdownRelativePaths.js +40 -0
- package/esm/useCode/Pre.js +15 -2
- package/esm/useCode/useCode.d.ts +15 -2
- package/esm/useCode/useCode.js +15 -6
- package/esm/useCode/useCodeUtils.js +3 -3
- package/esm/useCode/useFileNavigation.d.ts +9 -3
- package/esm/useCode/useFileNavigation.js +124 -81
- package/esm/useCode/useUIState.d.ts +4 -1
- package/esm/useCode/useUIState.js +17 -2
- package/esm/useCode/useVariantSelection.d.ts +8 -3
- package/esm/useCode/useVariantSelection.js +144 -52
- package/esm/useCopier/index.js +5 -4
- package/esm/useDemo/createCodeSandbox.d.ts +1 -1
- package/esm/useDemo/createStackBlitz.d.ts +1 -1
- package/esm/useDemo/exportVariant.js +13 -11
- package/esm/useDemo/index.d.ts +1 -1
- package/esm/useDemo/index.js +1 -1
- package/esm/useDemo/useDemo.d.ts +5 -5
- package/esm/useDemo/useDemo.js +6 -6
- package/esm/useErrors/useErrors.d.ts +1 -1
- package/esm/useErrors/useErrors.js +6 -2
- package/esm/useSearch/index.d.ts +1 -0
- package/esm/useSearch/index.js +1 -0
- package/esm/useSearch/types.d.ts +165 -0
- package/esm/useSearch/types.js +1 -0
- package/esm/useSearch/useSearch.d.ts +56 -0
- package/esm/useSearch/useSearch.js +647 -0
- package/esm/withDocsInfra/withDeploymentConfig.js +4 -2
- package/esm/withDocsInfra/withDocsInfra.d.ts +39 -0
- package/esm/withDocsInfra/withDocsInfra.js +79 -7
- package/package.json +106 -6
- package/esm/CodeHighlighter/transformParsedSource.d.ts +0 -3
- /package/esm/{CodeHighlighter/addPathsToVariant.js → pipeline/loadCodeVariant/addCodeVariantPaths.js} +0 -0
- /package/esm/{CodeHighlighter → pipeline/loadCodeVariant}/calculateMainFilePath.d.ts +0 -0
- /package/esm/{CodeHighlighter/hasAllVariants.js → pipeline/loadCodeVariant/hasAllCodeVariants.js} +0 -0
- /package/esm/{CodeHighlighter → pipeline/loadCodeVariant}/parseCode.js +0 -0
- /package/esm/{CodeHighlighter → pipeline/loadCodeVariant}/pathUtils.d.ts +0 -0
- /package/esm/{CodeHighlighter → pipeline/loadCodeVariant}/pathUtils.js +0 -0
- /package/esm/{CodeHighlighter → pipeline/loadCodeVariant}/transformSource.js +0 -0
|
@@ -0,0 +1,1486 @@
|
|
|
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 _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
6
|
+
import _createForOfIteratorHelper from "@babel/runtime/helpers/esm/createForOfIteratorHelper";
|
|
7
|
+
var _excluded = ["position"];
|
|
8
|
+
import { unified } from 'unified';
|
|
9
|
+
import remarkParse from 'remark-parse';
|
|
10
|
+
import { visit } from 'unist-util-visit';
|
|
11
|
+
import { heading, paragraph, text, link, comment } from "./createMarkdownNodes.js";
|
|
12
|
+
|
|
13
|
+
// Definition nodes are used for markdown-style comments like [//]: # "Comment text"
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Converts AST nodes (from heading.children) back to markdown string
|
|
17
|
+
*/
|
|
18
|
+
function astNodesToMarkdown(nodes) {
|
|
19
|
+
var result = '';
|
|
20
|
+
var _iterator = _createForOfIteratorHelper(nodes),
|
|
21
|
+
_step;
|
|
22
|
+
try {
|
|
23
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
24
|
+
var node = _step.value;
|
|
25
|
+
if (node.type === 'text') {
|
|
26
|
+
result += node.value;
|
|
27
|
+
} else if (node.type === 'inlineCode') {
|
|
28
|
+
result += "`".concat(node.value, "`");
|
|
29
|
+
} else if (node.type === 'emphasis') {
|
|
30
|
+
result += "*".concat(astNodesToMarkdown(node.children), "*");
|
|
31
|
+
} else if (node.type === 'strong') {
|
|
32
|
+
result += "**".concat(astNodesToMarkdown(node.children), "**");
|
|
33
|
+
} else if (node.type === 'link') {
|
|
34
|
+
result += "[".concat(astNodesToMarkdown(node.children), "](").concat(node.url, ")");
|
|
35
|
+
} else if ('children' in node) {
|
|
36
|
+
result += astNodesToMarkdown(node.children);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
} catch (err) {
|
|
40
|
+
_iterator.e(err);
|
|
41
|
+
} finally {
|
|
42
|
+
_iterator.f();
|
|
43
|
+
}
|
|
44
|
+
return result;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Options for metadataToMarkdown and metadataToMarkdownAst functions
|
|
49
|
+
*/
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Converts a HeadingHierarchy into markdown list format
|
|
53
|
+
*/
|
|
54
|
+
function headingHierarchyToMarkdown(hierarchy, basePath) {
|
|
55
|
+
var depth = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
|
|
56
|
+
var result = '';
|
|
57
|
+
var indent = ' '.repeat(depth);
|
|
58
|
+
for (var _i = 0, _Object$values = Object.values(hierarchy); _i < _Object$values.length; _i++) {
|
|
59
|
+
var node = _Object$values[_i];
|
|
60
|
+
var titleMarkdown = node.titleMarkdown,
|
|
61
|
+
children = node.children;
|
|
62
|
+
// Convert AST nodes back to markdown string with preserved formatting
|
|
63
|
+
var titleString = astNodesToMarkdown(titleMarkdown);
|
|
64
|
+
|
|
65
|
+
// Escape numbered list syntax (e.g., "1. Text" -> "1\. Text")
|
|
66
|
+
// This prevents markdown from treating "- 1. Text" as a nested ordered list
|
|
67
|
+
titleString = titleString.replace(/^(\d+)\.\s/, '$1\\. ');
|
|
68
|
+
result += "".concat(indent, "- ").concat(titleString, "\n");
|
|
69
|
+
if (Object.keys(children).length > 0) {
|
|
70
|
+
result += headingHierarchyToMarkdown(children, basePath, depth + 1);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
return result;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Converts a HeadingHierarchy into markdown AST list nodes
|
|
78
|
+
*/
|
|
79
|
+
function headingHierarchyToListNodes(hierarchy, basePath) {
|
|
80
|
+
var listItems = [];
|
|
81
|
+
for (var _i2 = 0, _Object$values2 = Object.values(hierarchy); _i2 < _Object$values2.length; _i2++) {
|
|
82
|
+
var node = _Object$values2[_i2];
|
|
83
|
+
var titleMarkdown = node.titleMarkdown,
|
|
84
|
+
children = node.children;
|
|
85
|
+
var listItem = {
|
|
86
|
+
type: 'listItem',
|
|
87
|
+
children: [{
|
|
88
|
+
type: 'paragraph',
|
|
89
|
+
children: titleMarkdown // Use the preserved AST nodes directly
|
|
90
|
+
}]
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
// Add nested children if they exist
|
|
94
|
+
if (Object.keys(children).length > 0) {
|
|
95
|
+
var nestedList = {
|
|
96
|
+
type: 'list',
|
|
97
|
+
ordered: false,
|
|
98
|
+
children: headingHierarchyToListNodes(children, basePath)
|
|
99
|
+
};
|
|
100
|
+
listItem.children.push(nestedList);
|
|
101
|
+
}
|
|
102
|
+
listItems.push(listItem);
|
|
103
|
+
}
|
|
104
|
+
return listItems;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Strips position metadata from AST nodes recursively
|
|
109
|
+
*/
|
|
110
|
+
function stripPositions(nodes) {
|
|
111
|
+
return nodes.map(function (node) {
|
|
112
|
+
var position = node.position,
|
|
113
|
+
rest = _objectWithoutPropertiesLoose(node, _excluded);
|
|
114
|
+
if (rest.children) {
|
|
115
|
+
rest.children = stripPositions(rest.children);
|
|
116
|
+
}
|
|
117
|
+
return rest;
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* Parses exports metadata from a nested list structure
|
|
123
|
+
* Expects format:
|
|
124
|
+
* - Exports:
|
|
125
|
+
* - ComponentName - PartName
|
|
126
|
+
* - Props: a, b, c
|
|
127
|
+
* - Data Attributes: x, y
|
|
128
|
+
* - CSS Variables: --var1, --var2
|
|
129
|
+
*/
|
|
130
|
+
function parseExportsFromListItem(listItem) {
|
|
131
|
+
var _listItem$children;
|
|
132
|
+
var exports = {};
|
|
133
|
+
var parts = {};
|
|
134
|
+
|
|
135
|
+
// Find the nested list within this list item
|
|
136
|
+
var nestedList = (_listItem$children = listItem.children) == null ? void 0 : _listItem$children.find(function (child) {
|
|
137
|
+
return child.type === 'list';
|
|
138
|
+
});
|
|
139
|
+
if (!(nestedList != null && nestedList.children)) {
|
|
140
|
+
return {
|
|
141
|
+
exports: exports
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
// Parse each export/part item from the nested list
|
|
146
|
+
var _iterator2 = _createForOfIteratorHelper(nestedList.children),
|
|
147
|
+
_step2;
|
|
148
|
+
try {
|
|
149
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
150
|
+
var _exportListItem$child, _exportParagraph$chil, _exportListItem$child2;
|
|
151
|
+
var exportListItem = _step2.value;
|
|
152
|
+
if (exportListItem.type !== 'listItem') {
|
|
153
|
+
continue;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
// Find the paragraph with the export/part name
|
|
157
|
+
var exportParagraph = (_exportListItem$child = exportListItem.children) == null ? void 0 : _exportListItem$child.find(function (child) {
|
|
158
|
+
return child.type === 'paragraph';
|
|
159
|
+
});
|
|
160
|
+
if (!exportParagraph) {
|
|
161
|
+
continue;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
// Extract the name from the text node
|
|
165
|
+
var textNode = (_exportParagraph$chil = exportParagraph.children) == null ? void 0 : _exportParagraph$chil.find(function (child) {
|
|
166
|
+
return child.type === 'text';
|
|
167
|
+
});
|
|
168
|
+
if (!textNode) {
|
|
169
|
+
continue;
|
|
170
|
+
}
|
|
171
|
+
var fullName = textNode.value || '';
|
|
172
|
+
|
|
173
|
+
// Check if this is a part (has dash) or export (no dash)
|
|
174
|
+
var hasDash = fullName.includes(' - ');
|
|
175
|
+
|
|
176
|
+
// Find the nested list with props/dataAttributes/cssVariables
|
|
177
|
+
var metadataList = (_exportListItem$child2 = exportListItem.children) == null ? void 0 : _exportListItem$child2.find(function (child) {
|
|
178
|
+
return child.type === 'list';
|
|
179
|
+
});
|
|
180
|
+
|
|
181
|
+
// Initialize the metadata (only add properties that have content)
|
|
182
|
+
var metadata = {};
|
|
183
|
+
if (metadataList) {
|
|
184
|
+
// Parse each metadata item
|
|
185
|
+
var _iterator3 = _createForOfIteratorHelper(metadataList.children),
|
|
186
|
+
_step3;
|
|
187
|
+
try {
|
|
188
|
+
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
|
189
|
+
var _metadataItem$childre;
|
|
190
|
+
var metadataItem = _step3.value;
|
|
191
|
+
if (metadataItem.type !== 'listItem') {
|
|
192
|
+
continue;
|
|
193
|
+
}
|
|
194
|
+
var metadataParagraph = (_metadataItem$childre = metadataItem.children) == null ? void 0 : _metadataItem$childre.find(function (child) {
|
|
195
|
+
return child.type === 'paragraph';
|
|
196
|
+
});
|
|
197
|
+
if (!metadataParagraph) {
|
|
198
|
+
continue;
|
|
199
|
+
}
|
|
200
|
+
var metadataText = extractPlainTextFromNode(metadataParagraph);
|
|
201
|
+
if (metadataText.startsWith('Props:')) {
|
|
202
|
+
var propsText = metadataText.replace('Props:', '').trim();
|
|
203
|
+
if (propsText) {
|
|
204
|
+
metadata.props = propsText.split(',').map(function (p) {
|
|
205
|
+
return p.trim();
|
|
206
|
+
});
|
|
207
|
+
}
|
|
208
|
+
} else if (metadataText.startsWith('Data Attributes:')) {
|
|
209
|
+
var dataAttributesText = metadataText.replace('Data Attributes:', '').trim();
|
|
210
|
+
if (dataAttributesText) {
|
|
211
|
+
metadata.dataAttributes = dataAttributesText.split(',').map(function (attr) {
|
|
212
|
+
return attr.trim();
|
|
213
|
+
});
|
|
214
|
+
}
|
|
215
|
+
} else if (metadataText.startsWith('CSS Variables:')) {
|
|
216
|
+
var cssVariablesText = metadataText.replace('CSS Variables:', '').trim();
|
|
217
|
+
if (cssVariablesText) {
|
|
218
|
+
metadata.cssVariables = cssVariablesText.split(',').map(function (cssVar) {
|
|
219
|
+
return cssVar.trim();
|
|
220
|
+
});
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
} catch (err) {
|
|
225
|
+
_iterator3.e(err);
|
|
226
|
+
} finally {
|
|
227
|
+
_iterator3.f();
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
if (hasDash) {
|
|
231
|
+
// This is a part name (e.g., "ComponentName - PartName")
|
|
232
|
+
var partName = fullName.split(' - ').pop() || fullName;
|
|
233
|
+
// Always add the part, even if it has no properties
|
|
234
|
+
parts[partName] = metadata;
|
|
235
|
+
} else {
|
|
236
|
+
// This is an export name (no dash)
|
|
237
|
+
var exportName = fullName;
|
|
238
|
+
// Always add the export, even if it has no properties
|
|
239
|
+
exports[exportName] = metadata;
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
} catch (err) {
|
|
243
|
+
_iterator2.e(err);
|
|
244
|
+
} finally {
|
|
245
|
+
_iterator2.f();
|
|
246
|
+
}
|
|
247
|
+
return {
|
|
248
|
+
exports: Object.keys(exports).length > 0 ? exports : undefined,
|
|
249
|
+
parts: Object.keys(parts).length > 0 ? parts : undefined
|
|
250
|
+
};
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
/**
|
|
254
|
+
* Parses a list of section links back into a HeadingHierarchy structure
|
|
255
|
+
* Expects list items with links in the format: [Title](path#slug)
|
|
256
|
+
* OR plain text in the format: Title
|
|
257
|
+
*/
|
|
258
|
+
function parseHeadingSections(listNode) {
|
|
259
|
+
var hierarchy = {};
|
|
260
|
+
var stack = [{
|
|
261
|
+
depth: -1,
|
|
262
|
+
node: hierarchy
|
|
263
|
+
}];
|
|
264
|
+
|
|
265
|
+
// Helper to calculate depth from list nesting
|
|
266
|
+
function processListItems(items, baseDepth) {
|
|
267
|
+
var parentIsOrdered = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
268
|
+
var startIndex = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 1;
|
|
269
|
+
for (var i = 0; i < items.length; i += 1) {
|
|
270
|
+
var _item$children, _itemParagraph$childr;
|
|
271
|
+
var item = items[i];
|
|
272
|
+
if (item.type !== 'listItem') {
|
|
273
|
+
continue;
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
// Find the paragraph content
|
|
277
|
+
var itemParagraph = (_item$children = item.children) == null ? void 0 : _item$children.find(function (child) {
|
|
278
|
+
return child.type === 'paragraph';
|
|
279
|
+
});
|
|
280
|
+
if (!itemParagraph) {
|
|
281
|
+
continue;
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
// Try to find a link first (linked format)
|
|
285
|
+
var itemLink = itemParagraph == null || (_itemParagraph$childr = itemParagraph.children) == null ? void 0 : _itemParagraph$childr.find(function (child) {
|
|
286
|
+
return child.type === 'link';
|
|
287
|
+
});
|
|
288
|
+
var title = '';
|
|
289
|
+
var titleMarkdown = [];
|
|
290
|
+
var slug = '';
|
|
291
|
+
if (itemLink) {
|
|
292
|
+
var _itemLink$children;
|
|
293
|
+
// Linked format: [Title](path#slug)
|
|
294
|
+
title = ((_itemLink$children = itemLink.children) == null || (_itemLink$children = _itemLink$children[0]) == null ? void 0 : _itemLink$children.value) || '';
|
|
295
|
+
// Strip position metadata from titleMarkdown
|
|
296
|
+
titleMarkdown = stripPositions(itemLink.children || []);
|
|
297
|
+
var url = itemLink.url || '';
|
|
298
|
+
slug = url.split('#')[1] || '';
|
|
299
|
+
} else {
|
|
300
|
+
// Plain text format: extract all children (preserves formatting)
|
|
301
|
+
// Strip position metadata from titleMarkdown
|
|
302
|
+
titleMarkdown = stripPositions(itemParagraph.children || []);
|
|
303
|
+
|
|
304
|
+
// Extract plain text for slug generation
|
|
305
|
+
var rawTitle = itemParagraph.children.map(function (child) {
|
|
306
|
+
if (child.type === 'text') {
|
|
307
|
+
return child.value;
|
|
308
|
+
}
|
|
309
|
+
if (child.type === 'inlineCode') {
|
|
310
|
+
return child.value;
|
|
311
|
+
}
|
|
312
|
+
if ('children' in child) {
|
|
313
|
+
// Recursively extract text from nested nodes
|
|
314
|
+
return astNodesToMarkdown(child.children).replace(/[*`_]/g, '');
|
|
315
|
+
}
|
|
316
|
+
return '';
|
|
317
|
+
}).join('').trim();
|
|
318
|
+
|
|
319
|
+
// Unescape numbered list syntax (e.g., "1\. Text" -> "1. Text")
|
|
320
|
+
// This handles titles that were escaped during serialization
|
|
321
|
+
rawTitle = rawTitle.replace(/^(\d+)\\\.\s/, '$1. ');
|
|
322
|
+
|
|
323
|
+
// If this is from an ordered list, prepend the number
|
|
324
|
+
if (parentIsOrdered) {
|
|
325
|
+
var itemNumber = startIndex + i;
|
|
326
|
+
title = "".concat(itemNumber, ". ").concat(rawTitle);
|
|
327
|
+
// Update titleMarkdown to include the number
|
|
328
|
+
titleMarkdown = [{
|
|
329
|
+
type: 'text',
|
|
330
|
+
value: title
|
|
331
|
+
}];
|
|
332
|
+
} else {
|
|
333
|
+
title = rawTitle;
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
// Generate slug from the title (with number if applicable)
|
|
337
|
+
slug = title.toLowerCase().replace(/[^a-z0-9]+/g, '-').replace(/^-|-$/g, '');
|
|
338
|
+
}
|
|
339
|
+
if (title && slug && titleMarkdown.length > 0) {
|
|
340
|
+
var _item$children2;
|
|
341
|
+
// Pop stack until we find the parent at the right depth
|
|
342
|
+
while (stack.length > 0 && stack[stack.length - 1].depth >= baseDepth) {
|
|
343
|
+
stack.pop();
|
|
344
|
+
}
|
|
345
|
+
var parent = stack[stack.length - 1].node;
|
|
346
|
+
var newNode = {
|
|
347
|
+
title: title,
|
|
348
|
+
titleMarkdown: titleMarkdown,
|
|
349
|
+
children: {}
|
|
350
|
+
};
|
|
351
|
+
parent[slug] = newNode;
|
|
352
|
+
stack.push({
|
|
353
|
+
depth: baseDepth,
|
|
354
|
+
node: newNode.children
|
|
355
|
+
});
|
|
356
|
+
|
|
357
|
+
// Check for nested lists (can be ordered or unordered)
|
|
358
|
+
var nestedLists = (_item$children2 = item.children) == null ? void 0 : _item$children2.filter(function (child) {
|
|
359
|
+
return child.type === 'list';
|
|
360
|
+
});
|
|
361
|
+
var _iterator4 = _createForOfIteratorHelper(nestedLists || []),
|
|
362
|
+
_step4;
|
|
363
|
+
try {
|
|
364
|
+
for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
|
|
365
|
+
var nestedList = _step4.value;
|
|
366
|
+
if (nestedList.children) {
|
|
367
|
+
var nestedIsOrdered = nestedList.ordered === true;
|
|
368
|
+
var nestedStart = nestedList.start || 1;
|
|
369
|
+
// Always increment depth for true nesting
|
|
370
|
+
processListItems(nestedList.children, baseDepth + 1, nestedIsOrdered, nestedStart);
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
} catch (err) {
|
|
374
|
+
_iterator4.e(err);
|
|
375
|
+
} finally {
|
|
376
|
+
_iterator4.f();
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
if ((listNode == null ? void 0 : listNode.type) === 'list' && listNode.children) {
|
|
382
|
+
processListItems(listNode.children, 0);
|
|
383
|
+
}
|
|
384
|
+
return hierarchy;
|
|
385
|
+
} /**
|
|
386
|
+
* Converts an array of page metadata into a markdown AST
|
|
387
|
+
*/
|
|
388
|
+
export function metadataToMarkdownAst(data) {
|
|
389
|
+
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
390
|
+
var editableMarker = options.editableMarker,
|
|
391
|
+
indexWrapperComponent = options.indexWrapperComponent,
|
|
392
|
+
path = options.path;
|
|
393
|
+
var mainTitle = data.title,
|
|
394
|
+
mainDescription = data.description,
|
|
395
|
+
pages = data.pages,
|
|
396
|
+
pageMetadata = data.pageMetadata;
|
|
397
|
+
var children = [];
|
|
398
|
+
|
|
399
|
+
// Add main title
|
|
400
|
+
children.push(heading(1, mainTitle));
|
|
401
|
+
|
|
402
|
+
// Add description if provided (editable section)
|
|
403
|
+
if (mainDescription) {
|
|
404
|
+
children.push(paragraph(mainDescription));
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
// Add editable section marker
|
|
408
|
+
// Extract just the comment text from the marker (strip [//]: # 'text' wrapper)
|
|
409
|
+
var defaultMarkerText = 'This file is autogenerated, but the following list can be modified.';
|
|
410
|
+
var markerText = defaultMarkerText;
|
|
411
|
+
if (editableMarker) {
|
|
412
|
+
// Extract text between single quotes: [//]: # 'text'
|
|
413
|
+
var match = editableMarker.match(/\[\/\/\]: # '(.+)'/);
|
|
414
|
+
markerText = match ? match[1] : defaultMarkerText;
|
|
415
|
+
}
|
|
416
|
+
children.push(comment(markerText));
|
|
417
|
+
|
|
418
|
+
// Open wrapper component if provided
|
|
419
|
+
if (indexWrapperComponent) {
|
|
420
|
+
children.push({
|
|
421
|
+
type: 'html',
|
|
422
|
+
value: "<".concat(indexWrapperComponent, ">")
|
|
423
|
+
});
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
// Add page list (editable section) as proper list items
|
|
427
|
+
var listItems = [];
|
|
428
|
+
var _iterator5 = _createForOfIteratorHelper(pages),
|
|
429
|
+
_step5;
|
|
430
|
+
try {
|
|
431
|
+
for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
|
|
432
|
+
var _page$openGraph;
|
|
433
|
+
var page = _step5.value;
|
|
434
|
+
var pageTitle = ((_page$openGraph = page.openGraph) == null ? void 0 : _page$openGraph.title) || page.title || page.slug;
|
|
435
|
+
|
|
436
|
+
// Check if this is a single-link entry (external link or no detail section)
|
|
437
|
+
var isSingleLink = page.skipDetailSection || false;
|
|
438
|
+
var paragraphChildren = void 0;
|
|
439
|
+
if (isSingleLink) {
|
|
440
|
+
// Format: - [Title](./path) [Tag1] [Tag2]
|
|
441
|
+
paragraphChildren = [link(page.path, pageTitle)];
|
|
442
|
+
|
|
443
|
+
// Add tags if present (directly after link)
|
|
444
|
+
if (page.tags && page.tags.length > 0) {
|
|
445
|
+
var _iterator7 = _createForOfIteratorHelper(page.tags),
|
|
446
|
+
_step7;
|
|
447
|
+
try {
|
|
448
|
+
for (_iterator7.s(); !(_step7 = _iterator7.n()).done;) {
|
|
449
|
+
var tag = _step7.value;
|
|
450
|
+
paragraphChildren.push(text(" [".concat(tag, "]")));
|
|
451
|
+
}
|
|
452
|
+
} catch (err) {
|
|
453
|
+
_iterator7.e(err);
|
|
454
|
+
} finally {
|
|
455
|
+
_iterator7.f();
|
|
456
|
+
}
|
|
457
|
+
}
|
|
458
|
+
} else {
|
|
459
|
+
// Format: - [Title](#slug) [Tag1] [Tag2] - [Full Docs](./path/page.mdx)
|
|
460
|
+
paragraphChildren = [link("#".concat(page.slug), pageTitle)];
|
|
461
|
+
|
|
462
|
+
// Add tags if present (directly after component name)
|
|
463
|
+
if (page.tags && page.tags.length > 0) {
|
|
464
|
+
var _iterator8 = _createForOfIteratorHelper(page.tags),
|
|
465
|
+
_step8;
|
|
466
|
+
try {
|
|
467
|
+
for (_iterator8.s(); !(_step8 = _iterator8.n()).done;) {
|
|
468
|
+
var _tag = _step8.value;
|
|
469
|
+
paragraphChildren.push(text(" [".concat(_tag, "]")));
|
|
470
|
+
}
|
|
471
|
+
} catch (err) {
|
|
472
|
+
_iterator8.e(err);
|
|
473
|
+
} finally {
|
|
474
|
+
_iterator8.f();
|
|
475
|
+
}
|
|
476
|
+
}
|
|
477
|
+
|
|
478
|
+
// Add separator and Full Docs link
|
|
479
|
+
paragraphChildren.push(text(' - '));
|
|
480
|
+
paragraphChildren.push(link(page.path, 'Full Docs'));
|
|
481
|
+
}
|
|
482
|
+
listItems.push({
|
|
483
|
+
type: 'listItem',
|
|
484
|
+
spread: false,
|
|
485
|
+
children: [paragraph(paragraphChildren)]
|
|
486
|
+
});
|
|
487
|
+
}
|
|
488
|
+
|
|
489
|
+
// Add the list to children
|
|
490
|
+
} catch (err) {
|
|
491
|
+
_iterator5.e(err);
|
|
492
|
+
} finally {
|
|
493
|
+
_iterator5.f();
|
|
494
|
+
}
|
|
495
|
+
children.push({
|
|
496
|
+
type: 'list',
|
|
497
|
+
ordered: false,
|
|
498
|
+
spread: false,
|
|
499
|
+
children: listItems
|
|
500
|
+
});
|
|
501
|
+
|
|
502
|
+
// Add non-editable section marker
|
|
503
|
+
// Trim common prefixes and suffixes from path, quote if contains parentheses for shell safety
|
|
504
|
+
var trimmedPath = path == null ? void 0 : path.replace(/^(src\/app\/|app\/)/, '').replace(/\/page\.mdx$/, '');
|
|
505
|
+
var quotedPath = trimmedPath && /[()]/.test(trimmedPath) ? "\"".concat(trimmedPath, "\"") : trimmedPath;
|
|
506
|
+
var doNotEditComment = quotedPath ? "This file is autogenerated, DO NOT EDIT AFTER THIS LINE, run: pnpm docs:validate ".concat(quotedPath) : 'This file is autogenerated, DO NOT EDIT AFTER THIS LINE';
|
|
507
|
+
children.push(comment(doNotEditComment));
|
|
508
|
+
|
|
509
|
+
// Add detailed page sections (non-editable)
|
|
510
|
+
var _iterator6 = _createForOfIteratorHelper(pages),
|
|
511
|
+
_step6;
|
|
512
|
+
try {
|
|
513
|
+
for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) {
|
|
514
|
+
var _page$openGraph2, _page$openGraph3, _page$openGraph4;
|
|
515
|
+
var _page = _step6.value;
|
|
516
|
+
var _pageTitle = ((_page$openGraph2 = _page.openGraph) == null ? void 0 : _page$openGraph2.title) || _page.title || _page.slug;
|
|
517
|
+
// Note: We don't replace newlines here to allow natural line breaks in detailed sections
|
|
518
|
+
var description = ((_page$openGraph3 = _page.openGraph) == null ? void 0 : _page$openGraph3.description) || _page.description || 'No description available';
|
|
519
|
+
var keywords = _page.keywords || [];
|
|
520
|
+
var image = (_page$openGraph4 = _page.openGraph) == null || (_page$openGraph4 = _page$openGraph4.images) == null ? void 0 : _page$openGraph4[0];
|
|
521
|
+
|
|
522
|
+
// Add page heading
|
|
523
|
+
children.push(heading(2, _pageTitle));
|
|
524
|
+
|
|
525
|
+
// Add description
|
|
526
|
+
children.push(paragraph(description));
|
|
527
|
+
|
|
528
|
+
// Add image if available
|
|
529
|
+
if (image) {
|
|
530
|
+
children.push({
|
|
531
|
+
type: 'paragraph',
|
|
532
|
+
children: [{
|
|
533
|
+
type: 'image',
|
|
534
|
+
url: image.url,
|
|
535
|
+
alt: image.alt || _pageTitle
|
|
536
|
+
}]
|
|
537
|
+
});
|
|
538
|
+
}
|
|
539
|
+
|
|
540
|
+
// Add metadata list (keywords, sections, parts, and exports combined)
|
|
541
|
+
var hasKeywords = keywords.length > 0;
|
|
542
|
+
var hasSections = _page.sections && Object.keys(_page.sections).length > 0;
|
|
543
|
+
var hasParts = _page.parts && Object.keys(_page.parts).length > 0;
|
|
544
|
+
var hasExports = _page.exports && Object.keys(_page.exports).length > 0;
|
|
545
|
+
if (hasKeywords || hasSections || hasParts || hasExports) {
|
|
546
|
+
var metadataListItems = [];
|
|
547
|
+
if (hasKeywords) {
|
|
548
|
+
metadataListItems.push({
|
|
549
|
+
type: 'listItem',
|
|
550
|
+
children: [paragraph("Keywords: ".concat(keywords.join(', ')))]
|
|
551
|
+
});
|
|
552
|
+
}
|
|
553
|
+
if (hasSections && _page.sections) {
|
|
554
|
+
var sectionListItems = headingHierarchyToListNodes(_page.sections, _page.path);
|
|
555
|
+
metadataListItems.push({
|
|
556
|
+
type: 'listItem',
|
|
557
|
+
children: [paragraph('Sections:'), {
|
|
558
|
+
type: 'list',
|
|
559
|
+
ordered: false,
|
|
560
|
+
children: sectionListItems
|
|
561
|
+
}]
|
|
562
|
+
});
|
|
563
|
+
}
|
|
564
|
+
if (hasParts || hasExports) {
|
|
565
|
+
var exportsListItems = [];
|
|
566
|
+
|
|
567
|
+
// First, add all parts with their metadata (use dash format)
|
|
568
|
+
if (hasParts && _page.parts) {
|
|
569
|
+
for (var _i3 = 0, _Object$entries = Object.entries(_page.parts); _i3 < _Object$entries.length; _i3++) {
|
|
570
|
+
var _Object$entries$_i = _slicedToArray(_Object$entries[_i3], 2),
|
|
571
|
+
partName = _Object$entries$_i[0],
|
|
572
|
+
partMetadata = _Object$entries$_i[1];
|
|
573
|
+
var partListItems = [];
|
|
574
|
+
if (partMetadata.props && partMetadata.props.length > 0) {
|
|
575
|
+
partListItems.push({
|
|
576
|
+
type: 'listItem',
|
|
577
|
+
children: [paragraph("Props: ".concat(partMetadata.props.join(', ')))]
|
|
578
|
+
});
|
|
579
|
+
}
|
|
580
|
+
if (partMetadata.dataAttributes && partMetadata.dataAttributes.length > 0) {
|
|
581
|
+
partListItems.push({
|
|
582
|
+
type: 'listItem',
|
|
583
|
+
children: [paragraph("Data Attributes: ".concat(partMetadata.dataAttributes.join(', ')))]
|
|
584
|
+
});
|
|
585
|
+
}
|
|
586
|
+
if (partMetadata.cssVariables && partMetadata.cssVariables.length > 0) {
|
|
587
|
+
partListItems.push({
|
|
588
|
+
type: 'listItem',
|
|
589
|
+
children: [paragraph("CSS Variables: ".concat(partMetadata.cssVariables.join(', ')))]
|
|
590
|
+
});
|
|
591
|
+
}
|
|
592
|
+
|
|
593
|
+
// Add the part with dash separator
|
|
594
|
+
if (partListItems.length > 0) {
|
|
595
|
+
exportsListItems.push({
|
|
596
|
+
type: 'listItem',
|
|
597
|
+
children: [{
|
|
598
|
+
type: 'paragraph',
|
|
599
|
+
children: [{
|
|
600
|
+
type: 'text',
|
|
601
|
+
value: "".concat(_page.title, " - ").concat(partName)
|
|
602
|
+
}]
|
|
603
|
+
}, {
|
|
604
|
+
type: 'list',
|
|
605
|
+
ordered: false,
|
|
606
|
+
children: partListItems
|
|
607
|
+
}]
|
|
608
|
+
});
|
|
609
|
+
} else {
|
|
610
|
+
// Part with no properties - just add the part name with dash
|
|
611
|
+
exportsListItems.push({
|
|
612
|
+
type: 'listItem',
|
|
613
|
+
children: [{
|
|
614
|
+
type: 'paragraph',
|
|
615
|
+
children: [{
|
|
616
|
+
type: 'text',
|
|
617
|
+
value: "".concat(_page.title, " - ").concat(partName)
|
|
618
|
+
}]
|
|
619
|
+
}]
|
|
620
|
+
});
|
|
621
|
+
}
|
|
622
|
+
}
|
|
623
|
+
}
|
|
624
|
+
|
|
625
|
+
// Then add all exports with their metadata (no dash format)
|
|
626
|
+
if (hasExports && _page.exports) {
|
|
627
|
+
for (var _i4 = 0, _Object$entries2 = Object.entries(_page.exports); _i4 < _Object$entries2.length; _i4++) {
|
|
628
|
+
var _Object$entries2$_i = _slicedToArray(_Object$entries2[_i4], 2),
|
|
629
|
+
exportName = _Object$entries2$_i[0],
|
|
630
|
+
exportMetadata = _Object$entries2$_i[1];
|
|
631
|
+
var exportListItems = [];
|
|
632
|
+
if (exportMetadata.props && exportMetadata.props.length > 0) {
|
|
633
|
+
exportListItems.push({
|
|
634
|
+
type: 'listItem',
|
|
635
|
+
children: [paragraph("Props: ".concat(exportMetadata.props.join(', ')))]
|
|
636
|
+
});
|
|
637
|
+
}
|
|
638
|
+
if (exportMetadata.dataAttributes && exportMetadata.dataAttributes.length > 0) {
|
|
639
|
+
exportListItems.push({
|
|
640
|
+
type: 'listItem',
|
|
641
|
+
children: [paragraph("Data Attributes: ".concat(exportMetadata.dataAttributes.join(', ')))]
|
|
642
|
+
});
|
|
643
|
+
}
|
|
644
|
+
if (exportMetadata.cssVariables && exportMetadata.cssVariables.length > 0) {
|
|
645
|
+
exportListItems.push({
|
|
646
|
+
type: 'listItem',
|
|
647
|
+
children: [paragraph("CSS Variables: ".concat(exportMetadata.cssVariables.join(', ')))]
|
|
648
|
+
});
|
|
649
|
+
}
|
|
650
|
+
|
|
651
|
+
// Always add the export, even if it has no properties
|
|
652
|
+
if (exportListItems.length > 0) {
|
|
653
|
+
exportsListItems.push({
|
|
654
|
+
type: 'listItem',
|
|
655
|
+
children: [{
|
|
656
|
+
type: 'paragraph',
|
|
657
|
+
children: [{
|
|
658
|
+
type: 'text',
|
|
659
|
+
value: exportName
|
|
660
|
+
}]
|
|
661
|
+
}, {
|
|
662
|
+
type: 'list',
|
|
663
|
+
ordered: false,
|
|
664
|
+
children: exportListItems
|
|
665
|
+
}]
|
|
666
|
+
});
|
|
667
|
+
} else {
|
|
668
|
+
// Export with no properties - just add the export name
|
|
669
|
+
exportsListItems.push({
|
|
670
|
+
type: 'listItem',
|
|
671
|
+
children: [{
|
|
672
|
+
type: 'paragraph',
|
|
673
|
+
children: [{
|
|
674
|
+
type: 'text',
|
|
675
|
+
value: exportName
|
|
676
|
+
}]
|
|
677
|
+
}]
|
|
678
|
+
});
|
|
679
|
+
}
|
|
680
|
+
}
|
|
681
|
+
}
|
|
682
|
+
if (exportsListItems.length > 0) {
|
|
683
|
+
metadataListItems.push({
|
|
684
|
+
type: 'listItem',
|
|
685
|
+
children: [paragraph('Exports:'), {
|
|
686
|
+
type: 'list',
|
|
687
|
+
ordered: false,
|
|
688
|
+
children: exportsListItems
|
|
689
|
+
}]
|
|
690
|
+
});
|
|
691
|
+
}
|
|
692
|
+
}
|
|
693
|
+
|
|
694
|
+
// Wrap metadata in details/summary tags
|
|
695
|
+
children.push({
|
|
696
|
+
type: 'html',
|
|
697
|
+
value: '<details>'
|
|
698
|
+
});
|
|
699
|
+
children.push(paragraph(''));
|
|
700
|
+
children.push({
|
|
701
|
+
type: 'html',
|
|
702
|
+
value: '<summary>Outline</summary>'
|
|
703
|
+
});
|
|
704
|
+
children.push(paragraph(''));
|
|
705
|
+
children.push({
|
|
706
|
+
type: 'list',
|
|
707
|
+
ordered: false,
|
|
708
|
+
children: metadataListItems
|
|
709
|
+
});
|
|
710
|
+
children.push(paragraph(''));
|
|
711
|
+
children.push({
|
|
712
|
+
type: 'html',
|
|
713
|
+
value: '</details>'
|
|
714
|
+
});
|
|
715
|
+
}
|
|
716
|
+
|
|
717
|
+
// Add embeddings as a comment if available
|
|
718
|
+
if (_page.embeddings && _page.embeddings.length > 0) {
|
|
719
|
+
children.push(comment("Embeddings: ".concat(JSON.stringify(_page.embeddings))));
|
|
720
|
+
}
|
|
721
|
+
|
|
722
|
+
// Add read more link
|
|
723
|
+
children.push(paragraph([link(_page.path, 'Read more')]));
|
|
724
|
+
}
|
|
725
|
+
|
|
726
|
+
// Close wrapper component if provided
|
|
727
|
+
} catch (err) {
|
|
728
|
+
_iterator6.e(err);
|
|
729
|
+
} finally {
|
|
730
|
+
_iterator6.f();
|
|
731
|
+
}
|
|
732
|
+
if (indexWrapperComponent) {
|
|
733
|
+
children.push({
|
|
734
|
+
type: 'html',
|
|
735
|
+
value: "</".concat(indexWrapperComponent, ">")
|
|
736
|
+
});
|
|
737
|
+
}
|
|
738
|
+
|
|
739
|
+
// Add metadata export at the end
|
|
740
|
+
children.push(comment('This file is autogenerated, but the following metadata can be modified.'));
|
|
741
|
+
var metadataCode;
|
|
742
|
+
if (pageMetadata && Object.keys(pageMetadata).length > 0) {
|
|
743
|
+
metadataCode = "export const metadata = ".concat(JSON.stringify(pageMetadata, null, 2), ";");
|
|
744
|
+
} else {
|
|
745
|
+
// Default metadata with robots noindex
|
|
746
|
+
metadataCode = "export const metadata = {\n robots: {\n index: false,\n },\n};";
|
|
747
|
+
}
|
|
748
|
+
// Output as raw MDX/JSX code (mdxjsEsm node type)
|
|
749
|
+
children.push({
|
|
750
|
+
type: 'mdxjsEsm',
|
|
751
|
+
value: metadataCode
|
|
752
|
+
});
|
|
753
|
+
return {
|
|
754
|
+
type: 'root',
|
|
755
|
+
children: children
|
|
756
|
+
};
|
|
757
|
+
}
|
|
758
|
+
|
|
759
|
+
/**
|
|
760
|
+
* Converts an array of page metadata into the markdown format (string)
|
|
761
|
+
*/
|
|
762
|
+
export function metadataToMarkdown(data) {
|
|
763
|
+
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
764
|
+
// Support legacy signature where second param was editableMarker string
|
|
765
|
+
var normalizedOptions = typeof options === 'string' ? {
|
|
766
|
+
editableMarker: options
|
|
767
|
+
} : options;
|
|
768
|
+
var editableMarker = normalizedOptions.editableMarker,
|
|
769
|
+
indexWrapperComponent = normalizedOptions.indexWrapperComponent,
|
|
770
|
+
path = normalizedOptions.path;
|
|
771
|
+
var title = data.title,
|
|
772
|
+
description = data.description,
|
|
773
|
+
pages = data.pages,
|
|
774
|
+
pageMetadata = data.pageMetadata;
|
|
775
|
+
var lines = [];
|
|
776
|
+
|
|
777
|
+
// Add main title
|
|
778
|
+
lines.push("# ".concat(title));
|
|
779
|
+
lines.push('');
|
|
780
|
+
|
|
781
|
+
// Add description if provided (editable section)
|
|
782
|
+
if (description) {
|
|
783
|
+
lines.push(description);
|
|
784
|
+
lines.push('');
|
|
785
|
+
}
|
|
786
|
+
|
|
787
|
+
// Add editable section marker
|
|
788
|
+
var marker = editableMarker != null ? editableMarker : "[//]: # 'This file is autogenerated, but the following list can be modified.'";
|
|
789
|
+
lines.push(marker);
|
|
790
|
+
lines.push('');
|
|
791
|
+
|
|
792
|
+
// Open wrapper component if provided
|
|
793
|
+
if (indexWrapperComponent) {
|
|
794
|
+
lines.push("<".concat(indexWrapperComponent, ">"));
|
|
795
|
+
lines.push('');
|
|
796
|
+
}
|
|
797
|
+
|
|
798
|
+
// Add page list (editable section)
|
|
799
|
+
var _iterator9 = _createForOfIteratorHelper(pages),
|
|
800
|
+
_step9;
|
|
801
|
+
try {
|
|
802
|
+
for (_iterator9.s(); !(_step9 = _iterator9.n()).done;) {
|
|
803
|
+
var _page$openGraph5;
|
|
804
|
+
var page = _step9.value;
|
|
805
|
+
var pageTitle = ((_page$openGraph5 = page.openGraph) == null ? void 0 : _page$openGraph5.title) || page.title || page.slug;
|
|
806
|
+
|
|
807
|
+
// Check if this is a single-link entry (external link or no detail section)
|
|
808
|
+
var isSingleLink = page.skipDetailSection || false;
|
|
809
|
+
var line = void 0;
|
|
810
|
+
if (isSingleLink) {
|
|
811
|
+
// Format: - [Title](./path) [Tag1] [Tag2]
|
|
812
|
+
line = "- [".concat(pageTitle, "](").concat(page.path, ")");
|
|
813
|
+
|
|
814
|
+
// Add tags if present (directly after link)
|
|
815
|
+
if (page.tags && page.tags.length > 0) {
|
|
816
|
+
var _iterator1 = _createForOfIteratorHelper(page.tags),
|
|
817
|
+
_step1;
|
|
818
|
+
try {
|
|
819
|
+
for (_iterator1.s(); !(_step1 = _iterator1.n()).done;) {
|
|
820
|
+
var tag = _step1.value;
|
|
821
|
+
line += " [".concat(tag, "]");
|
|
822
|
+
}
|
|
823
|
+
} catch (err) {
|
|
824
|
+
_iterator1.e(err);
|
|
825
|
+
} finally {
|
|
826
|
+
_iterator1.f();
|
|
827
|
+
}
|
|
828
|
+
}
|
|
829
|
+
} else {
|
|
830
|
+
// Format: - [Title](#slug) [Tag1] [Tag2] - [Full Docs](./path/page.mdx)
|
|
831
|
+
line = "- [".concat(pageTitle, "](#").concat(page.slug, ")");
|
|
832
|
+
|
|
833
|
+
// Add tags if present (directly after component name)
|
|
834
|
+
if (page.tags && page.tags.length > 0) {
|
|
835
|
+
var _iterator10 = _createForOfIteratorHelper(page.tags),
|
|
836
|
+
_step10;
|
|
837
|
+
try {
|
|
838
|
+
for (_iterator10.s(); !(_step10 = _iterator10.n()).done;) {
|
|
839
|
+
var _tag2 = _step10.value;
|
|
840
|
+
line += " [".concat(_tag2, "]");
|
|
841
|
+
}
|
|
842
|
+
} catch (err) {
|
|
843
|
+
_iterator10.e(err);
|
|
844
|
+
} finally {
|
|
845
|
+
_iterator10.f();
|
|
846
|
+
}
|
|
847
|
+
}
|
|
848
|
+
|
|
849
|
+
// Add separator and Full Docs link
|
|
850
|
+
line += " - [Full Docs](".concat(page.path, ")");
|
|
851
|
+
}
|
|
852
|
+
lines.push(line);
|
|
853
|
+
}
|
|
854
|
+
} catch (err) {
|
|
855
|
+
_iterator9.e(err);
|
|
856
|
+
} finally {
|
|
857
|
+
_iterator9.f();
|
|
858
|
+
}
|
|
859
|
+
lines.push('');
|
|
860
|
+
|
|
861
|
+
// Add non-editable section marker
|
|
862
|
+
// Trim common prefixes and suffixes from path, quote if contains parentheses for shell safety
|
|
863
|
+
var trimmedPath = path == null ? void 0 : path.replace(/^(src\/app\/|app\/)/, '').replace(/\/page\.mdx$/, '');
|
|
864
|
+
var quotedPath = trimmedPath && /[()]/.test(trimmedPath) ? "\"".concat(trimmedPath, "\"") : trimmedPath;
|
|
865
|
+
var doNotEditMarker = quotedPath ? "[//]: # 'This file is autogenerated, DO NOT EDIT AFTER THIS LINE, run: pnpm docs:validate ".concat(quotedPath, "'") : "[//]: # 'This file is autogenerated, DO NOT EDIT AFTER THIS LINE'";
|
|
866
|
+
lines.push(doNotEditMarker);
|
|
867
|
+
lines.push('');
|
|
868
|
+
|
|
869
|
+
// Add detailed page sections (non-editable)
|
|
870
|
+
var _iterator0 = _createForOfIteratorHelper(pages),
|
|
871
|
+
_step0;
|
|
872
|
+
try {
|
|
873
|
+
for (_iterator0.s(); !(_step0 = _iterator0.n()).done;) {
|
|
874
|
+
var _page2$openGraph, _page2$openGraph3;
|
|
875
|
+
var _page2 = _step0.value;
|
|
876
|
+
// Skip detail section for single-link entries (external links)
|
|
877
|
+
if (_page2.skipDetailSection) {
|
|
878
|
+
continue;
|
|
879
|
+
}
|
|
880
|
+
var _pageTitle2 = ((_page2$openGraph = _page2.openGraph) == null ? void 0 : _page2$openGraph.title) || _page2.title || _page2.slug;
|
|
881
|
+
// Use descriptionMarkdown to preserve formatting if available
|
|
882
|
+
// Note: We don't replace newlines here to allow natural line breaks in detailed sections
|
|
883
|
+
var pageDescription = void 0;
|
|
884
|
+
if (_page2.descriptionMarkdown && _page2.descriptionMarkdown.length > 0) {
|
|
885
|
+
pageDescription = astNodesToMarkdown(_page2.descriptionMarkdown);
|
|
886
|
+
} else {
|
|
887
|
+
var _page2$openGraph2;
|
|
888
|
+
pageDescription = ((_page2$openGraph2 = _page2.openGraph) == null ? void 0 : _page2$openGraph2.description) || _page2.description || 'No description available';
|
|
889
|
+
}
|
|
890
|
+
var keywords = _page2.keywords || [];
|
|
891
|
+
var image = (_page2$openGraph3 = _page2.openGraph) == null || (_page2$openGraph3 = _page2$openGraph3.images) == null ? void 0 : _page2$openGraph3[0];
|
|
892
|
+
|
|
893
|
+
// Add page heading
|
|
894
|
+
lines.push("## ".concat(_pageTitle2));
|
|
895
|
+
lines.push('');
|
|
896
|
+
|
|
897
|
+
// Add description
|
|
898
|
+
lines.push(pageDescription);
|
|
899
|
+
lines.push('');
|
|
900
|
+
|
|
901
|
+
// Add image if available
|
|
902
|
+
if (image) {
|
|
903
|
+
lines.push(".concat(image.url, ")"));
|
|
904
|
+
lines.push('');
|
|
905
|
+
}
|
|
906
|
+
|
|
907
|
+
// Add metadata list (keywords, sections, parts, and exports)
|
|
908
|
+
var hasKeywords = keywords.length > 0;
|
|
909
|
+
var hasSections = _page2.sections && Object.keys(_page2.sections).length > 0;
|
|
910
|
+
var hasParts = _page2.parts && Object.keys(_page2.parts).length > 0;
|
|
911
|
+
var hasExports = _page2.exports && Object.keys(_page2.exports).length > 0;
|
|
912
|
+
|
|
913
|
+
// Track if we actually add any metadata content
|
|
914
|
+
var hasMetadataContent = false;
|
|
915
|
+
if (hasKeywords || hasSections || hasParts || hasExports) {
|
|
916
|
+
lines.push('<details>');
|
|
917
|
+
lines.push('');
|
|
918
|
+
lines.push('<summary>Outline</summary>');
|
|
919
|
+
lines.push('');
|
|
920
|
+
if (hasKeywords) {
|
|
921
|
+
lines.push("- Keywords: ".concat(keywords.join(', ')));
|
|
922
|
+
hasMetadataContent = true;
|
|
923
|
+
}
|
|
924
|
+
if (hasSections && _page2.sections) {
|
|
925
|
+
var sectionLines = headingHierarchyToMarkdown(_page2.sections, _page2.path, 1); // Start at depth 1 for indentation
|
|
926
|
+
lines.push('- Sections:');
|
|
927
|
+
lines.push(sectionLines.trimEnd());
|
|
928
|
+
hasMetadataContent = true;
|
|
929
|
+
}
|
|
930
|
+
// Handle both parts and exports
|
|
931
|
+
// Parts and exports are combined into a single "Exports:" section
|
|
932
|
+
// Parts use format "ComponentName - PartName" (written with dash)
|
|
933
|
+
// Exports use just "ExportName" (written without dash)
|
|
934
|
+
if (hasParts || hasExports) {
|
|
935
|
+
lines.push('- Exports:');
|
|
936
|
+
|
|
937
|
+
// First, list all parts with their metadata (use dash format)
|
|
938
|
+
if (hasParts && _page2.parts) {
|
|
939
|
+
for (var _i5 = 0, _Object$entries3 = Object.entries(_page2.parts); _i5 < _Object$entries3.length; _i5++) {
|
|
940
|
+
var _Object$entries3$_i = _slicedToArray(_Object$entries3[_i5], 2),
|
|
941
|
+
partName = _Object$entries3$_i[0],
|
|
942
|
+
partMetadata = _Object$entries3$_i[1];
|
|
943
|
+
var hasProps = partMetadata.props && partMetadata.props.length > 0;
|
|
944
|
+
var hasDataAttributes = partMetadata.dataAttributes && partMetadata.dataAttributes.length > 0;
|
|
945
|
+
var hasCssVariables = partMetadata.cssVariables && partMetadata.cssVariables.length > 0;
|
|
946
|
+
lines.push(" - ".concat(_page2.title, " - ").concat(partName));
|
|
947
|
+
if (hasProps) {
|
|
948
|
+
lines.push(" - Props: ".concat(partMetadata.props.join(', ')));
|
|
949
|
+
}
|
|
950
|
+
if (hasDataAttributes) {
|
|
951
|
+
lines.push(" - Data Attributes: ".concat(partMetadata.dataAttributes.join(', ')));
|
|
952
|
+
}
|
|
953
|
+
if (hasCssVariables) {
|
|
954
|
+
lines.push(" - CSS Variables: ".concat(partMetadata.cssVariables.join(', ')));
|
|
955
|
+
}
|
|
956
|
+
}
|
|
957
|
+
}
|
|
958
|
+
|
|
959
|
+
// Then list all exports with their metadata (no dash format)
|
|
960
|
+
if (hasExports && _page2.exports) {
|
|
961
|
+
for (var _i6 = 0, _Object$entries4 = Object.entries(_page2.exports); _i6 < _Object$entries4.length; _i6++) {
|
|
962
|
+
var _Object$entries4$_i = _slicedToArray(_Object$entries4[_i6], 2),
|
|
963
|
+
exportName = _Object$entries4$_i[0],
|
|
964
|
+
exportMetadata = _Object$entries4$_i[1];
|
|
965
|
+
var _hasProps = exportMetadata.props && exportMetadata.props.length > 0;
|
|
966
|
+
var _hasDataAttributes = exportMetadata.dataAttributes && exportMetadata.dataAttributes.length > 0;
|
|
967
|
+
var _hasCssVariables = exportMetadata.cssVariables && exportMetadata.cssVariables.length > 0;
|
|
968
|
+
lines.push(" - ".concat(exportName));
|
|
969
|
+
if (_hasProps) {
|
|
970
|
+
lines.push(" - Props: ".concat(exportMetadata.props.join(', ')));
|
|
971
|
+
}
|
|
972
|
+
if (_hasDataAttributes) {
|
|
973
|
+
lines.push(" - Data Attributes: ".concat(exportMetadata.dataAttributes.join(', ')));
|
|
974
|
+
}
|
|
975
|
+
if (_hasCssVariables) {
|
|
976
|
+
lines.push(" - CSS Variables: ".concat(exportMetadata.cssVariables.join(', ')));
|
|
977
|
+
}
|
|
978
|
+
}
|
|
979
|
+
}
|
|
980
|
+
hasMetadataContent = true;
|
|
981
|
+
}
|
|
982
|
+
lines.push('');
|
|
983
|
+
lines.push('</details>');
|
|
984
|
+
// Only add blank line if we actually added metadata content
|
|
985
|
+
if (hasMetadataContent) {
|
|
986
|
+
lines.push('');
|
|
987
|
+
}
|
|
988
|
+
}
|
|
989
|
+
|
|
990
|
+
// Add embeddings as a comment if available
|
|
991
|
+
if (_page2.embeddings && _page2.embeddings.length > 0) {
|
|
992
|
+
lines.push("[//]: # 'Embeddings: ".concat(JSON.stringify(_page2.embeddings), "'"));
|
|
993
|
+
lines.push('');
|
|
994
|
+
}
|
|
995
|
+
|
|
996
|
+
// Add read more link
|
|
997
|
+
lines.push("[Read more](".concat(_page2.path, ")"));
|
|
998
|
+
lines.push('');
|
|
999
|
+
}
|
|
1000
|
+
|
|
1001
|
+
// Close wrapper component if provided
|
|
1002
|
+
} catch (err) {
|
|
1003
|
+
_iterator0.e(err);
|
|
1004
|
+
} finally {
|
|
1005
|
+
_iterator0.f();
|
|
1006
|
+
}
|
|
1007
|
+
if (indexWrapperComponent) {
|
|
1008
|
+
lines.push("</".concat(indexWrapperComponent, ">"));
|
|
1009
|
+
lines.push('');
|
|
1010
|
+
}
|
|
1011
|
+
|
|
1012
|
+
// Add metadata export at the end
|
|
1013
|
+
lines.push("[//]: # 'This file is autogenerated, but the following metadata can be modified.'");
|
|
1014
|
+
lines.push('');
|
|
1015
|
+
if (pageMetadata && Object.keys(pageMetadata).length > 0) {
|
|
1016
|
+
lines.push("export const metadata = ".concat(JSON.stringify(pageMetadata, null, 2), ";"));
|
|
1017
|
+
} else {
|
|
1018
|
+
// Default metadata with robots noindex
|
|
1019
|
+
lines.push("export const metadata = {\n robots: {\n index: false,\n },\n};");
|
|
1020
|
+
}
|
|
1021
|
+
lines.push('');
|
|
1022
|
+
|
|
1023
|
+
// Remove trailing empty line
|
|
1024
|
+
return "".concat(lines.join('\n').trimEnd(), "\n");
|
|
1025
|
+
}
|
|
1026
|
+
|
|
1027
|
+
/**
|
|
1028
|
+
* Parses markdown content and extracts page metadata using unified
|
|
1029
|
+
*/
|
|
1030
|
+
export function markdownToMetadata(_x) {
|
|
1031
|
+
return _markdownToMetadata.apply(this, arguments);
|
|
1032
|
+
}
|
|
1033
|
+
|
|
1034
|
+
/**
|
|
1035
|
+
* Extracts plain text content from any mdast node without markdown formatting
|
|
1036
|
+
* Used for titles and other places where we don't want markdown syntax
|
|
1037
|
+
*/
|
|
1038
|
+
function _markdownToMetadata() {
|
|
1039
|
+
_markdownToMetadata = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(markdown) {
|
|
1040
|
+
var tree, title, description, pageMetadata, indexWrapperComponent, pages, currentSection, currentPage, metadataExportMatch, partialPage, foundIndex;
|
|
1041
|
+
return _regenerator().w(function (_context) {
|
|
1042
|
+
while (1) switch (_context.n) {
|
|
1043
|
+
case 0:
|
|
1044
|
+
tree = unified().use(remarkParse).parse(markdown);
|
|
1045
|
+
title = null;
|
|
1046
|
+
pages = [];
|
|
1047
|
+
currentSection = 'header';
|
|
1048
|
+
currentPage = null; // Visit all nodes in the AST
|
|
1049
|
+
visit(tree, function (node, index, parent) {
|
|
1050
|
+
// Track sections based on definition nodes (HTML-style comments)
|
|
1051
|
+
if (node.type === 'definition') {
|
|
1052
|
+
var _defNode$title, _defNode$title2, _defNode$title3, _defNode$title4;
|
|
1053
|
+
var defNode = node;
|
|
1054
|
+
if ((_defNode$title = defNode.title) != null && _defNode$title.includes('following list can be modified')) {
|
|
1055
|
+
currentSection = 'editable';
|
|
1056
|
+
return;
|
|
1057
|
+
}
|
|
1058
|
+
if ((_defNode$title2 = defNode.title) != null && _defNode$title2.includes('DO NOT EDIT AFTER THIS LINE')) {
|
|
1059
|
+
currentSection = 'details';
|
|
1060
|
+
return;
|
|
1061
|
+
}
|
|
1062
|
+
if ((_defNode$title3 = defNode.title) != null && _defNode$title3.includes('following metadata can be modified')) {
|
|
1063
|
+
currentSection = 'metadata';
|
|
1064
|
+
return;
|
|
1065
|
+
}
|
|
1066
|
+
// Parse embeddings from comment
|
|
1067
|
+
if (currentPage && (_defNode$title4 = defNode.title) != null && _defNode$title4.includes('Embeddings:')) {
|
|
1068
|
+
var embeddingsText = defNode.title.replace('Embeddings:', '').trim();
|
|
1069
|
+
try {
|
|
1070
|
+
currentPage.embeddings = JSON.parse(embeddingsText);
|
|
1071
|
+
} catch (error) {
|
|
1072
|
+
console.error('Failed to parse embeddings:', error);
|
|
1073
|
+
}
|
|
1074
|
+
return;
|
|
1075
|
+
}
|
|
1076
|
+
}
|
|
1077
|
+
|
|
1078
|
+
// Extract wrapper component from HTML nodes (e.g., <PagesIndex>)
|
|
1079
|
+
if (node.type === 'html' && !indexWrapperComponent) {
|
|
1080
|
+
var htmlNode = node;
|
|
1081
|
+
// Match opening tag like <PagesIndex> or <ComponentsIndex>
|
|
1082
|
+
var openingTagMatch = htmlNode.value.match(/^<([A-Z][a-zA-Z0-9]*)>$/);
|
|
1083
|
+
if (openingTagMatch) {
|
|
1084
|
+
indexWrapperComponent = openingTagMatch[1];
|
|
1085
|
+
}
|
|
1086
|
+
}
|
|
1087
|
+
|
|
1088
|
+
// Extract main title (H1)
|
|
1089
|
+
if (node.type === 'heading') {
|
|
1090
|
+
var headingNode = node;
|
|
1091
|
+
if (headingNode.depth === 1) {
|
|
1092
|
+
title = extractPlainTextFromNode(headingNode);
|
|
1093
|
+
currentSection = 'header';
|
|
1094
|
+
return;
|
|
1095
|
+
}
|
|
1096
|
+
}
|
|
1097
|
+
|
|
1098
|
+
// Parse description in header section (paragraph after H1, before editable marker)
|
|
1099
|
+
if (currentSection === 'header' && node.type === 'paragraph' && (parent == null ? void 0 : parent.type) === 'root') {
|
|
1100
|
+
var paragraphNode = node;
|
|
1101
|
+
var paragraphText = extractPlainTextFromNode(paragraphNode);
|
|
1102
|
+
if (paragraphText && !description) {
|
|
1103
|
+
description = paragraphText;
|
|
1104
|
+
}
|
|
1105
|
+
return;
|
|
1106
|
+
}
|
|
1107
|
+
|
|
1108
|
+
// Parse editable list items - check if we're in a paragraph that's a child of a listItem
|
|
1109
|
+
if (currentSection === 'editable' && node.type === 'paragraph' && (parent == null ? void 0 : parent.type) === 'listItem') {
|
|
1110
|
+
var _paragraphNode = node;
|
|
1111
|
+
if (_paragraphNode.children) {
|
|
1112
|
+
// Look for links in the paragraph
|
|
1113
|
+
var links = _paragraphNode.children.filter(function (child) {
|
|
1114
|
+
return child.type === 'link';
|
|
1115
|
+
});
|
|
1116
|
+
if (links.length === 0) {
|
|
1117
|
+
// No links found, skip this item
|
|
1118
|
+
return;
|
|
1119
|
+
}
|
|
1120
|
+
if (links.length === 1) {
|
|
1121
|
+
// Single link format: - [Title](./path) [Tag1] [Tag2]
|
|
1122
|
+
// This is for external links or pages that don't have detail sections
|
|
1123
|
+
var singleLink = links[0];
|
|
1124
|
+
var pageTitle = extractPlainTextFromNode(singleLink);
|
|
1125
|
+
var path = singleLink.url;
|
|
1126
|
+
|
|
1127
|
+
// Generate slug from title for consistency
|
|
1128
|
+
var slug = titleToSlug(pageTitle);
|
|
1129
|
+
|
|
1130
|
+
// Extract tags from text nodes after the link
|
|
1131
|
+
// Tags are in the format [Tag] where Tag can be New, Hot, Beta, External, etc.
|
|
1132
|
+
var tags = [];
|
|
1133
|
+
var foundLink = false;
|
|
1134
|
+
var _iterator11 = _createForOfIteratorHelper(_paragraphNode.children),
|
|
1135
|
+
_step11;
|
|
1136
|
+
try {
|
|
1137
|
+
for (_iterator11.s(); !(_step11 = _iterator11.n()).done;) {
|
|
1138
|
+
var child = _step11.value;
|
|
1139
|
+
if (child === singleLink) {
|
|
1140
|
+
foundLink = true;
|
|
1141
|
+
continue;
|
|
1142
|
+
}
|
|
1143
|
+
if (foundLink && child.type === 'text') {
|
|
1144
|
+
// Match [Tag] patterns in the text
|
|
1145
|
+
var tagRegex = /\[(\w+)\]/g;
|
|
1146
|
+
var match = tagRegex.exec(child.value);
|
|
1147
|
+
while (match !== null) {
|
|
1148
|
+
tags.push(match[1]);
|
|
1149
|
+
match = tagRegex.exec(child.value);
|
|
1150
|
+
}
|
|
1151
|
+
}
|
|
1152
|
+
}
|
|
1153
|
+
|
|
1154
|
+
// These entries are preserved as-is in the editable section
|
|
1155
|
+
// They won't have detail sections generated
|
|
1156
|
+
} catch (err) {
|
|
1157
|
+
_iterator11.e(err);
|
|
1158
|
+
} finally {
|
|
1159
|
+
_iterator11.f();
|
|
1160
|
+
}
|
|
1161
|
+
pages.push({
|
|
1162
|
+
slug: slug,
|
|
1163
|
+
path: path,
|
|
1164
|
+
title: pageTitle,
|
|
1165
|
+
description: 'No description available',
|
|
1166
|
+
tags: tags.length > 0 ? tags : undefined,
|
|
1167
|
+
skipDetailSection: true,
|
|
1168
|
+
// Mark as external/single-link entry
|
|
1169
|
+
openGraph: {
|
|
1170
|
+
title: pageTitle,
|
|
1171
|
+
description: 'No description available'
|
|
1172
|
+
}
|
|
1173
|
+
});
|
|
1174
|
+
} else if (links.length >= 2) {
|
|
1175
|
+
// Two-link format: - [Title](#slug) [Tag1] [Tag2] - [Full Docs](./path/page.mdx)
|
|
1176
|
+
var sectionLink = links[0];
|
|
1177
|
+
var docsLink = links[1];
|
|
1178
|
+
var _pageTitle3 = extractPlainTextFromNode(sectionLink);
|
|
1179
|
+
var _slug = sectionLink.url.replace('#', ''); // Extract slug from #slug
|
|
1180
|
+
var _path = docsLink.url; // Get path from full docs link
|
|
1181
|
+
|
|
1182
|
+
// Extract tags from text nodes between the section link and full docs link
|
|
1183
|
+
// Tags are in the format [Tag] where Tag can be New, Hot, Beta, etc.
|
|
1184
|
+
var _tags = [];
|
|
1185
|
+
var foundSectionLink = false;
|
|
1186
|
+
var foundDocsLink = false;
|
|
1187
|
+
var _iterator12 = _createForOfIteratorHelper(_paragraphNode.children),
|
|
1188
|
+
_step12;
|
|
1189
|
+
try {
|
|
1190
|
+
for (_iterator12.s(); !(_step12 = _iterator12.n()).done;) {
|
|
1191
|
+
var _child = _step12.value;
|
|
1192
|
+
if (_child === sectionLink) {
|
|
1193
|
+
foundSectionLink = true;
|
|
1194
|
+
continue;
|
|
1195
|
+
}
|
|
1196
|
+
if (_child === docsLink) {
|
|
1197
|
+
foundDocsLink = true;
|
|
1198
|
+
break;
|
|
1199
|
+
}
|
|
1200
|
+
if (foundSectionLink && !foundDocsLink && _child.type === 'text') {
|
|
1201
|
+
// Match [Tag] patterns in the text
|
|
1202
|
+
var _tagRegex = /\[(\w+)\]/g;
|
|
1203
|
+
var _match = _tagRegex.exec(_child.value);
|
|
1204
|
+
while (_match !== null) {
|
|
1205
|
+
_tags.push(_match[1]);
|
|
1206
|
+
_match = _tagRegex.exec(_child.value);
|
|
1207
|
+
}
|
|
1208
|
+
}
|
|
1209
|
+
}
|
|
1210
|
+
|
|
1211
|
+
// Only extract slug, path, title, and tags from the editable list
|
|
1212
|
+
// The description will be filled in from the details section
|
|
1213
|
+
} catch (err) {
|
|
1214
|
+
_iterator12.e(err);
|
|
1215
|
+
} finally {
|
|
1216
|
+
_iterator12.f();
|
|
1217
|
+
}
|
|
1218
|
+
pages.push({
|
|
1219
|
+
slug: _slug,
|
|
1220
|
+
path: _path,
|
|
1221
|
+
title: _pageTitle3,
|
|
1222
|
+
description: 'No description available',
|
|
1223
|
+
// Will be updated from details section
|
|
1224
|
+
tags: _tags.length > 0 ? _tags : undefined,
|
|
1225
|
+
openGraph: {
|
|
1226
|
+
title: _pageTitle3,
|
|
1227
|
+
description: 'No description available' // Will be updated from details section
|
|
1228
|
+
}
|
|
1229
|
+
});
|
|
1230
|
+
}
|
|
1231
|
+
}
|
|
1232
|
+
return;
|
|
1233
|
+
}
|
|
1234
|
+
|
|
1235
|
+
// Parse detail sections
|
|
1236
|
+
if (currentSection === 'details') {
|
|
1237
|
+
// Start of a new page section (H2)
|
|
1238
|
+
if (node.type === 'heading') {
|
|
1239
|
+
var _headingNode = node;
|
|
1240
|
+
if (_headingNode.depth === 2) {
|
|
1241
|
+
var _currentPage;
|
|
1242
|
+
// Save previous page if exists
|
|
1243
|
+
if ((_currentPage = currentPage) != null && _currentPage.slug) {
|
|
1244
|
+
var savedSlug = currentPage.slug;
|
|
1245
|
+
var foundIndex = pages.findIndex(function (c) {
|
|
1246
|
+
return c.slug === savedSlug;
|
|
1247
|
+
});
|
|
1248
|
+
if (foundIndex !== -1) {
|
|
1249
|
+
pages[foundIndex] = _extends(_extends({}, pages[foundIndex]), currentPage);
|
|
1250
|
+
}
|
|
1251
|
+
}
|
|
1252
|
+
var _pageTitle4 = extractPlainTextFromNode(_headingNode);
|
|
1253
|
+
// Find the page in the existing pages array by matching the title
|
|
1254
|
+
var existingPage = pages.find(function (p) {
|
|
1255
|
+
return p.title === _pageTitle4;
|
|
1256
|
+
});
|
|
1257
|
+
if (existingPage) {
|
|
1258
|
+
// Start updating this existing page
|
|
1259
|
+
currentPage = {
|
|
1260
|
+
slug: existingPage.slug,
|
|
1261
|
+
title: _pageTitle4
|
|
1262
|
+
};
|
|
1263
|
+
} else {
|
|
1264
|
+
// If no matching page found, create a new one with slug from title
|
|
1265
|
+
var _slug2 = titleToSlug(_pageTitle4);
|
|
1266
|
+
currentPage = {
|
|
1267
|
+
slug: _slug2,
|
|
1268
|
+
title: _pageTitle4
|
|
1269
|
+
};
|
|
1270
|
+
}
|
|
1271
|
+
return;
|
|
1272
|
+
}
|
|
1273
|
+
}
|
|
1274
|
+
|
|
1275
|
+
// Parse description (first paragraph after title) and keywords/sections
|
|
1276
|
+
if (currentPage && node.type === 'paragraph') {
|
|
1277
|
+
var _paragraphNode2 = node;
|
|
1278
|
+
var _paragraphText = extractTextFromNode(_paragraphNode2);
|
|
1279
|
+
|
|
1280
|
+
// Check if we're in a list item
|
|
1281
|
+
if ((parent == null ? void 0 : parent.type) === 'listItem') {
|
|
1282
|
+
// Parse keywords
|
|
1283
|
+
if (_paragraphText.startsWith('Keywords:')) {
|
|
1284
|
+
var keywordsText = _paragraphText.replace('Keywords:', '').trim();
|
|
1285
|
+
currentPage.keywords = keywordsText.split(',').map(function (k) {
|
|
1286
|
+
return k.trim();
|
|
1287
|
+
});
|
|
1288
|
+
return;
|
|
1289
|
+
}
|
|
1290
|
+
|
|
1291
|
+
// Parse exports - they're in a nested list within the same parent list item
|
|
1292
|
+
if (_paragraphText.startsWith('Exports:')) {
|
|
1293
|
+
var result = parseExportsFromListItem(parent);
|
|
1294
|
+
if (result.exports) {
|
|
1295
|
+
currentPage.exports = result.exports;
|
|
1296
|
+
}
|
|
1297
|
+
if (result.parts) {
|
|
1298
|
+
currentPage.parts = result.parts;
|
|
1299
|
+
}
|
|
1300
|
+
return;
|
|
1301
|
+
}
|
|
1302
|
+
|
|
1303
|
+
// Parse sections - now they're in a nested list within the same parent list item
|
|
1304
|
+
if (_paragraphText.startsWith('Sections:')) {
|
|
1305
|
+
var _listItem$children2;
|
|
1306
|
+
// Find the nested list within this list item
|
|
1307
|
+
var listItem = parent;
|
|
1308
|
+
var nestedList = (_listItem$children2 = listItem.children) == null ? void 0 : _listItem$children2.find(function (child) {
|
|
1309
|
+
return child.type === 'list';
|
|
1310
|
+
});
|
|
1311
|
+
if (nestedList && nestedList.children) {
|
|
1312
|
+
currentPage.sections = parseHeadingSections(nestedList);
|
|
1313
|
+
} else {
|
|
1314
|
+
currentPage.sections = {};
|
|
1315
|
+
}
|
|
1316
|
+
return;
|
|
1317
|
+
}
|
|
1318
|
+
}
|
|
1319
|
+
|
|
1320
|
+
// Skip read more links
|
|
1321
|
+
if (_paragraphText.startsWith('[Read more]')) {
|
|
1322
|
+
return;
|
|
1323
|
+
}
|
|
1324
|
+
|
|
1325
|
+
// Parse description (first paragraph after title, not in a list)
|
|
1326
|
+
if (!currentPage.description && (parent == null ? void 0 : parent.type) !== 'listItem') {
|
|
1327
|
+
currentPage.description = _paragraphText;
|
|
1328
|
+
// Store the AST nodes with position info stripped for clean serialization
|
|
1329
|
+
if (_paragraphNode2.children) {
|
|
1330
|
+
currentPage.descriptionMarkdown = stripPositions(_paragraphNode2.children);
|
|
1331
|
+
}
|
|
1332
|
+
if (!currentPage.openGraph) {
|
|
1333
|
+
currentPage.openGraph = {};
|
|
1334
|
+
}
|
|
1335
|
+
currentPage.openGraph.description = _paragraphText;
|
|
1336
|
+
return;
|
|
1337
|
+
}
|
|
1338
|
+
}
|
|
1339
|
+
|
|
1340
|
+
// Parse image
|
|
1341
|
+
if (currentPage && node.type === 'image') {
|
|
1342
|
+
var imageNode = node;
|
|
1343
|
+
if (!currentPage.openGraph) {
|
|
1344
|
+
currentPage.openGraph = {};
|
|
1345
|
+
}
|
|
1346
|
+
currentPage.openGraph.images = [{
|
|
1347
|
+
url: imageNode.url,
|
|
1348
|
+
width: 800,
|
|
1349
|
+
height: 600,
|
|
1350
|
+
alt: imageNode.alt || currentPage.title || currentPage.slug || ''
|
|
1351
|
+
}];
|
|
1352
|
+
return;
|
|
1353
|
+
}
|
|
1354
|
+
}
|
|
1355
|
+
|
|
1356
|
+
// Parse metadata export section (code block or raw export statement after metadata comment)
|
|
1357
|
+
if (currentSection === 'metadata' && node.type === 'code') {
|
|
1358
|
+
var codeNode = node;
|
|
1359
|
+
var codeValue = codeNode.value;
|
|
1360
|
+
// Parse the export const metadata = { ... } statement
|
|
1361
|
+
var metadataMatch = codeValue.match(/export\s+const\s+metadata\s*=\s*(\{[\s\S]*\})/);
|
|
1362
|
+
if (metadataMatch) {
|
|
1363
|
+
try {
|
|
1364
|
+
// Use Function constructor to safely parse the object literal
|
|
1365
|
+
// eslint-disable-next-line no-new-func
|
|
1366
|
+
pageMetadata = new Function("return ".concat(metadataMatch[1]))();
|
|
1367
|
+
} catch (error) {
|
|
1368
|
+
console.error('Failed to parse page metadata:', error);
|
|
1369
|
+
}
|
|
1370
|
+
}
|
|
1371
|
+
return;
|
|
1372
|
+
}
|
|
1373
|
+
});
|
|
1374
|
+
|
|
1375
|
+
// Also try to parse metadata from raw export statement in the markdown
|
|
1376
|
+
// This handles MDX files where the export is not in a code block
|
|
1377
|
+
metadataExportMatch = markdown.match(/\[\/\/\]: # 'This file is autogenerated, but the following metadata can be modified\.'\s*\n\s*\n\s*export\s+const\s+metadata\s*=\s*(\{[\s\S]*?\n\})/);
|
|
1378
|
+
if (metadataExportMatch && !pageMetadata) {
|
|
1379
|
+
try {
|
|
1380
|
+
// eslint-disable-next-line no-new-func
|
|
1381
|
+
pageMetadata = new Function("return ".concat(metadataExportMatch[1]))();
|
|
1382
|
+
} catch (error) {
|
|
1383
|
+
console.error('Failed to parse page metadata from raw export:', error);
|
|
1384
|
+
}
|
|
1385
|
+
}
|
|
1386
|
+
|
|
1387
|
+
// Save last page if exists
|
|
1388
|
+
if (currentPage) {
|
|
1389
|
+
partialPage = currentPage;
|
|
1390
|
+
if (partialPage.slug) {
|
|
1391
|
+
foundIndex = pages.findIndex(function (c) {
|
|
1392
|
+
return c.slug === partialPage.slug;
|
|
1393
|
+
});
|
|
1394
|
+
if (foundIndex !== -1) {
|
|
1395
|
+
pages[foundIndex] = _extends(_extends({}, pages[foundIndex]), partialPage);
|
|
1396
|
+
}
|
|
1397
|
+
}
|
|
1398
|
+
}
|
|
1399
|
+
if (title) {
|
|
1400
|
+
_context.n = 1;
|
|
1401
|
+
break;
|
|
1402
|
+
}
|
|
1403
|
+
return _context.a(2, null);
|
|
1404
|
+
case 1:
|
|
1405
|
+
return _context.a(2, {
|
|
1406
|
+
title: title,
|
|
1407
|
+
description: description,
|
|
1408
|
+
pages: pages,
|
|
1409
|
+
pageMetadata: pageMetadata,
|
|
1410
|
+
indexWrapperComponent: indexWrapperComponent
|
|
1411
|
+
});
|
|
1412
|
+
}
|
|
1413
|
+
}, _callee);
|
|
1414
|
+
}));
|
|
1415
|
+
return _markdownToMetadata.apply(this, arguments);
|
|
1416
|
+
}
|
|
1417
|
+
function extractPlainTextFromNode(node) {
|
|
1418
|
+
if (node.type === 'text') {
|
|
1419
|
+
return node.value;
|
|
1420
|
+
}
|
|
1421
|
+
if (node.type === 'inlineCode') {
|
|
1422
|
+
return node.value;
|
|
1423
|
+
}
|
|
1424
|
+
if (node.children) {
|
|
1425
|
+
var extractedText = node.children.map(function (child) {
|
|
1426
|
+
return extractPlainTextFromNode(child);
|
|
1427
|
+
}).join('');
|
|
1428
|
+
// For paragraph nodes, replace sequences of regular whitespace (spaces, tabs, newlines)
|
|
1429
|
+
// with a single space, but preserve non-breaking spaces and other special whitespace
|
|
1430
|
+
if (node.type === 'paragraph') {
|
|
1431
|
+
return extractedText.replace(/[ \t\n\r]+/g, ' ').trim();
|
|
1432
|
+
}
|
|
1433
|
+
return extractedText;
|
|
1434
|
+
}
|
|
1435
|
+
return '';
|
|
1436
|
+
}
|
|
1437
|
+
|
|
1438
|
+
/**
|
|
1439
|
+
* Extracts text content from any mdast node
|
|
1440
|
+
* Preserves markdown formatting like inline code and links
|
|
1441
|
+
*/
|
|
1442
|
+
function extractTextFromNode(node) {
|
|
1443
|
+
if (node.type === 'text') {
|
|
1444
|
+
return node.value;
|
|
1445
|
+
}
|
|
1446
|
+
if (node.type === 'inlineCode') {
|
|
1447
|
+
return "`".concat(node.value, "`");
|
|
1448
|
+
}
|
|
1449
|
+
if (node.type === 'link') {
|
|
1450
|
+
var linkText = node.children.map(function (child) {
|
|
1451
|
+
return extractTextFromNode(child);
|
|
1452
|
+
}).join('');
|
|
1453
|
+
return "[".concat(linkText, "](").concat(node.url, ")");
|
|
1454
|
+
}
|
|
1455
|
+
if (node.type === 'emphasis') {
|
|
1456
|
+
var emphasisText = node.children.map(function (child) {
|
|
1457
|
+
return extractTextFromNode(child);
|
|
1458
|
+
}).join('');
|
|
1459
|
+
return "*".concat(emphasisText, "*");
|
|
1460
|
+
}
|
|
1461
|
+
if (node.type === 'strong') {
|
|
1462
|
+
var strongText = node.children.map(function (child) {
|
|
1463
|
+
return extractTextFromNode(child);
|
|
1464
|
+
}).join('');
|
|
1465
|
+
return "**".concat(strongText, "**");
|
|
1466
|
+
}
|
|
1467
|
+
if (node.children) {
|
|
1468
|
+
var extractedText = node.children.map(function (child) {
|
|
1469
|
+
return extractTextFromNode(child);
|
|
1470
|
+
}).join('');
|
|
1471
|
+
// For paragraph nodes, replace sequences of regular whitespace (spaces, tabs, newlines)
|
|
1472
|
+
// with a single space, but preserve non-breaking spaces and other special whitespace
|
|
1473
|
+
if (node.type === 'paragraph') {
|
|
1474
|
+
return extractedText.replace(/[ \t\n\r]+/g, ' ').trim();
|
|
1475
|
+
}
|
|
1476
|
+
return extractedText;
|
|
1477
|
+
}
|
|
1478
|
+
return '';
|
|
1479
|
+
}
|
|
1480
|
+
|
|
1481
|
+
/**
|
|
1482
|
+
* Converts a title to a slug (simple version)
|
|
1483
|
+
*/
|
|
1484
|
+
function titleToSlug(title) {
|
|
1485
|
+
return title.toLowerCase().replace(/[^a-z0-9]+/g, '-').replace(/^-+|-+$/g, '');
|
|
1486
|
+
}
|