fumadocs-core 13.0.6 → 13.1.0
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/source/index.js +3 -1
- package/dist/toc.js +12 -4
- package/package.json +1 -1
package/dist/source/index.js
CHANGED
|
@@ -65,6 +65,7 @@ var separator = /^---(?<name>.*?)---$/;
|
|
|
65
65
|
var rest = "...";
|
|
66
66
|
function buildAll(nodes, ctx, skipIndex) {
|
|
67
67
|
const output = [];
|
|
68
|
+
const folders = [];
|
|
68
69
|
for (const node of [...nodes].sort(
|
|
69
70
|
(a, b) => a.file.name.localeCompare(b.file.name)
|
|
70
71
|
)) {
|
|
@@ -77,9 +78,10 @@ function buildAll(nodes, ctx, skipIndex) {
|
|
|
77
78
|
output.push(treeNode);
|
|
78
79
|
}
|
|
79
80
|
if ("children" in node) {
|
|
80
|
-
|
|
81
|
+
folders.push(buildFolderNode(node, false, ctx));
|
|
81
82
|
}
|
|
82
83
|
}
|
|
84
|
+
output.push(...folders);
|
|
83
85
|
return output;
|
|
84
86
|
}
|
|
85
87
|
function resolveFolderItem(folder, item, ctx, addedNodePaths) {
|
package/dist/toc.js
CHANGED
|
@@ -29,17 +29,24 @@ function useAnchorObserver(watch) {
|
|
|
29
29
|
(entries) => {
|
|
30
30
|
setActiveAnchor((f) => {
|
|
31
31
|
for (const entry of entries) {
|
|
32
|
-
|
|
33
|
-
const active = aboveHalf && entry.isIntersecting;
|
|
34
|
-
if (active) {
|
|
32
|
+
if (entry.isIntersecting) {
|
|
35
33
|
return entry.target.id;
|
|
36
34
|
}
|
|
37
35
|
}
|
|
38
36
|
return f ?? watch[0];
|
|
39
37
|
});
|
|
40
38
|
},
|
|
41
|
-
{ rootMargin:
|
|
39
|
+
{ rootMargin: `-60px 0% -75% 0%`, threshold: 1 }
|
|
42
40
|
);
|
|
41
|
+
const scroll = () => {
|
|
42
|
+
const element = document.scrollingElement;
|
|
43
|
+
if (!element) return;
|
|
44
|
+
if (element.scrollTop >= // assume you have a 10px margin
|
|
45
|
+
element.scrollHeight - element.clientHeight - 10) {
|
|
46
|
+
setActiveAnchor(watch.at(-1));
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
window.addEventListener("scroll", scroll);
|
|
43
50
|
for (const heading of watch) {
|
|
44
51
|
const element = document.getElementById(heading);
|
|
45
52
|
if (element !== null) {
|
|
@@ -47,6 +54,7 @@ function useAnchorObserver(watch) {
|
|
|
47
54
|
}
|
|
48
55
|
}
|
|
49
56
|
return () => {
|
|
57
|
+
window.removeEventListener("scroll", scroll);
|
|
50
58
|
observer.disconnect();
|
|
51
59
|
};
|
|
52
60
|
}, [watch]);
|