@mui/internal-docs-infra 0.2.3-canary.9 → 0.3.1-canary.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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} +141 -55
- 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 +94 -16
- package/esm/pipeline/loadPrecomputedCodeHighlighter/parseCreateFactoryCall.js +3 -3
- package/esm/pipeline/loadPrecomputedCodeHighlighter/performanceLogger.d.ts +30 -0
- package/esm/pipeline/loadPrecomputedCodeHighlighter/performanceLogger.js +77 -0
- package/esm/pipeline/loadPrecomputedCodeHighlighterClient/loadPrecomputedCodeHighlighterClient.js +24 -14
- 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 +220 -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 +7 -5
- package/esm/pipeline/{loaderUtils → loadServerCodeMeta}/resolveModulePathWithFs.d.ts +3 -3
- package/esm/pipeline/{loaderUtils → loadServerCodeMeta}/resolveModulePathWithFs.js +14 -8
- 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 +176 -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 +170 -0
- package/esm/pipeline/loadServerSource/loadServerSource.js +18 -15
- package/esm/pipeline/loaderUtils/externalsToPackages.js +1 -1
- package/esm/pipeline/loaderUtils/extractNameAndSlugFromUrl.d.ts +0 -9
- package/esm/pipeline/loaderUtils/extractNameAndSlugFromUrl.js +7 -7
- package/esm/pipeline/loaderUtils/fileUrlToPortablePath.d.ts +44 -0
- package/esm/pipeline/loaderUtils/fileUrlToPortablePath.js +80 -0
- package/esm/pipeline/loaderUtils/index.d.ts +2 -1
- package/esm/pipeline/loaderUtils/index.js +2 -1
- package/esm/pipeline/loaderUtils/parseImportsAndComments.d.ts +10 -6
- package/esm/pipeline/loaderUtils/parseImportsAndComments.js +17 -12
- package/esm/pipeline/loaderUtils/processRelativeImports.d.ts +1 -1
- package/esm/pipeline/loaderUtils/processRelativeImports.js +44 -27
- package/esm/pipeline/loaderUtils/resolveModulePath.d.ts +5 -5
- package/esm/pipeline/loaderUtils/resolveModulePath.js +40 -37
- 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 +43 -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 +94 -14
- package/package.json +105 -5
- 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,108 @@
|
|
|
1
|
+
import * as lockfile from 'proper-lockfile';
|
|
2
|
+
import type { PageMetadata } from "./metadataToMarkdown.js";
|
|
3
|
+
export interface SyncPageIndexOptions {
|
|
4
|
+
/**
|
|
5
|
+
* The path to the page file (e.g., './app/components/button/page.mdx')
|
|
6
|
+
* OR the path to the index file itself when using metadataList
|
|
7
|
+
*/
|
|
8
|
+
pagePath: string;
|
|
9
|
+
/**
|
|
10
|
+
* The metadata extracted from the page
|
|
11
|
+
* Either provide this for a single update, or metadataList for batch updates
|
|
12
|
+
*/
|
|
13
|
+
metadata?: PageMetadata;
|
|
14
|
+
/**
|
|
15
|
+
* Array of metadata for batch updates
|
|
16
|
+
* When provided, all metadata will be merged in a single file lock/write operation
|
|
17
|
+
*/
|
|
18
|
+
metadataList?: PageMetadata[];
|
|
19
|
+
/**
|
|
20
|
+
* The title for the index file (e.g., 'Components')
|
|
21
|
+
* If not provided, will be derived from the parent directory name
|
|
22
|
+
* (e.g., 'app/components/page.mdx' -> 'Components')
|
|
23
|
+
*/
|
|
24
|
+
indexTitle?: string;
|
|
25
|
+
/**
|
|
26
|
+
* The name of the index file to update (e.g., 'page.mdx')
|
|
27
|
+
* Defaults to 'page.mdx'
|
|
28
|
+
*/
|
|
29
|
+
indexFileName?: string;
|
|
30
|
+
/**
|
|
31
|
+
* Lock options for proper-lockfile
|
|
32
|
+
*/
|
|
33
|
+
lockOptions?: lockfile.LockOptions;
|
|
34
|
+
/**
|
|
35
|
+
* The base directory to stop recursion at (e.g., './app')
|
|
36
|
+
* If not provided, will continue until reaching the root directory
|
|
37
|
+
*/
|
|
38
|
+
baseDir?: string;
|
|
39
|
+
/**
|
|
40
|
+
* Whether to update parent indexes recursively
|
|
41
|
+
* @default false
|
|
42
|
+
*/
|
|
43
|
+
updateParents?: boolean;
|
|
44
|
+
/**
|
|
45
|
+
* Path patterns to include when creating/updating indexes
|
|
46
|
+
* Only indexes within these paths will be created or modified
|
|
47
|
+
* Patterns are matched against the directory path relative to baseDir
|
|
48
|
+
*/
|
|
49
|
+
include?: string[];
|
|
50
|
+
/**
|
|
51
|
+
* Path patterns to exclude when creating/updating indexes
|
|
52
|
+
* Indexes matching these patterns will not be created or modified
|
|
53
|
+
* Patterns are matched against the directory path relative to baseDir
|
|
54
|
+
*/
|
|
55
|
+
exclude?: string[];
|
|
56
|
+
/**
|
|
57
|
+
* Only update existing indexes, don't create new ones
|
|
58
|
+
* When true, will skip updating if the index file doesn't already exist
|
|
59
|
+
* @default false
|
|
60
|
+
*/
|
|
61
|
+
onlyUpdateIndexes?: boolean;
|
|
62
|
+
/**
|
|
63
|
+
* Directory to write marker files when indexes are updated.
|
|
64
|
+
* Path is relative to baseDir.
|
|
65
|
+
* Set to false to disable marker file creation.
|
|
66
|
+
* A marker file will be created at: `${markerDir}/${relativePath}/page.mdx`
|
|
67
|
+
* @default false
|
|
68
|
+
*/
|
|
69
|
+
markerDir?: string | false;
|
|
70
|
+
/**
|
|
71
|
+
* Throw an error if the index is out of date or missing.
|
|
72
|
+
* Useful for CI environments to ensure indexes are committed.
|
|
73
|
+
* @default false
|
|
74
|
+
*/
|
|
75
|
+
errorIfOutOfDate?: boolean;
|
|
76
|
+
/**
|
|
77
|
+
* Optional component name to wrap the autogenerated index content.
|
|
78
|
+
* When provided, the content will be wrapped like: `<ComponentName>...</ComponentName>`
|
|
79
|
+
* @example 'PagesIndex'
|
|
80
|
+
*/
|
|
81
|
+
indexWrapperComponent?: string;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Updates the parent directory's index file with metadata from a page.
|
|
85
|
+
*
|
|
86
|
+
* This function:
|
|
87
|
+
* 1. Acquires a lock on the index file
|
|
88
|
+
* 2. Reads the existing index markdown (if it exists)
|
|
89
|
+
* 3. Merges the new page metadata with existing metadata
|
|
90
|
+
* 4. Writes the updated markdown back to the index file
|
|
91
|
+
* 5. Releases the lock
|
|
92
|
+
* 6. Optionally updates parent indexes recursively
|
|
93
|
+
*
|
|
94
|
+
* @example
|
|
95
|
+
* ```ts
|
|
96
|
+
* await syncPageIndex({
|
|
97
|
+
* pagePath: './app/components/button/page.mdx',
|
|
98
|
+
* metadata: {
|
|
99
|
+
* slug: 'button',
|
|
100
|
+
* path: './button/page.mdx',
|
|
101
|
+
* title: 'Button',
|
|
102
|
+
* description: 'A button component.',
|
|
103
|
+
* },
|
|
104
|
+
* indexTitle: 'Components',
|
|
105
|
+
* });
|
|
106
|
+
* ```
|
|
107
|
+
*/
|
|
108
|
+
export declare function syncPageIndex(options: SyncPageIndexOptions): Promise<void>;
|
|
@@ -0,0 +1,540 @@
|
|
|
1
|
+
import _regeneratorValues from "@babel/runtime/helpers/esm/regeneratorValues";
|
|
2
|
+
import _regenerator from "@babel/runtime/helpers/esm/regenerator";
|
|
3
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
4
|
+
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
|
|
5
|
+
import _createForOfIteratorHelper from "@babel/runtime/helpers/esm/createForOfIteratorHelper";
|
|
6
|
+
import { readFile, writeFile, mkdir } from 'node:fs/promises';
|
|
7
|
+
import { basename, dirname, resolve, relative, join } from 'node:path';
|
|
8
|
+
import * as lockfile from 'proper-lockfile';
|
|
9
|
+
import { mergeMetadataMarkdown } from "./mergeMetadataMarkdown.js";
|
|
10
|
+
import { markdownToMetadata } from "./metadataToMarkdown.js";
|
|
11
|
+
/**
|
|
12
|
+
* Converts a kebab-case string to Title Case
|
|
13
|
+
* @example kebabToTitleCase('my-component') -> 'My Component'
|
|
14
|
+
* @example kebabToTitleCase('hello-world') -> 'Hello World'
|
|
15
|
+
*/
|
|
16
|
+
function kebabToTitleCase(str) {
|
|
17
|
+
return str.split('-').map(function (word) {
|
|
18
|
+
return word.charAt(0).toUpperCase() + word.slice(1);
|
|
19
|
+
}).join(' ');
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Checks if a directory name is a Next.js route group (wrapped in parentheses)
|
|
24
|
+
* @example isRouteGroup('(public)') -> true
|
|
25
|
+
* @example isRouteGroup('components') -> false
|
|
26
|
+
*/
|
|
27
|
+
function isRouteGroup(dirName) {
|
|
28
|
+
return dirName.startsWith('(') && dirName.endsWith(')');
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Gets the parent directory, skipping over Next.js route groups
|
|
33
|
+
* @example getParentDir('/app/(public)/(content)/react') -> '/app/(public)/(content)'
|
|
34
|
+
* When recursing, skips route groups: '/app/(public)/(content)' -> '/app'
|
|
35
|
+
*/
|
|
36
|
+
function getParentDir(path) {
|
|
37
|
+
var skipRouteGroups = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
38
|
+
var parent = dirname(path);
|
|
39
|
+
|
|
40
|
+
// If we should skip route groups, keep going up until we find a non-route-group directory
|
|
41
|
+
if (skipRouteGroups) {
|
|
42
|
+
while (parent !== dirname(parent) && isRouteGroup(basename(parent))) {
|
|
43
|
+
parent = dirname(parent);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
return parent;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Checks if a path should be included based on include/exclude patterns
|
|
51
|
+
* @param path The path to check (relative to baseDir)
|
|
52
|
+
* @param include Include patterns - if provided, path must match at least one
|
|
53
|
+
* @param exclude Exclude patterns - if path matches any, it's excluded
|
|
54
|
+
* @returns true if the path should be included, false otherwise
|
|
55
|
+
*/
|
|
56
|
+
function shouldIncludePath(path, include, exclude) {
|
|
57
|
+
// Normalize path separators to forward slashes and remove Next.js route groups
|
|
58
|
+
var normalizedPath = path.replace(/\\/g, '/').replace(/\/\([^)]+\)/g, '');
|
|
59
|
+
|
|
60
|
+
// Check exclude patterns first
|
|
61
|
+
if (exclude && exclude.length > 0) {
|
|
62
|
+
var _iterator = _createForOfIteratorHelper(exclude),
|
|
63
|
+
_step;
|
|
64
|
+
try {
|
|
65
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
66
|
+
var pattern = _step.value;
|
|
67
|
+
var normalizedPattern = pattern.replace(/\\/g, '/');
|
|
68
|
+
if (normalizedPath.startsWith(normalizedPattern)) {
|
|
69
|
+
return false;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
} catch (err) {
|
|
73
|
+
_iterator.e(err);
|
|
74
|
+
} finally {
|
|
75
|
+
_iterator.f();
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
// If no include patterns, include by default (unless excluded above)
|
|
80
|
+
if (!include || include.length === 0) {
|
|
81
|
+
return true;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
// Check if path matches any include pattern
|
|
85
|
+
var _iterator2 = _createForOfIteratorHelper(include),
|
|
86
|
+
_step2;
|
|
87
|
+
try {
|
|
88
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
89
|
+
var _pattern = _step2.value;
|
|
90
|
+
var _normalizedPattern = _pattern.replace(/\\/g, '/');
|
|
91
|
+
if (normalizedPath.startsWith(_normalizedPattern)) {
|
|
92
|
+
return true;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
// Path doesn't match any include pattern
|
|
97
|
+
} catch (err) {
|
|
98
|
+
_iterator2.e(err);
|
|
99
|
+
} finally {
|
|
100
|
+
_iterator2.f();
|
|
101
|
+
}
|
|
102
|
+
return false;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Updates the parent directory's index file with metadata from a page.
|
|
106
|
+
*
|
|
107
|
+
* This function:
|
|
108
|
+
* 1. Acquires a lock on the index file
|
|
109
|
+
* 2. Reads the existing index markdown (if it exists)
|
|
110
|
+
* 3. Merges the new page metadata with existing metadata
|
|
111
|
+
* 4. Writes the updated markdown back to the index file
|
|
112
|
+
* 5. Releases the lock
|
|
113
|
+
* 6. Optionally updates parent indexes recursively
|
|
114
|
+
*
|
|
115
|
+
* @example
|
|
116
|
+
* ```ts
|
|
117
|
+
* await syncPageIndex({
|
|
118
|
+
* pagePath: './app/components/button/page.mdx',
|
|
119
|
+
* metadata: {
|
|
120
|
+
* slug: 'button',
|
|
121
|
+
* path: './button/page.mdx',
|
|
122
|
+
* title: 'Button',
|
|
123
|
+
* description: 'A button component.',
|
|
124
|
+
* },
|
|
125
|
+
* indexTitle: 'Components',
|
|
126
|
+
* });
|
|
127
|
+
* ```
|
|
128
|
+
*/
|
|
129
|
+
export function syncPageIndex(_x) {
|
|
130
|
+
return _syncPageIndex.apply(this, arguments);
|
|
131
|
+
}
|
|
132
|
+
function _syncPageIndex() {
|
|
133
|
+
_syncPageIndex = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(options) {
|
|
134
|
+
var _options$indexTitle;
|
|
135
|
+
var pagePath, metadata, metadataList, _options$indexFileNam, indexFileName, _options$lockOptions, lockOptions, baseDir, _options$updateParent, updateParents, include, exclude, _options$onlyUpdateIn, onlyUpdateIndexes, _options$markerDir, markerDir, _options$errorIfOutOf, errorIfOutOfDate, indexWrapperComponent, isBatchUpdate, metadataArray, indexPath, parentDir, relativePath, shouldStop, indexTitle, existingContent, fileExists, relativeIndexPath, hasMarker, existingMarkdown, existingPages, parsed, needsUpdate, _iterator3, _step3, _loop, _ret, _relativeIndexPath, release, mergedPages, currentContent, currentMarkdown, currentPages, _parsed, updatedPagesMap, _iterator4, _step4, page, _iterator5, _step5, metaItem, allPages, _relativeIndexPath2, finalMarkdown, markerRelativePath, markerDirResolved, markerPath, markerDirPath, grandParentDir, relativePathFromGrandparent, indexMetadata, sections, _iterator6, _step6, childPage, _t, _t2, _t3, _t4;
|
|
136
|
+
return _regenerator().w(function (_context2) {
|
|
137
|
+
while (1) switch (_context2.p = _context2.n) {
|
|
138
|
+
case 0:
|
|
139
|
+
pagePath = options.pagePath, metadata = options.metadata, metadataList = options.metadataList, _options$indexFileNam = options.indexFileName, indexFileName = _options$indexFileNam === void 0 ? 'page.mdx' : _options$indexFileNam, _options$lockOptions = options.lockOptions, lockOptions = _options$lockOptions === void 0 ? {} : _options$lockOptions, baseDir = options.baseDir, _options$updateParent = options.updateParents, updateParents = _options$updateParent === void 0 ? false : _options$updateParent, include = options.include, exclude = options.exclude, _options$onlyUpdateIn = options.onlyUpdateIndexes, onlyUpdateIndexes = _options$onlyUpdateIn === void 0 ? false : _options$onlyUpdateIn, _options$markerDir = options.markerDir, markerDir = _options$markerDir === void 0 ? false : _options$markerDir, _options$errorIfOutOf = options.errorIfOutOfDate, errorIfOutOfDate = _options$errorIfOutOf === void 0 ? false : _options$errorIfOutOf, indexWrapperComponent = options.indexWrapperComponent; // Validate that either metadata or metadataList is provided
|
|
140
|
+
if (!(!metadata && (!metadataList || metadataList.length === 0))) {
|
|
141
|
+
_context2.n = 1;
|
|
142
|
+
break;
|
|
143
|
+
}
|
|
144
|
+
throw new Error('Either metadata or metadataList must be provided');
|
|
145
|
+
case 1:
|
|
146
|
+
// Determine if we're doing a batch update
|
|
147
|
+
isBatchUpdate = !!metadataList;
|
|
148
|
+
metadataArray = isBatchUpdate ? metadataList : [metadata]; // Resolve the index file path
|
|
149
|
+
// For batch updates, pagePath is the index file itself
|
|
150
|
+
// For single updates, pagePath is a child page and we need the parent's index
|
|
151
|
+
indexPath = isBatchUpdate ? resolve(pagePath) : resolve(getParentDir(dirname(pagePath), true), indexFileName);
|
|
152
|
+
parentDir = dirname(indexPath); // Check if this index path should be processed based on include/exclude filters
|
|
153
|
+
if (!baseDir) {
|
|
154
|
+
_context2.n = 2;
|
|
155
|
+
break;
|
|
156
|
+
}
|
|
157
|
+
relativePath = relative(resolve(baseDir), resolve(parentDir));
|
|
158
|
+
if (shouldIncludePath(relativePath, include, exclude)) {
|
|
159
|
+
_context2.n = 2;
|
|
160
|
+
break;
|
|
161
|
+
}
|
|
162
|
+
return _context2.a(2);
|
|
163
|
+
case 2:
|
|
164
|
+
// Check if we've reached the base directory
|
|
165
|
+
shouldStop = baseDir && resolve(parentDir) === resolve(baseDir); // Derive index title from directory name if not provided
|
|
166
|
+
indexTitle = (_options$indexTitle = options.indexTitle) != null ? _options$indexTitle : kebabToTitleCase(basename(parentDir)); // Step 1: Read the file without acquiring a lock to check if we need to make changes
|
|
167
|
+
existingContent = '';
|
|
168
|
+
fileExists = true;
|
|
169
|
+
_context2.p = 3;
|
|
170
|
+
_context2.n = 4;
|
|
171
|
+
return readFile(indexPath, 'utf-8');
|
|
172
|
+
case 4:
|
|
173
|
+
existingContent = _context2.v;
|
|
174
|
+
_context2.n = 8;
|
|
175
|
+
break;
|
|
176
|
+
case 5:
|
|
177
|
+
_context2.p = 5;
|
|
178
|
+
_t = _context2.v;
|
|
179
|
+
if (!(_t.code !== 'ENOENT')) {
|
|
180
|
+
_context2.n = 6;
|
|
181
|
+
break;
|
|
182
|
+
}
|
|
183
|
+
throw _t;
|
|
184
|
+
case 6:
|
|
185
|
+
// File doesn't exist
|
|
186
|
+
fileExists = false;
|
|
187
|
+
|
|
188
|
+
// If onlyUpdateIndexes is true and file doesn't exist, skip this update
|
|
189
|
+
if (!onlyUpdateIndexes) {
|
|
190
|
+
_context2.n = 7;
|
|
191
|
+
break;
|
|
192
|
+
}
|
|
193
|
+
return _context2.a(2);
|
|
194
|
+
case 7:
|
|
195
|
+
if (!errorIfOutOfDate) {
|
|
196
|
+
_context2.n = 8;
|
|
197
|
+
break;
|
|
198
|
+
}
|
|
199
|
+
relativeIndexPath = baseDir ? relative(resolve(baseDir), indexPath) : indexPath;
|
|
200
|
+
throw new Error("Index file is missing: ".concat(relativeIndexPath, "\n") + "Please run next build locally and commit the updated index files.\n" + "Don't forget to add it to the `app/sitemap/index.ts` to list it publicly.");
|
|
201
|
+
case 8:
|
|
202
|
+
if (!(fileExists && existingContent)) {
|
|
203
|
+
_context2.n = 9;
|
|
204
|
+
break;
|
|
205
|
+
}
|
|
206
|
+
hasMarker = existingContent.includes("[//]: # 'This file is autogenerated");
|
|
207
|
+
if (hasMarker) {
|
|
208
|
+
_context2.n = 9;
|
|
209
|
+
break;
|
|
210
|
+
}
|
|
211
|
+
return _context2.a(2);
|
|
212
|
+
case 9:
|
|
213
|
+
// Step 2: Parse existing content and check if our specific page needs updating
|
|
214
|
+
existingMarkdown = existingContent.trim() ? existingContent : undefined;
|
|
215
|
+
existingPages = [];
|
|
216
|
+
if (!existingMarkdown) {
|
|
217
|
+
_context2.n = 11;
|
|
218
|
+
break;
|
|
219
|
+
}
|
|
220
|
+
_context2.n = 10;
|
|
221
|
+
return markdownToMetadata(existingMarkdown);
|
|
222
|
+
case 10:
|
|
223
|
+
parsed = _context2.v;
|
|
224
|
+
if (parsed) {
|
|
225
|
+
existingPages = parsed.pages;
|
|
226
|
+
}
|
|
227
|
+
case 11:
|
|
228
|
+
// Step 3: Check if any of our metadata items need updating
|
|
229
|
+
needsUpdate = false;
|
|
230
|
+
_iterator3 = _createForOfIteratorHelper(metadataArray);
|
|
231
|
+
_context2.p = 12;
|
|
232
|
+
_loop = /*#__PURE__*/_regenerator().m(function _loop() {
|
|
233
|
+
var metaItem, existingPageIndex, existingPage, existingPageJson, newPageJson;
|
|
234
|
+
return _regenerator().w(function (_context) {
|
|
235
|
+
while (1) switch (_context.n) {
|
|
236
|
+
case 0:
|
|
237
|
+
metaItem = _step3.value;
|
|
238
|
+
existingPageIndex = existingPages.findIndex(function (p) {
|
|
239
|
+
return p.slug === metaItem.slug;
|
|
240
|
+
});
|
|
241
|
+
if (!(existingPageIndex >= 0)) {
|
|
242
|
+
_context.n = 2;
|
|
243
|
+
break;
|
|
244
|
+
}
|
|
245
|
+
existingPage = existingPages[existingPageIndex]; // Compare metadata - if different, we need to update
|
|
246
|
+
existingPageJson = JSON.stringify(existingPage);
|
|
247
|
+
newPageJson = JSON.stringify(metaItem);
|
|
248
|
+
if (!(existingPageJson !== newPageJson)) {
|
|
249
|
+
_context.n = 1;
|
|
250
|
+
break;
|
|
251
|
+
}
|
|
252
|
+
needsUpdate = true;
|
|
253
|
+
return _context.a(2, 0);
|
|
254
|
+
case 1:
|
|
255
|
+
_context.n = 3;
|
|
256
|
+
break;
|
|
257
|
+
case 2:
|
|
258
|
+
// Page doesn't exist, we need to add it
|
|
259
|
+
needsUpdate = true;
|
|
260
|
+
return _context.a(2, 0);
|
|
261
|
+
case 3:
|
|
262
|
+
return _context.a(2);
|
|
263
|
+
}
|
|
264
|
+
}, _loop);
|
|
265
|
+
});
|
|
266
|
+
_iterator3.s();
|
|
267
|
+
case 13:
|
|
268
|
+
if ((_step3 = _iterator3.n()).done) {
|
|
269
|
+
_context2.n = 16;
|
|
270
|
+
break;
|
|
271
|
+
}
|
|
272
|
+
return _context2.d(_regeneratorValues(_loop()), 14);
|
|
273
|
+
case 14:
|
|
274
|
+
_ret = _context2.v;
|
|
275
|
+
if (!(_ret === 0)) {
|
|
276
|
+
_context2.n = 15;
|
|
277
|
+
break;
|
|
278
|
+
}
|
|
279
|
+
return _context2.a(3, 16);
|
|
280
|
+
case 15:
|
|
281
|
+
_context2.n = 13;
|
|
282
|
+
break;
|
|
283
|
+
case 16:
|
|
284
|
+
_context2.n = 18;
|
|
285
|
+
break;
|
|
286
|
+
case 17:
|
|
287
|
+
_context2.p = 17;
|
|
288
|
+
_t2 = _context2.v;
|
|
289
|
+
_iterator3.e(_t2);
|
|
290
|
+
case 18:
|
|
291
|
+
_context2.p = 18;
|
|
292
|
+
_iterator3.f();
|
|
293
|
+
return _context2.f(18);
|
|
294
|
+
case 19:
|
|
295
|
+
if (needsUpdate) {
|
|
296
|
+
_context2.n = 20;
|
|
297
|
+
break;
|
|
298
|
+
}
|
|
299
|
+
return _context2.a(2);
|
|
300
|
+
case 20:
|
|
301
|
+
if (!errorIfOutOfDate) {
|
|
302
|
+
_context2.n = 21;
|
|
303
|
+
break;
|
|
304
|
+
}
|
|
305
|
+
_relativeIndexPath = baseDir ? relative(resolve(baseDir), indexPath) : indexPath;
|
|
306
|
+
throw new Error("Index file is out of date: ".concat(_relativeIndexPath, "\n") + "Please run the validation command (or next build) locally and commit the updated index files.");
|
|
307
|
+
case 21:
|
|
308
|
+
if (fileExists) {
|
|
309
|
+
_context2.n = 22;
|
|
310
|
+
break;
|
|
311
|
+
}
|
|
312
|
+
_context2.n = 22;
|
|
313
|
+
return writeFile(indexPath, '', 'utf-8');
|
|
314
|
+
case 22:
|
|
315
|
+
mergedPages = []; // Store merged pages for parent update
|
|
316
|
+
_context2.p = 23;
|
|
317
|
+
_context2.n = 24;
|
|
318
|
+
return lockfile.lock(indexPath, _extends({
|
|
319
|
+
retries: {
|
|
320
|
+
retries: 300,
|
|
321
|
+
minTimeout: 1,
|
|
322
|
+
// Start with 1ms for fast retries
|
|
323
|
+
maxTimeout: 150,
|
|
324
|
+
randomize: true
|
|
325
|
+
},
|
|
326
|
+
stale: 30000
|
|
327
|
+
}, lockOptions));
|
|
328
|
+
case 24:
|
|
329
|
+
release = _context2.v;
|
|
330
|
+
// Step 6: Re-read and re-merge to catch any concurrent updates from other processes
|
|
331
|
+
// This ensures we don't lose updates from other pages being processed in parallel
|
|
332
|
+
currentContent = '';
|
|
333
|
+
_context2.p = 25;
|
|
334
|
+
_context2.n = 26;
|
|
335
|
+
return readFile(indexPath, 'utf-8');
|
|
336
|
+
case 26:
|
|
337
|
+
currentContent = _context2.v;
|
|
338
|
+
_context2.n = 28;
|
|
339
|
+
break;
|
|
340
|
+
case 27:
|
|
341
|
+
_context2.p = 27;
|
|
342
|
+
_t3 = _context2.v;
|
|
343
|
+
if (!(_t3.code !== 'ENOENT')) {
|
|
344
|
+
_context2.n = 28;
|
|
345
|
+
break;
|
|
346
|
+
}
|
|
347
|
+
throw _t3;
|
|
348
|
+
case 28:
|
|
349
|
+
currentMarkdown = currentContent.trim() ? currentContent : undefined;
|
|
350
|
+
currentPages = [];
|
|
351
|
+
if (!currentMarkdown) {
|
|
352
|
+
_context2.n = 30;
|
|
353
|
+
break;
|
|
354
|
+
}
|
|
355
|
+
_context2.n = 29;
|
|
356
|
+
return markdownToMetadata(currentMarkdown);
|
|
357
|
+
case 29:
|
|
358
|
+
_parsed = _context2.v;
|
|
359
|
+
if (_parsed) {
|
|
360
|
+
currentPages = _parsed.pages;
|
|
361
|
+
}
|
|
362
|
+
case 30:
|
|
363
|
+
// For batch updates, merge the metadata items with existing pages
|
|
364
|
+
// Build a map keyed by path (not slug) to match mergeMetadataMarkdown's logic
|
|
365
|
+
updatedPagesMap = new Map(); // First, add all current pages
|
|
366
|
+
_iterator4 = _createForOfIteratorHelper(currentPages);
|
|
367
|
+
try {
|
|
368
|
+
for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
|
|
369
|
+
page = _step4.value;
|
|
370
|
+
updatedPagesMap.set(page.path, page);
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
// Then update/add the new metadata items
|
|
374
|
+
} catch (err) {
|
|
375
|
+
_iterator4.e(err);
|
|
376
|
+
} finally {
|
|
377
|
+
_iterator4.f();
|
|
378
|
+
}
|
|
379
|
+
_iterator5 = _createForOfIteratorHelper(metadataArray);
|
|
380
|
+
try {
|
|
381
|
+
for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
|
|
382
|
+
metaItem = _step5.value;
|
|
383
|
+
updatedPagesMap.set(metaItem.path, metaItem);
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
// Convert back to array - this is the COMPLETE list of pages that should exist
|
|
387
|
+
} catch (err) {
|
|
388
|
+
_iterator5.e(err);
|
|
389
|
+
} finally {
|
|
390
|
+
_iterator5.f();
|
|
391
|
+
}
|
|
392
|
+
allPages = Array.from(updatedPagesMap.values()); // Store for parent update
|
|
393
|
+
mergedPages = allPages;
|
|
394
|
+
|
|
395
|
+
// Re-merge with the latest content, passing the COMPLETE list of pages
|
|
396
|
+
// mergeMetadataMarkdown will preserve the order from currentMarkdown
|
|
397
|
+
// Only include path in the comment when baseDir is set (otherwise it's an absolute path)
|
|
398
|
+
_relativeIndexPath2 = baseDir ? relative(resolve(baseDir), indexPath) : undefined;
|
|
399
|
+
_context2.n = 31;
|
|
400
|
+
return mergeMetadataMarkdown(currentMarkdown, {
|
|
401
|
+
title: indexTitle,
|
|
402
|
+
pages: allPages
|
|
403
|
+
}, {
|
|
404
|
+
indexWrapperComponent: indexWrapperComponent,
|
|
405
|
+
path: _relativeIndexPath2
|
|
406
|
+
});
|
|
407
|
+
case 31:
|
|
408
|
+
finalMarkdown = _context2.v;
|
|
409
|
+
if (!(!finalMarkdown || !finalMarkdown.trim())) {
|
|
410
|
+
_context2.n = 32;
|
|
411
|
+
break;
|
|
412
|
+
}
|
|
413
|
+
throw new Error("Cannot write empty content to ".concat(indexPath));
|
|
414
|
+
case 32:
|
|
415
|
+
if (!(currentContent !== finalMarkdown)) {
|
|
416
|
+
_context2.n = 35;
|
|
417
|
+
break;
|
|
418
|
+
}
|
|
419
|
+
_context2.n = 33;
|
|
420
|
+
return writeFile(indexPath, finalMarkdown, 'utf-8');
|
|
421
|
+
case 33:
|
|
422
|
+
if (!markerDir) {
|
|
423
|
+
_context2.n = 35;
|
|
424
|
+
break;
|
|
425
|
+
}
|
|
426
|
+
// Compute relative path for marker (always compute, not used for comments)
|
|
427
|
+
markerRelativePath = baseDir ? relative(resolve(baseDir), indexPath) : indexPath; // Resolve markerDir relative to baseDir (if baseDir is provided)
|
|
428
|
+
markerDirResolved = baseDir ? resolve(baseDir, markerDir) : markerDir;
|
|
429
|
+
markerPath = join(markerDirResolved, markerRelativePath);
|
|
430
|
+
markerDirPath = dirname(markerPath); // Ensure the marker directory exists
|
|
431
|
+
_context2.n = 34;
|
|
432
|
+
return mkdir(markerDirPath, {
|
|
433
|
+
recursive: true
|
|
434
|
+
});
|
|
435
|
+
case 34:
|
|
436
|
+
_context2.n = 35;
|
|
437
|
+
return writeFile(markerPath, '', 'utf-8');
|
|
438
|
+
case 35:
|
|
439
|
+
_context2.p = 35;
|
|
440
|
+
if (!release) {
|
|
441
|
+
_context2.n = 36;
|
|
442
|
+
break;
|
|
443
|
+
}
|
|
444
|
+
_context2.n = 36;
|
|
445
|
+
return release();
|
|
446
|
+
case 36:
|
|
447
|
+
return _context2.f(35);
|
|
448
|
+
case 37:
|
|
449
|
+
if (!(updateParents && !shouldStop)) {
|
|
450
|
+
_context2.n = 47;
|
|
451
|
+
break;
|
|
452
|
+
}
|
|
453
|
+
// Get the grandparent directory, skipping over Next.js route groups
|
|
454
|
+
grandParentDir = getParentDir(parentDir, true); // Only continue if we're not at the filesystem root
|
|
455
|
+
if (!(grandParentDir !== parentDir)) {
|
|
456
|
+
_context2.n = 47;
|
|
457
|
+
break;
|
|
458
|
+
}
|
|
459
|
+
// CRITICAL: Use the merged pages from Step 6, not a re-read of the file
|
|
460
|
+
// Re-reading could get a stale version if other processes are still writing
|
|
461
|
+
// mergedPages already contains ALL pages after the merge in Step 6
|
|
462
|
+
// Calculate the relative path from grandparent to this index, preserving route groups
|
|
463
|
+
relativePathFromGrandparent = relative(grandParentDir, parentDir); // Extract metadata for the current index to add to its parent
|
|
464
|
+
indexMetadata = {
|
|
465
|
+
slug: basename(parentDir),
|
|
466
|
+
path: "./".concat(relativePathFromGrandparent, "/").concat(indexFileName),
|
|
467
|
+
title: indexTitle,
|
|
468
|
+
description: 'No description available'
|
|
469
|
+
}; // Convert child pages to sections format (no subsections, just page names)
|
|
470
|
+
// Use mergedPages which contains the complete merged state
|
|
471
|
+
// Skip single-link entries (external links) as they don't have detail sections
|
|
472
|
+
if (!(mergedPages.length > 0)) {
|
|
473
|
+
_context2.n = 46;
|
|
474
|
+
break;
|
|
475
|
+
}
|
|
476
|
+
sections = {};
|
|
477
|
+
_iterator6 = _createForOfIteratorHelper(mergedPages);
|
|
478
|
+
_context2.p = 38;
|
|
479
|
+
_iterator6.s();
|
|
480
|
+
case 39:
|
|
481
|
+
if ((_step6 = _iterator6.n()).done) {
|
|
482
|
+
_context2.n = 42;
|
|
483
|
+
break;
|
|
484
|
+
}
|
|
485
|
+
childPage = _step6.value;
|
|
486
|
+
if (!childPage.skipDetailSection) {
|
|
487
|
+
_context2.n = 40;
|
|
488
|
+
break;
|
|
489
|
+
}
|
|
490
|
+
return _context2.a(3, 41);
|
|
491
|
+
case 40:
|
|
492
|
+
sections[childPage.slug] = {
|
|
493
|
+
title: childPage.title || childPage.slug,
|
|
494
|
+
titleMarkdown: childPage.title ? [{
|
|
495
|
+
type: 'text',
|
|
496
|
+
value: childPage.title
|
|
497
|
+
}] : [{
|
|
498
|
+
type: 'text',
|
|
499
|
+
value: childPage.slug
|
|
500
|
+
}],
|
|
501
|
+
children: {} // Don't include any subsections in parent index
|
|
502
|
+
};
|
|
503
|
+
case 41:
|
|
504
|
+
_context2.n = 39;
|
|
505
|
+
break;
|
|
506
|
+
case 42:
|
|
507
|
+
_context2.n = 44;
|
|
508
|
+
break;
|
|
509
|
+
case 43:
|
|
510
|
+
_context2.p = 43;
|
|
511
|
+
_t4 = _context2.v;
|
|
512
|
+
_iterator6.e(_t4);
|
|
513
|
+
case 44:
|
|
514
|
+
_context2.p = 44;
|
|
515
|
+
_iterator6.f();
|
|
516
|
+
return _context2.f(44);
|
|
517
|
+
case 45:
|
|
518
|
+
indexMetadata.sections = sections;
|
|
519
|
+
case 46:
|
|
520
|
+
_context2.n = 47;
|
|
521
|
+
return syncPageIndex({
|
|
522
|
+
pagePath: indexPath,
|
|
523
|
+
metadata: indexMetadata,
|
|
524
|
+
indexFileName: indexFileName,
|
|
525
|
+
lockOptions: lockOptions,
|
|
526
|
+
baseDir: baseDir,
|
|
527
|
+
updateParents: true,
|
|
528
|
+
include: include,
|
|
529
|
+
exclude: exclude,
|
|
530
|
+
onlyUpdateIndexes: onlyUpdateIndexes,
|
|
531
|
+
markerDir: markerDir,
|
|
532
|
+
errorIfOutOfDate: errorIfOutOfDate
|
|
533
|
+
});
|
|
534
|
+
case 47:
|
|
535
|
+
return _context2.a(2);
|
|
536
|
+
}
|
|
537
|
+
}, _callee, null, [[38, 43, 44, 45], [25, 27], [23,, 35, 37], [12, 17, 18, 19], [3, 5]]);
|
|
538
|
+
}));
|
|
539
|
+
return _syncPageIndex.apply(this, arguments);
|
|
540
|
+
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import type { Plugin } from 'unified';
|
|
2
2
|
/**
|
|
3
|
-
* Rehype plugin that transforms semantic HTML code structures to use
|
|
3
|
+
* Rehype plugin that transforms semantic HTML code structures to use loadCodeVariant
|
|
4
4
|
*
|
|
5
5
|
* This plugin:
|
|
6
6
|
* 1. Finds section and dl elements in the HTML AST
|
|
7
7
|
* 2. Extracts code elements from the semantic structure (figure/dl/dd/pre/code)
|
|
8
8
|
* 3. Creates variants from multiple code elements or single Default variant
|
|
9
|
-
* 4. Uses
|
|
9
|
+
* 4. Uses loadCodeVariant to process each variant
|
|
10
10
|
* 5. Stores the combined precompute data on the root element
|
|
11
11
|
* 6. Clears all code element contents and replaces with error message
|
|
12
12
|
*/
|