rework/lightweight #12
@ -2,5 +2,4 @@ export type Section = {
|
|||||||
id: string;
|
id: string;
|
||||||
title: string;
|
title: string;
|
||||||
level: 2 | 3;
|
level: 2 | 3;
|
||||||
path: string;
|
|
||||||
};
|
};
|
||||||
|
|||||||
@ -124,21 +124,6 @@ const formatExportNode = (): MDXJSEsm => {
|
|||||||
method: false,
|
method: false,
|
||||||
shorthand: false,
|
shorthand: false,
|
||||||
},
|
},
|
||||||
{
|
|
||||||
type: "Property",
|
|
||||||
key: {
|
|
||||||
type: "Identifier",
|
|
||||||
name: "path",
|
|
||||||
},
|
|
||||||
value: {
|
|
||||||
type: "Literal",
|
|
||||||
value: section.path,
|
|
||||||
},
|
|
||||||
kind: "init",
|
|
||||||
computed: false,
|
|
||||||
method: false,
|
|
||||||
shorthand: false,
|
|
||||||
},
|
|
||||||
],
|
],
|
||||||
})),
|
})),
|
||||||
},
|
},
|
||||||
@ -161,9 +146,6 @@ const remarkHeadingId: Plugin<[], Root> = () => (tree: Root, file) => {
|
|||||||
visit(tree, "heading", (node) => {
|
visit(tree, "heading", (node) => {
|
||||||
const lastChild = node.children[node.children.length - 1];
|
const lastChild = node.children[node.children.length - 1];
|
||||||
|
|
||||||
const filePath = file.path;
|
|
||||||
console.log(`File path: ${filePath}`);
|
|
||||||
|
|
||||||
if (lastChild && lastChild.type === "text") {
|
if (lastChild && lastChild.type === "text") {
|
||||||
const string = lastChild.value.replace(/ +$/, "");
|
const string = lastChild.value.replace(/ +$/, "");
|
||||||
const matched = string.match(/ {#(.*?)}$/);
|
const matched = string.match(/ {#(.*?)}$/);
|
||||||
@ -181,7 +163,6 @@ const remarkHeadingId: Plugin<[], Root> = () => (tree: Root, file) => {
|
|||||||
id: slug,
|
id: slug,
|
||||||
title: extractText(node.children),
|
title: extractText(node.children),
|
||||||
level: depth,
|
level: depth,
|
||||||
path: filePath,
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user