mirror of
https://github.com/facebook/docusaurus.git
synced 2025-06-12 15:52:39 +02:00
refactor: enforce type import specifiers (#6230)
* refactor: enforce type import specifiers * fix * Upgrade esbuild * Fix (haha)
This commit is contained in:
parent
24d65d9bdd
commit
cb1aa30286
192 changed files with 484 additions and 337 deletions
|
@ -6,7 +6,7 @@
|
|||
*/
|
||||
|
||||
import toString from 'mdast-util-to-string';
|
||||
import visit, {Visitor} from 'unist-util-visit';
|
||||
import visit from 'unist-util-visit';
|
||||
import {toValue} from '../utils';
|
||||
import type {TOCItem} from '@docusaurus/types';
|
||||
import type {Node} from 'unist';
|
||||
|
@ -26,7 +26,7 @@ interface SearchItem {
|
|||
export default function search(node: Node): TOCItem[] {
|
||||
const headings: SearchItem[] = [];
|
||||
|
||||
const visitor: Visitor<Heading> = (child, _index, parent) => {
|
||||
visit(node, 'heading', (child: Heading, _index, parent) => {
|
||||
const value = toString(child);
|
||||
|
||||
// depth:1 headings are titles and not included in the TOC
|
||||
|
@ -44,9 +44,7 @@ export default function search(node: Node): TOCItem[] {
|
|||
level: child.depth,
|
||||
parentIndex: -1,
|
||||
});
|
||||
};
|
||||
|
||||
visit(node, 'heading', visitor);
|
||||
});
|
||||
|
||||
// Keep track of which previous index would be the current heading's direcy parent.
|
||||
// Each entry <i> is the last index of the `headings` array at heading level <i>.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue