astro-custom-toc 2.0.15 → 2.0.17
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/dist/index.d.ts +1 -1
- package/dist/rehype-custom-toc.js +5 -3
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { AstroIntegration } from "astro";
|
|
2
|
-
import { RehypeCustomTocOptions } from "./rehype-custom-toc.js";
|
|
2
|
+
import { type RehypeCustomTocOptions } from "./rehype-custom-toc.js";
|
|
3
3
|
/**
|
|
4
4
|
* Create the astro-custom-toc integration.
|
|
5
5
|
* @param options Options for the integration
|
|
@@ -28,7 +28,7 @@ const DEFAULT_OPTIONS = {
|
|
|
28
28
|
* @param headings Headings data
|
|
29
29
|
* @returns The generated table of contents
|
|
30
30
|
*/
|
|
31
|
-
// eslint-disable-next-line max-statements
|
|
31
|
+
// eslint-disable-next-line max-statements, max-lines-per-function
|
|
32
32
|
const generateToc = (options, headings) => {
|
|
33
33
|
const toc = {
|
|
34
34
|
children: [],
|
|
@@ -63,9 +63,11 @@ const generateToc = (options, headings) => {
|
|
|
63
63
|
for (let i = 0; i < currentDepth - heading.depth; i++) {
|
|
64
64
|
parents.pop();
|
|
65
65
|
// eslint-disable-next-line no-magic-numbers
|
|
66
|
-
|
|
67
|
-
if (!parentNode)
|
|
66
|
+
if (parents.length < 1) {
|
|
68
67
|
throw new Error("Parent node not found. Make sure the headings are sorted by depth.");
|
|
68
|
+
}
|
|
69
|
+
// eslint-disable-next-line no-magic-numbers
|
|
70
|
+
const parentNode = parents[parents.length - 1];
|
|
69
71
|
currentParent = parentNode;
|
|
70
72
|
}
|
|
71
73
|
currentParent.children.push(li);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "astro-custom-toc",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.17",
|
|
4
4
|
"description": "Astro Integration to generate a customizable table of contents",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"provenance": true
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
"devDependencies": {
|
|
54
54
|
"@changesets/changelog-github": "^0.5.0",
|
|
55
55
|
"@changesets/cli": "^2.27.1",
|
|
56
|
-
"@robot-inventor/eslint-config": "^0.
|
|
56
|
+
"@robot-inventor/eslint-config": "^3.0.0",
|
|
57
57
|
"eslint": "^9.0.0",
|
|
58
58
|
"prettier": "^3.2.5"
|
|
59
59
|
}
|