dumi 2.3.1 → 2.3.2

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.
@@ -83,7 +83,8 @@ async function parseBlockAsset(opts) {
83
83
  type: "NPM",
84
84
  value: pkg.version
85
85
  };
86
- result.resolveMap[args.path] = args.path;
86
+ if (opts.techStack.runtimeOpts)
87
+ result.resolveMap[args.path] = args.path;
87
88
  }
88
89
  return { path: args.path, external: true };
89
90
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dumi",
3
- "version": "2.3.1",
3
+ "version": "2.3.2",
4
4
  "description": "📖 Documentation Generator of React Component",
5
5
  "keywords": [
6
6
  "generator",
@@ -23,6 +23,10 @@ var Toc = function Toc() {
23
23
  _useState2 = _slicedToArray(_useState, 2),
24
24
  sectionRefs = _useState2[0],
25
25
  setSectionRefs = _useState2[1];
26
+ var _useState3 = useState(0),
27
+ _useState4 = _slicedToArray(_useState3, 2),
28
+ headerHeight = _useState4[0],
29
+ setHeaderHeight = _useState4[1];
26
30
  var memoToc = React.useMemo(function () {
27
31
  var toc = meta.toc;
28
32
  if (tabMeta) {
@@ -47,8 +51,17 @@ var Toc = function Toc() {
47
51
  setSectionRefs(refs);
48
52
  }
49
53
  }, [pathname, search, loading, memoToc]);
54
+ useEffect(function () {
55
+ if (sectionRefs.length > 0) {
56
+ // find the header height, and set it to scrollspy offset
57
+ // because the header is sticky, so we need to set the offset to avoid the active item is hidden by the header
58
+ var header = document.querySelector('.dumi-default-header');
59
+ setHeaderHeight(header ? header.clientHeight : 0);
60
+ }
61
+ }, [sectionRefs]);
50
62
  return sectionRefs.length ? /*#__PURE__*/React.createElement(ScrollSpy, {
51
- sectionRefs: sectionRefs
63
+ sectionRefs: sectionRefs,
64
+ offset: -headerHeight
52
65
  }, function (_ref3) {
53
66
  var currentElementIndexInViewport = _ref3.currentElementIndexInViewport;
54
67
  // for keep prev item active when no item in viewport