@umijs/plugin-docs 4.0.0-canary.20220507.2 → 4.0.0-canary.20220516.3

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}
@@ -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,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/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,7 +138,7 @@ 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
  );
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-canary.20220507.2",
3
+ "version": "4.0.0-canary.20220516.3",
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"
@@ -39,7 +39,7 @@
39
39
  "rehype-slug": "5.0.1",
40
40
  "remark-gfm": "^3.0.1",
41
41
  "tailwindcss": "^3.0.24",
42
- "umi": "4.0.0-canary.20220507.2"
42
+ "umi": "4.0.0-canary.20220516.3"
43
43
  },
44
44
  "publishConfig": {
45
45
  "access": "public"