refactor: enforce type import specifiers (#6230)

* refactor: enforce type import specifiers

* fix

* Upgrade esbuild

* Fix (haha)
This commit is contained in:
Joshua Chen 2021-12-31 21:17:09 +08:00 committed by GitHub
parent 24d65d9bdd
commit cb1aa30286
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
192 changed files with 484 additions and 337 deletions

View file

@ -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>.