@umijs/plugin-docs 4.0.0-rc.15 → 4.0.0-rc.18

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.
@@ -43,6 +43,7 @@ export default (props: any) => {
43
43
  components: props.components,
44
44
  themeConfig: props.themeConfig,
45
45
  location: props.location,
46
+ history: props.history,
46
47
  }}
47
48
  >
48
49
  <div
@@ -95,9 +95,19 @@ export default () => {
95
95
  className={cx(
96
96
  'absolute transition-all duration-500 top-12 w-96 rounded-lg',
97
97
  'cursor-pointer shadow overflow-hidden',
98
- result.length > 0 && isFocused ? 'max-h-80' : 'max-h-0',
98
+ keyword && isFocused ? 'max-h-80' : 'max-h-0',
99
99
  )}
100
100
  >
101
+ {keyword && result.length === 0 && (
102
+ <div>
103
+ <p
104
+ className="p-2 bg-white hover:bg-gray-50 transition
105
+ duration-300 group-focus:bg-blue-200 dark:bg-gray-700"
106
+ >
107
+ {render('No result for')} "{keyword}"
108
+ </p>
109
+ </div>
110
+ )}
101
111
  {result.map((r, i) => (
102
112
  <components.Link
103
113
  to={(isFromPath ? currentLanguage?.locale : '') + r.href}
@@ -63,7 +63,8 @@ export default (props: SidebarProps) => {
63
63
  return (
64
64
  <components.Link
65
65
  key={route.path}
66
- to={route.path}
66
+ to={to.startsWith('/') ? to : `/${to}`}
67
+ prefetch
67
68
  onClick={() =>
68
69
  props.setMenuOpened && props.setMenuOpened((o) => !o)
69
70
  }
@@ -37,6 +37,9 @@ interface IContext {
37
37
  hash: string;
38
38
  key: string;
39
39
  };
40
+ history: {
41
+ push(to: string, state?: any): void;
42
+ };
40
43
  }
41
44
 
42
45
  export const ThemeContext = React.createContext<IContext | null>(null);
@@ -1,5 +1,5 @@
1
1
  /*
2
- ! tailwindcss v3.0.23 | MIT License | https://tailwindcss.com
2
+ ! tailwindcss v3.0.24 | MIT License | https://tailwindcss.com
3
3
  */
4
4
 
5
5
  /*
@@ -1,5 +1,4 @@
1
1
  // @ts-ignore
2
- import { history } from 'umi';
3
2
  import { useThemeContext } from './context';
4
3
 
5
4
  interface useLanguageResult {
@@ -11,7 +10,7 @@ interface useLanguageResult {
11
10
  }
12
11
 
13
12
  function useLanguage(): useLanguageResult {
14
- const { themeConfig, location } = useThemeContext()!;
13
+ const { themeConfig, location, history } = useThemeContext()!;
15
14
 
16
15
  const languages = themeConfig.i18n;
17
16
  let currentLanguage: { locale: string; text: string } | undefined = undefined;
package/dist/compiler.js CHANGED
@@ -4,8 +4,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.compile = void 0;
7
- const plugin_utils_1 = require("umi/plugin-utils");
8
7
  const rehype_pretty_code_1 = __importDefault(require("rehype-pretty-code"));
8
+ const plugin_utils_1 = require("umi/plugin-utils");
9
9
  // @ts-ignore
10
10
  const mdx_1 = require("../compiled/@mdx-js/mdx");
11
11
  // @ts-ignore
@@ -48,8 +48,11 @@ function MDXContent(props = {}) {
48
48
 
49
49
  useEffect(() => {
50
50
  if (window.location.hash.length !== 0) {
51
- const hash = window.location.hash;
52
- document.getElementById(hash.slice(1))?.scrollIntoView();
51
+ // 为了右侧内容区能正常跳转
52
+ const hash = decodeURIComponent(window.location.hash);
53
+ setTimeout(() => {
54
+ document.getElementById(hash.slice(1))?.scrollIntoView();
55
+ }, 100);
53
56
  } else {
54
57
  window.scrollTo(0, 0);
55
58
  }
package/dist/index.js CHANGED
@@ -125,7 +125,7 @@ export { ${exports
125
125
  path: 'Layout.tsx',
126
126
  content: `
127
127
  import React from 'react';
128
- import { useOutlet, useAppData, useLocation, Link } from 'umi';
128
+ import { useOutlet, useAppData, useLocation, Link, history } from 'umi';
129
129
  import { $Layout as Layout } from '${(0, utils_1.winPath)(require.resolve('../client/theme-doc/index.ts'))}';
130
130
  ${themeExists
131
131
  ? `import themeConfig from '${themeConfigPath}'`
@@ -138,12 +138,12 @@ export default () => {
138
138
  const appData = useAppData();
139
139
  const location = useLocation();
140
140
  return (
141
- <Layout appData={appData} components={{Link}} themeConfig={themeConfig} location={location}>
141
+ <Layout appData={appData} components={{Link}} themeConfig={themeConfig} location={location} history={history}>
142
142
  <div>{ outlet }</div>
143
143
  </Layout>
144
144
  );
145
145
  };
146
- `,
146
+ `,
147
147
  });
148
148
  });
149
149
  };
package/dist/markdown.js CHANGED
@@ -2,7 +2,9 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.parseTitle = void 0;
4
4
  function parseTitle(opts) {
5
- const lines = opts.content.split('\n');
5
+ const lines = opts.content
6
+ .replace(/{[\n\s\t]*\/\*[\s\S]*?\*\/[\n\s\t]*}/g, '')
7
+ .split('\n');
6
8
  let i = 0;
7
9
  const ret = [];
8
10
  while (i < lines.length) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@umijs/plugin-docs",
3
- "version": "4.0.0-rc.15",
3
+ "version": "4.0.0-rc.18",
4
4
  "description": "@umijs/plugin-docs",
5
5
  "homepage": "https://github.com/umijs/umi-next/tree/master/packages/plugin-docs#readme",
6
6
  "bugs": "https://github.com/umijs/umi-next/issues",
@@ -20,7 +20,7 @@
20
20
  "build": "pnpm tsc",
21
21
  "build:css": "tailwindcss -i ./client/theme-doc/tailwind.css -o ./client/theme-doc/tailwind.out.css",
22
22
  "build:deps": "umi-scripts bundleDeps",
23
- "build:extra": "pnpm build:css && pnpm build:deps",
23
+ "build:extra": "pnpm build:css",
24
24
  "dev": "pnpm build -- --watch",
25
25
  "dev:css": "pnpm build:css -- --watch",
26
26
  "test": "umi-scripts jest-turbo"
@@ -28,7 +28,7 @@
28
28
  "dependencies": {
29
29
  "keymaster": "1.6.2",
30
30
  "react-helmet": "^6.1.0",
31
- "rehype-pretty-code": "^0.3.0",
31
+ "rehype-pretty-code": "^0.3.1",
32
32
  "shiki": "^0.10.1"
33
33
  },
34
34
  "devDependencies": {
@@ -38,8 +38,8 @@
38
38
  "classnames": "^2.3.1",
39
39
  "rehype-slug": "5.0.1",
40
40
  "remark-gfm": "^3.0.1",
41
- "tailwindcss": "^3.0.23",
42
- "umi": "4.0.0-rc.15"
41
+ "tailwindcss": "^3.0.24",
42
+ "umi": "4.0.0-rc.18"
43
43
  },
44
44
  "publishConfig": {
45
45
  "access": "public"