>(
+ (previous, next) => ({
+ ...previous,
+ ...getOptionProperties(next),
+ }),
+ {},
+ );
+ }
+
+ return undefined;
+}
diff --git a/packages/website/plugins/utils/nodes.ts b/packages/website/plugins/utils/nodes.ts
index 5d7d1494a45c..3f1e5c995268 100644
--- a/packages/website/plugins/utils/nodes.ts
+++ b/packages/website/plugins/utils/nodes.ts
@@ -1,4 +1,5 @@
import type * as mdast from 'mdast';
+import type { MdxFlowExpression } from 'mdast-util-mdx';
import type * as unist from 'unist';
export function nodeIsCode(node: unist.Node): node is mdast.Code {
@@ -9,6 +10,12 @@ export function nodeIsHeading(node: unist.Node): node is mdast.Heading {
return node.type === 'heading';
}
+export function nodeIsMdxFlowExpression(
+ node: unist.Node,
+): node is MdxFlowExpression {
+ return node.type === 'mdxFlowExpression';
+}
+
export function nodeIsParent(node: unist.Node): node is unist.Parent {
return 'children' in node;
}
diff --git a/packages/website/plugins/utils/rules.ts b/packages/website/plugins/utils/rules.ts
index 02130f2e28db..508616497146 100644
--- a/packages/website/plugins/utils/rules.ts
+++ b/packages/website/plugins/utils/rules.ts
@@ -4,6 +4,7 @@ import * as path from 'node:path';
import type { ESLintPluginRuleModule } from '@typescript-eslint/eslint-plugin/use-at-your-own-risk/rules';
import type { RuleModule } from '@typescript-eslint/utils/ts-eslint';
import * as lz from 'lz-string';
+import type * as mdast from 'mdast';
import type * as unist from 'unist';
import type { VFile } from 'vfile';
@@ -68,16 +69,22 @@ export function isVFileWithStem(file: VFile): file is VFileWithStem {
return !!file.stem;
}
-export function findH2Index(
- children: unist.Node[],
- headingName: string,
+export function findHeadingIndex(
+ children: readonly unist.Node[],
+ depth: 2 | 3,
+ contents: string | ((node: mdast.PhrasingContent) => boolean),
): number {
+ const childMatch =
+ typeof contents === 'string'
+ ? (node: mdast.PhrasingContent): boolean =>
+ node.type === 'text' && node.value === contents
+ : contents;
+
return children.findIndex(
node =>
nodeIsHeading(node) &&
- node.depth === 2 &&
+ node.depth === depth &&
node.children.length === 1 &&
- node.children[0].type === 'text' &&
- node.children[0].value === headingName,
+ childMatch(node.children[0]),
);
}
pFad - Phonifier reborn
Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.
Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.
Alternative Proxies:
Alternative Proxy
pFad Proxy
pFad v3 Proxy
pFad v4 Proxy