dumi 2.1.14 → 2.1.15
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/features/derivative.js +4 -0
- package/dist/features/routes.js +5 -16
- package/dist/features/theme/index.js +6 -2
- package/dist/loaders/markdown/transformer/rehypeDemo.js +15 -6
- package/dist/loaders/markdown/transformer/rehypeLink.js +4 -4
- package/dist/utils.d.ts +4 -0
- package/dist/utils.js +14 -0
- package/package.json +5 -5
- package/theme-default/slots/Content/index.js +7 -2
- package/theme-default/slots/Content/index.less +17 -0
- package/theme-default/slots/Toc/index.js +18 -9
|
@@ -140,6 +140,10 @@ var derivative_default = (api) => {
|
|
|
140
140
|
});
|
|
141
141
|
const umiPath = import_path.default.join(api.paths.absTmpPath, "umi.ts");
|
|
142
142
|
import_plugin_utils.fsExtra.writeFileSync(umiPath, import_plugin_utils.fsExtra.readFileSync(umiPath, "utf-8").replace("'@/loading'", "'../loading'"));
|
|
143
|
+
if (api.config.ssr && import_plugin_utils.semver.subset(api.appData.umi.version, "4.0.54 - 4.0.55")) {
|
|
144
|
+
const helmetPath = import_path.default.join(api.paths.absTmpPath, "core/helmet.ts");
|
|
145
|
+
import_plugin_utils.fsExtra.writeFileSync(helmetPath, import_plugin_utils.fsExtra.readFileSync(helmetPath, "utf-8").replace(/(return )(React\.createElement)/, "$1typeof window === 'undefined' ? container : $2"));
|
|
146
|
+
}
|
|
143
147
|
}
|
|
144
148
|
});
|
|
145
149
|
api.registerPlugins([require.resolve("../../compiled/@umijs/plugins")]);
|
package/dist/features/routes.js
CHANGED
|
@@ -26,8 +26,9 @@ __export(routes_exports, {
|
|
|
26
26
|
});
|
|
27
27
|
module.exports = __toCommonJS(routes_exports);
|
|
28
28
|
var import_constants = require("../constants");
|
|
29
|
+
var import_utils = require("../utils");
|
|
29
30
|
var import_core = require("@umijs/core");
|
|
30
|
-
var
|
|
31
|
+
var import_utils2 = require("@umijs/core/dist/route/utils");
|
|
31
32
|
var import_path = __toESM(require("path"));
|
|
32
33
|
var import_pluralize = require("pluralize");
|
|
33
34
|
var import_plugin_utils = require("umi/plugin-utils");
|
|
@@ -61,18 +62,6 @@ function flatRoute(route, docLayoutId) {
|
|
|
61
62
|
route.path = route.path === "*" ? route.path : route.absPath.slice(1);
|
|
62
63
|
}
|
|
63
64
|
}
|
|
64
|
-
function getClientPageFile(file, cwd) {
|
|
65
|
-
let clientFile;
|
|
66
|
-
try {
|
|
67
|
-
clientFile = import_plugin_utils.resolve.sync(`dumi/dist/${file}`, {
|
|
68
|
-
basedir: cwd,
|
|
69
|
-
preserveSymlinks: false
|
|
70
|
-
});
|
|
71
|
-
} catch {
|
|
72
|
-
clientFile = require.resolve(`../${file}`);
|
|
73
|
-
}
|
|
74
|
-
return (0, import_plugin_utils.winPath)(clientFile);
|
|
75
|
-
}
|
|
76
65
|
var routes_default = (api) => {
|
|
77
66
|
var _a, _b, _c;
|
|
78
67
|
const extraWatchPaths = [
|
|
@@ -159,7 +148,7 @@ var routes_default = (api) => {
|
|
|
159
148
|
atomFiles.forEach((file) => {
|
|
160
149
|
const routeFile = (0, import_plugin_utils.winPath)(import_path.default.join((0, import_pluralize.plural)(type), file));
|
|
161
150
|
const routePath = routeFile.replace(/(\/index|\/README)?\.md$/, "").replace(/\./g, "/");
|
|
162
|
-
const routeId = (0,
|
|
151
|
+
const routeId = (0, import_utils2.createRouteId)(routeFile);
|
|
163
152
|
routes[routeId] = {
|
|
164
153
|
id: routeId,
|
|
165
154
|
path: routePath,
|
|
@@ -184,7 +173,7 @@ var routes_default = (api) => {
|
|
|
184
173
|
path: "*",
|
|
185
174
|
absPath: "/*",
|
|
186
175
|
parentId: docLayoutId,
|
|
187
|
-
file:
|
|
176
|
+
file: (0, import_utils.getClientDistFile)("dist/client/pages/404", api.cwd)
|
|
188
177
|
};
|
|
189
178
|
}
|
|
190
179
|
routes["demo-render"] = {
|
|
@@ -192,7 +181,7 @@ var routes_default = (api) => {
|
|
|
192
181
|
path: `${import_constants.SP_ROUTE_PREFIX}demos/:id`,
|
|
193
182
|
absPath: `/${import_constants.SP_ROUTE_PREFIX}demos/:id`,
|
|
194
183
|
parentId: demoLayoutId,
|
|
195
|
-
file:
|
|
184
|
+
file: (0, import_utils.getClientDistFile)("dist/client/pages/Demo", api.cwd),
|
|
196
185
|
prerender: false
|
|
197
186
|
};
|
|
198
187
|
return routes;
|
|
@@ -26,13 +26,13 @@ __export(theme_exports, {
|
|
|
26
26
|
});
|
|
27
27
|
module.exports = __toCommonJS(theme_exports);
|
|
28
28
|
var import_constants = require("../../constants");
|
|
29
|
+
var import_utils = require("../../utils");
|
|
29
30
|
var import_bundler_utils = require("@umijs/bundler-utils");
|
|
30
31
|
var import_fs = __toESM(require("fs"));
|
|
31
32
|
var import_path = __toESM(require("path"));
|
|
32
33
|
var import_plugin_utils = require("umi/plugin-utils");
|
|
33
34
|
var import_derivative = require("../derivative");
|
|
34
35
|
var import_loader = __toESM(require("./loader"));
|
|
35
|
-
var DEFAULT_THEME_PATH = import_path.default.join(__dirname, "../../../theme-default");
|
|
36
36
|
function getPkgThemeName(api) {
|
|
37
37
|
const validDeps = Object.assign({}, api.pkg.dependencies, api.pkg.devDependencies);
|
|
38
38
|
const pkgThemeName = Object.keys(validDeps).find((pkg) => pkg.split("/").pop().startsWith(import_constants.THEME_PREFIX));
|
|
@@ -40,7 +40,10 @@ function getPkgThemeName(api) {
|
|
|
40
40
|
}
|
|
41
41
|
function getPkgThemePath(api) {
|
|
42
42
|
const pkgThemeName = getPkgThemeName(api);
|
|
43
|
-
return pkgThemeName && import_path.default.dirname(
|
|
43
|
+
return pkgThemeName && import_path.default.dirname(import_plugin_utils.resolve.sync(`${pkgThemeName}/package.json`, {
|
|
44
|
+
basedir: api.cwd,
|
|
45
|
+
preserveSymlinks: true
|
|
46
|
+
}));
|
|
44
47
|
}
|
|
45
48
|
function getModuleExports(modulePath) {
|
|
46
49
|
return (0, import_bundler_utils.parseModuleSync)({
|
|
@@ -49,6 +52,7 @@ function getModuleExports(modulePath) {
|
|
|
49
52
|
})[1];
|
|
50
53
|
}
|
|
51
54
|
var theme_default = (api) => {
|
|
55
|
+
const DEFAULT_THEME_PATH = import_path.default.join((0, import_utils.getClientDistFile)("package.json", api.cwd), "../theme-default");
|
|
52
56
|
const defaultThemeData = (0, import_loader.default)(DEFAULT_THEME_PATH);
|
|
53
57
|
const pkgThemePath = getPkgThemePath(api);
|
|
54
58
|
const pkgThemeData = (0, import_plugin_utils.deepmerge)(defaultThemeData, pkgThemePath ? (0, import_loader.default)(import_path.default.join(pkgThemePath, "dist")) : {});
|
|
@@ -79,6 +79,7 @@ function tryMarkDemoNode(node, opts) {
|
|
|
79
79
|
function rehypeDemo(opts) {
|
|
80
80
|
return async (tree, vFile) => {
|
|
81
81
|
const deferrers = [];
|
|
82
|
+
const demoIds = [];
|
|
82
83
|
const replaceNodes = [];
|
|
83
84
|
let index = 0;
|
|
84
85
|
visit(tree, "element", (node) => {
|
|
@@ -129,7 +130,7 @@ function rehypeDemo(opts) {
|
|
|
129
130
|
if (isElement(node, "p") && ((_a = node.data) == null ? void 0 : _a[DEMO_NODE_CONTAINER])) {
|
|
130
131
|
const demosPropData = [];
|
|
131
132
|
node.children.forEach((codeNode) => {
|
|
132
|
-
var _a2;
|
|
133
|
+
var _a2, _b;
|
|
133
134
|
if (isElement(codeNode, "code")) {
|
|
134
135
|
const codeType = codeNode.data.type;
|
|
135
136
|
const techStack = codeNode.data.techStack;
|
|
@@ -146,11 +147,12 @@ function rehypeDemo(opts) {
|
|
|
146
147
|
if (codeType === "external") {
|
|
147
148
|
const chunkName = [vFile.data.frontmatter.atomId, "demos"].filter(Boolean).join("__");
|
|
148
149
|
parseOpts.fileAbsPath = (0, import_plugin_utils.winPath)(codeNode.properties.src);
|
|
149
|
-
|
|
150
|
+
let localId = ((_a2 = codeNode.properties) == null ? void 0 : _a2.id) ?? import_path.default.parse(parseOpts.fileAbsPath.replace(/\/index\.(j|t)sx?$/, "")).name;
|
|
151
|
+
parseOpts.id = getCodeId(opts.cwd, opts.fileAbsPath, localId, vFile.data.frontmatter.atomId);
|
|
150
152
|
component = `React.lazy(() => import( /* webpackChunkName: "${chunkName}" */ '${(0, import_plugin_utils.winPath)(parseOpts.fileAbsPath)}?techStack=${techStack.name}'))`;
|
|
151
153
|
if (codeValue)
|
|
152
154
|
codeNode.properties.title = codeValue;
|
|
153
|
-
(
|
|
155
|
+
(_b = codeNode.properties).filename ?? (_b.filename = (0, import_plugin_utils.winPath)(import_path.default.relative(opts.cwd, parseOpts.fileAbsPath)));
|
|
154
156
|
} else {
|
|
155
157
|
parseOpts.fileAbsPath = opts.fileAbsPath.replace(".md", ".tsx");
|
|
156
158
|
parseOpts.id = getCodeId(opts.cwd, opts.fileAbsPath, String(index++), vFile.data.frontmatter.atomId);
|
|
@@ -160,8 +162,15 @@ function rehypeDemo(opts) {
|
|
|
160
162
|
});
|
|
161
163
|
}
|
|
162
164
|
const propDemo = { id: parseOpts.id };
|
|
165
|
+
demoIds.push(parseOpts.id);
|
|
163
166
|
deferrers.push((0, import_block.default)(parseOpts).then(async ({ asset, sources, frontmatter }) => {
|
|
164
|
-
var _a3,
|
|
167
|
+
var _a3, _b2, _c;
|
|
168
|
+
if (demoIds.indexOf(parseOpts.id) !== demoIds.lastIndexOf(parseOpts.id)) {
|
|
169
|
+
const startLine = (_a3 = node.position) == null ? void 0 : _a3.start.line;
|
|
170
|
+
const suffix = startLine ? `:${startLine}` : "";
|
|
171
|
+
import_plugin_utils.logger.warn(`Duplicate demo id found due to filename conflicts, please consider adding a unique id to code tag to resolve this.
|
|
172
|
+
at ${opts.fileAbsPath}${suffix}`);
|
|
173
|
+
}
|
|
165
174
|
const { src, className, ...restAttrs } = codeNode.properties || {};
|
|
166
175
|
const validAssetAttrs = [
|
|
167
176
|
"title",
|
|
@@ -183,14 +192,14 @@ function rehypeDemo(opts) {
|
|
|
183
192
|
if (originalProps[key])
|
|
184
193
|
asset[key] = originalProps[key];
|
|
185
194
|
});
|
|
186
|
-
if (/ inline/.test(String((
|
|
195
|
+
if (/ inline/.test(String((_b2 = codeNode.data) == null ? void 0 : _b2.meta)) || originalProps.inline) {
|
|
187
196
|
propDemo.inline = true;
|
|
188
197
|
return {
|
|
189
198
|
id: asset.id,
|
|
190
199
|
component
|
|
191
200
|
};
|
|
192
201
|
}
|
|
193
|
-
Object.assign(previewerProps, await ((
|
|
202
|
+
Object.assign(previewerProps, await ((_c = techStack.generatePreviewerProps) == null ? void 0 : _c.call(techStack, originalProps, techStackOpts)) || originalProps);
|
|
194
203
|
if (previewerProps.description) {
|
|
195
204
|
const { unified } = await import("unified");
|
|
196
205
|
const { default: remarkParse } = await import("remark-parse");
|
|
@@ -37,12 +37,12 @@ var SKIP;
|
|
|
37
37
|
function rehypeLink(opts) {
|
|
38
38
|
return (tree) => {
|
|
39
39
|
visit(tree, "element", (node, i, parent) => {
|
|
40
|
-
var _a;
|
|
41
|
-
if (node.tagName === "a" && typeof ((_a = node.properties) == null ? void 0 : _a.href) === "string") {
|
|
40
|
+
var _a, _b, _c;
|
|
41
|
+
if (node.tagName === "a" && typeof ((_a = node.properties) == null ? void 0 : _a.href) === "string" && !((_b = node.properties) == null ? void 0 : _b.target) && !((_c = node.properties) == null ? void 0 : _c.download)) {
|
|
42
42
|
const href = node.properties.href;
|
|
43
43
|
const parsedUrl = import_url.default.parse(href);
|
|
44
44
|
const hostAbsPath = (0, import_tabs.getHostForTabRouteFile)(opts.fileAbsPath);
|
|
45
|
-
if (parsedUrl.
|
|
45
|
+
if (parsedUrl.protocol || href.startsWith("//"))
|
|
46
46
|
return SKIP;
|
|
47
47
|
if (/\.md$/i.test(parsedUrl.pathname)) {
|
|
48
48
|
const { routes } = opts;
|
|
@@ -52,7 +52,7 @@ function rehypeLink(opts) {
|
|
|
52
52
|
parsedUrl.pathname = routes[key].absPath;
|
|
53
53
|
}
|
|
54
54
|
});
|
|
55
|
-
} else if (
|
|
55
|
+
} else if (parsedUrl.pathname && /^[^/]+/.test(parsedUrl.pathname)) {
|
|
56
56
|
const routes = Object.values(opts.routes);
|
|
57
57
|
const basePath = routes.find((route) => route.file === hostAbsPath).absPath;
|
|
58
58
|
const htmlTargetPath = import_url.default.resolve(basePath, parsedUrl.pathname);
|
package/dist/utils.d.ts
CHANGED
|
@@ -34,4 +34,8 @@ export declare function tryFatherBuildConfigs(cwd: string): Promise<any[]>;
|
|
|
34
34
|
* get root dir for monorepo project
|
|
35
35
|
*/
|
|
36
36
|
export declare function getProjectRoot(cwd: string): string;
|
|
37
|
+
/**
|
|
38
|
+
* get dumi client dist file and preserve symlink(pnpm, tnpm & etc.) to make chunk name clean
|
|
39
|
+
*/
|
|
40
|
+
export declare function getClientDistFile(file: string, cwd: string): string;
|
|
37
41
|
export {};
|
package/dist/utils.js
CHANGED
|
@@ -23,6 +23,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
23
23
|
var utils_exports = {};
|
|
24
24
|
__export(utils_exports, {
|
|
25
25
|
getCache: () => getCache,
|
|
26
|
+
getClientDistFile: () => getClientDistFile,
|
|
26
27
|
getFileContentByRegExp: () => getFileContentByRegExp,
|
|
27
28
|
getFileRangeLines: () => getFileRangeLines,
|
|
28
29
|
getProjectRoot: () => getProjectRoot,
|
|
@@ -117,9 +118,22 @@ function getProjectRoot(cwd) {
|
|
|
117
118
|
}
|
|
118
119
|
return (0, import_plugin_utils.winPath)(cwd);
|
|
119
120
|
}
|
|
121
|
+
function getClientDistFile(file, cwd) {
|
|
122
|
+
let clientFile;
|
|
123
|
+
try {
|
|
124
|
+
clientFile = import_plugin_utils.resolve.sync(`dumi/${file}`, {
|
|
125
|
+
basedir: cwd,
|
|
126
|
+
preserveSymlinks: true
|
|
127
|
+
});
|
|
128
|
+
} catch {
|
|
129
|
+
clientFile = require.resolve(`../${file}`);
|
|
130
|
+
}
|
|
131
|
+
return (0, import_plugin_utils.winPath)(clientFile);
|
|
132
|
+
}
|
|
120
133
|
// Annotate the CommonJS export names for ESM import in node:
|
|
121
134
|
0 && (module.exports = {
|
|
122
135
|
getCache,
|
|
136
|
+
getClientDistFile,
|
|
123
137
|
getFileContentByRegExp,
|
|
124
138
|
getFileRangeLines,
|
|
125
139
|
getProjectRoot,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dumi",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.15",
|
|
4
4
|
"description": "📖 Documentation Generator of React Component",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"generator",
|
|
@@ -80,8 +80,8 @@
|
|
|
80
80
|
"@swc/core": "^1.2.224",
|
|
81
81
|
"@types/hast": "^2.3.4",
|
|
82
82
|
"@types/mdast": "^3.0.10",
|
|
83
|
-
"@umijs/bundler-utils": "^4.0.
|
|
84
|
-
"@umijs/core": "^4.0.
|
|
83
|
+
"@umijs/bundler-utils": "^4.0.55",
|
|
84
|
+
"@umijs/core": "^4.0.55",
|
|
85
85
|
"animated-scroll-to": "^2.3.0",
|
|
86
86
|
"classnames": "2.3.2",
|
|
87
87
|
"codesandbox": "^2.2.3",
|
|
@@ -122,7 +122,7 @@
|
|
|
122
122
|
"remark-rehype": "^10.1.0",
|
|
123
123
|
"sass": "^1.55.0",
|
|
124
124
|
"sitemap": "^7.1.1",
|
|
125
|
-
"umi": "^4.0.
|
|
125
|
+
"umi": "^4.0.55",
|
|
126
126
|
"unified": "^10.1.2",
|
|
127
127
|
"unist-util-visit": "^4.1.0",
|
|
128
128
|
"unist-util-visit-parents": "^5.1.1",
|
|
@@ -141,7 +141,7 @@
|
|
|
141
141
|
"@types/pluralize": "^0.0.29",
|
|
142
142
|
"@types/react": "^18.0.16",
|
|
143
143
|
"@types/react-copy-to-clipboard": "^5.0.4",
|
|
144
|
-
"@umijs/lint": "^4.0.
|
|
144
|
+
"@umijs/lint": "^4.0.55",
|
|
145
145
|
"@umijs/plugins": "4.0.32",
|
|
146
146
|
"dumi-theme-mobile": "workspace:*",
|
|
147
147
|
"eslint": "^8.20.0",
|
|
@@ -1,13 +1,18 @@
|
|
|
1
|
-
import { useSidebarData } from 'dumi';
|
|
1
|
+
import { useSidebarData, useSiteData } from 'dumi';
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import "./heti.scss";
|
|
4
4
|
import "./index.less";
|
|
5
5
|
|
|
6
6
|
var Content = function Content(props) {
|
|
7
7
|
var sidebar = useSidebarData();
|
|
8
|
+
|
|
9
|
+
var _useSiteData = useSiteData(),
|
|
10
|
+
themeConfig = _useSiteData.themeConfig;
|
|
11
|
+
|
|
8
12
|
return /*#__PURE__*/React.createElement("div", {
|
|
9
13
|
className: "dumi-default-content",
|
|
10
|
-
"data-no-sidebar": !sidebar || undefined
|
|
14
|
+
"data-no-sidebar": !sidebar || undefined,
|
|
15
|
+
"data-no-footer": themeConfig.footer === false || undefined
|
|
11
16
|
}, props.children);
|
|
12
17
|
};
|
|
13
18
|
|
|
@@ -51,6 +51,7 @@
|
|
|
51
51
|
// table
|
|
52
52
|
table {
|
|
53
53
|
width: 100%;
|
|
54
|
+
table-layout: auto;
|
|
54
55
|
}
|
|
55
56
|
|
|
56
57
|
th {
|
|
@@ -157,12 +158,20 @@
|
|
|
157
158
|
background-color: lighten(@c-site-bg-dark, 3%);
|
|
158
159
|
}
|
|
159
160
|
|
|
161
|
+
&[data-no-footer] {
|
|
162
|
+
padding-bottom: @s-content-padding;
|
|
163
|
+
}
|
|
164
|
+
|
|
160
165
|
@media @mobile {
|
|
161
166
|
max-width: initial;
|
|
162
167
|
margin: 0 -24px;
|
|
163
168
|
padding: 24px 24px 0;
|
|
164
169
|
border-radius: 0;
|
|
165
170
|
box-shadow: none;
|
|
171
|
+
|
|
172
|
+
&[data-no-footer] {
|
|
173
|
+
padding: 24px;
|
|
174
|
+
}
|
|
166
175
|
}
|
|
167
176
|
}
|
|
168
177
|
|
|
@@ -174,4 +183,12 @@
|
|
|
174
183
|
min-height: calc(100vh - @s-header-height-m);
|
|
175
184
|
}
|
|
176
185
|
}
|
|
186
|
+
|
|
187
|
+
&[data-no-sidebar][data-no-footer] {
|
|
188
|
+
margin-bottom: @s-content-padding;
|
|
189
|
+
|
|
190
|
+
@media @mobile {
|
|
191
|
+
margin-bottom: 24px;
|
|
192
|
+
}
|
|
193
|
+
}
|
|
177
194
|
}
|
|
@@ -13,7 +13,7 @@ function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Sy
|
|
|
13
13
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
14
14
|
|
|
15
15
|
import { Scrollspy as ScrollSpy } from '@makotot/ghostui/src/Scrollspy';
|
|
16
|
-
import { Link, useLocation, useRouteMeta, useSiteData } from 'dumi';
|
|
16
|
+
import { Link, useLocation, useRouteMeta, useSiteData, useTabMeta } from 'dumi';
|
|
17
17
|
import React, { useEffect, useRef, useState } from 'react';
|
|
18
18
|
import "./index.less";
|
|
19
19
|
|
|
@@ -23,6 +23,7 @@ var Toc = function Toc() {
|
|
|
23
23
|
search = _useLocation.search;
|
|
24
24
|
|
|
25
25
|
var meta = useRouteMeta();
|
|
26
|
+
var tabMeta = useTabMeta();
|
|
26
27
|
|
|
27
28
|
var _useSiteData = useSiteData(),
|
|
28
29
|
loading = _useSiteData.loading;
|
|
@@ -32,18 +33,26 @@ var Toc = function Toc() {
|
|
|
32
33
|
var _useState = useState([]),
|
|
33
34
|
_useState2 = _slicedToArray(_useState, 2),
|
|
34
35
|
sectionRefs = _useState2[0],
|
|
35
|
-
setSectionRefs = _useState2[1];
|
|
36
|
+
setSectionRefs = _useState2[1];
|
|
36
37
|
|
|
38
|
+
var memoToc = React.useMemo(function () {
|
|
39
|
+
var toc = meta.toc;
|
|
37
40
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
41
|
+
if (tabMeta) {
|
|
42
|
+
toc = tabMeta.toc;
|
|
43
|
+
} // only render h2 ~ h4
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
return toc.filter(function (_ref) {
|
|
47
|
+
var depth = _ref.depth;
|
|
48
|
+
return depth > 1 && depth < 4;
|
|
49
|
+
});
|
|
50
|
+
}, [meta, tabMeta]);
|
|
42
51
|
useEffect(function () {
|
|
43
52
|
// wait for page component ready (DOM ready)
|
|
44
53
|
if (!loading) {
|
|
45
54
|
// find all valid headings as ref elements
|
|
46
|
-
var refs =
|
|
55
|
+
var refs = memoToc.map(function (_ref2) {
|
|
47
56
|
var id = _ref2.id;
|
|
48
57
|
return {
|
|
49
58
|
current: document.getElementById(id)
|
|
@@ -60,11 +69,11 @@ var Toc = function Toc() {
|
|
|
60
69
|
if (currentElementIndexInViewport > -1) prevIndexRef.current = currentElementIndexInViewport;
|
|
61
70
|
return /*#__PURE__*/React.createElement("ul", {
|
|
62
71
|
className: "dumi-default-toc"
|
|
63
|
-
},
|
|
72
|
+
}, memoToc.filter(function (_ref4) {
|
|
64
73
|
var depth = _ref4.depth;
|
|
65
74
|
return depth > 1 && depth < 4;
|
|
66
75
|
}).map(function (item, i) {
|
|
67
|
-
var link = "#".concat(encodeURIComponent(item.id));
|
|
76
|
+
var link = "".concat(search, "#").concat(encodeURIComponent(item.id));
|
|
68
77
|
var activeIndex = currentElementIndexInViewport > -1 ? currentElementIndexInViewport : prevIndexRef.current;
|
|
69
78
|
return /*#__PURE__*/React.createElement("li", {
|
|
70
79
|
key: item.id,
|