@umijs/plugin-docs 4.0.0-rc.9 → 4.0.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.
- package/client/theme-doc/Head.tsx +28 -16
- package/client/theme-doc/LangSwitch.tsx +3 -1
- package/client/theme-doc/Layout.tsx +31 -24
- package/client/theme-doc/Logo.tsx +9 -5
- package/client/theme-doc/NavBar.tsx +101 -18
- package/client/theme-doc/Search.tsx +52 -22
- package/client/theme-doc/Sidebar.tsx +6 -3
- package/client/theme-doc/ThemeSwitch.tsx +24 -0
- package/client/theme-doc/Toc.tsx +12 -14
- package/client/theme-doc/components/Announcement.tsx +1 -0
- package/client/theme-doc/components/Features.tsx +1 -1
- package/client/theme-doc/components/Message.tsx +31 -19
- package/client/theme-doc/context.ts +11 -1
- package/client/theme-doc/firefox-polyfill.css +4 -4
- package/client/theme-doc/icons/link.svg +1 -0
- package/client/theme-doc/tailwind.css +127 -27
- package/client/theme-doc/tailwind.out.css +548 -141
- package/client/theme-doc/useLanguage.ts +8 -3
- package/client/theme-doc/utils/getLinkFromTitle.ts +15 -0
- package/client/theme-doc/utils/getTocTitle.ts +9 -0
- package/compiled/@mdx-js/mdx/index.js +1 -1
- package/compiled/remark-gfm/LICENSE +22 -0
- package/compiled/remark-gfm/index.js +1 -0
- package/compiled/remark-gfm/package.json +1 -0
- package/dist/compiler.d.ts +1 -0
- package/dist/compiler.js +55 -21
- package/dist/index.js +14 -8
- package/dist/loader.js +14 -15
- package/dist/markdown.js +3 -1
- package/package.json +16 -10
|
@@ -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;
|
|
@@ -57,7 +56,13 @@ function useLanguage(): useLanguageResult {
|
|
|
57
56
|
}
|
|
58
57
|
|
|
59
58
|
function render(key: string) {
|
|
60
|
-
if (!
|
|
59
|
+
if (!themeConfig.locales || Object.keys(themeConfig.locales).length === 0)
|
|
60
|
+
return key;
|
|
61
|
+
if (!currentLanguage) {
|
|
62
|
+
return (
|
|
63
|
+
themeConfig.locales[Object.keys(themeConfig.locales)[0]].key || key
|
|
64
|
+
);
|
|
65
|
+
}
|
|
61
66
|
if (!themeConfig.locales[currentLanguage.locale]) return key;
|
|
62
67
|
return themeConfig.locales[currentLanguage.locale][key] || key;
|
|
63
68
|
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export default function getLinkFromTitle(title: string) {
|
|
2
|
+
return (
|
|
3
|
+
title
|
|
4
|
+
.toLowerCase()
|
|
5
|
+
.trim()
|
|
6
|
+
// not remove html tags
|
|
7
|
+
// .replace(/<[!\/a-z].*?>/gi, '')
|
|
8
|
+
// remove unwanted chars
|
|
9
|
+
.replace(
|
|
10
|
+
/[\u2000-\u206F\u2E00-\u2E7F\\'!!"#$%&()()*+,,.。/::;;<=>??@[\]^`{|}~]/g,
|
|
11
|
+
'',
|
|
12
|
+
)
|
|
13
|
+
.replace(/\s/g, '-')
|
|
14
|
+
);
|
|
15
|
+
}
|