@rspress/core 1.0.1 → 1.1.0
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/README.md +2 -25
- package/dist/index.js +64 -16
- package/dist/index.js.map +1 -1
- package/dist/loader.d.ts +1 -0
- package/dist/loader.js +24 -105
- package/dist/loader.js.map +1 -1
- package/dist/theme/bundle.css +291 -293
- package/dist/theme/bundle.d.ts +1 -1
- package/dist/theme/bundle.js +567 -511
- package/dist/theme/bundle.js.map +1 -1
- package/package.json +14 -14
- package/src/theme-default/components/HomeHero/index.tsx +5 -4
- package/src/theme-default/components/Nav/NavBarTitle.tsx +2 -1
- package/src/theme-default/components/Nav/NavMenuGroup.tsx +1 -14
- package/src/theme-default/components/Nav/NavTranslations.tsx +16 -0
- package/src/theme-default/components/Nav/NavVersions.tsx +16 -0
- package/src/theme-default/components/Nav/index.tsx +12 -50
- package/src/theme-default/components/Nav/menuDataHooks.tsx +75 -0
- package/src/theme-default/components/{NavScreenMenuGroup → NavScreen}/NavScreenMenuGroup.tsx +1 -1
- package/src/theme-default/components/NavScreen/index.module.scss +42 -0
- package/src/theme-default/components/NavScreen/index.tsx +26 -54
- package/src/theme-default/components/Overview/index.module.scss +4 -5
- package/src/theme-default/components/Overview/index.tsx +7 -2
- package/src/theme-default/components/Search/index.module.scss +2 -0
- package/src/theme-default/components/Search/index.tsx +11 -3
- package/src/theme-default/components/Sidebar/index.tsx +1 -1
- package/src/theme-default/components/SocialLinks/HiddenLinks.tsx +1 -1
- package/src/theme-default/components/SocialLinks/ShownLinks.tsx +1 -1
- package/src/theme-default/layout/DocLayout/docComponents/code.tsx +4 -27
- package/src/theme-default/layout/DocLayout/index.module.scss +1 -0
- package/src/theme-default/layout/DocLayout/index.tsx +15 -5
- package/src/theme-default/layout/Layout/index.tsx +25 -1
- package/src/theme-default/logic/useHiddenNav.ts +4 -1
- package/src/theme-default/components/NavScreenMenuGroup/index.module.scss +0 -41
|
@@ -1,17 +1,5 @@
|
|
|
1
1
|
import { PrismLight as SyntaxHighlighter } from 'react-syntax-highlighter';
|
|
2
|
-
import
|
|
3
|
-
import js from 'react-syntax-highlighter/dist/esm/languages/prism/javascript';
|
|
4
|
-
import ts from 'react-syntax-highlighter/dist/esm/languages/prism/typescript';
|
|
5
|
-
import tsx from 'react-syntax-highlighter/dist/esm/languages/prism/tsx';
|
|
6
|
-
import json from 'react-syntax-highlighter/dist/esm/languages/prism/json';
|
|
7
|
-
import css from 'react-syntax-highlighter/dist/esm/languages/prism/css';
|
|
8
|
-
import scss from 'react-syntax-highlighter/dist/esm/languages/prism/scss';
|
|
9
|
-
import less from 'react-syntax-highlighter/dist/esm/languages/prism/less';
|
|
10
|
-
import xml from 'react-syntax-highlighter/dist/esm/languages/prism/xml-doc';
|
|
11
|
-
import yaml from 'react-syntax-highlighter/dist/esm/languages/prism/yaml';
|
|
12
|
-
import diff from 'react-syntax-highlighter/dist/esm/languages/prism/diff';
|
|
13
|
-
import bash from 'react-syntax-highlighter/dist/esm/languages/prism/bash';
|
|
14
|
-
import markdown from 'react-syntax-highlighter/dist/esm/languages/prism/markdown';
|
|
2
|
+
import languagesInfo from 'virtual-prism-languages';
|
|
15
3
|
import copy from 'copy-to-clipboard';
|
|
16
4
|
import { useRef } from 'react';
|
|
17
5
|
import style from './prisim-theme';
|
|
@@ -27,20 +15,9 @@ export interface CodeProps {
|
|
|
27
15
|
}
|
|
28
16
|
|
|
29
17
|
function registerLanguages() {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
SyntaxHighlighter.registerLanguage('js', js);
|
|
34
|
-
SyntaxHighlighter.registerLanguage('ts', ts);
|
|
35
|
-
SyntaxHighlighter.registerLanguage('json', json);
|
|
36
|
-
SyntaxHighlighter.registerLanguage('css', css);
|
|
37
|
-
SyntaxHighlighter.registerLanguage('scss', scss);
|
|
38
|
-
SyntaxHighlighter.registerLanguage('less', less);
|
|
39
|
-
SyntaxHighlighter.registerLanguage('xml', xml);
|
|
40
|
-
SyntaxHighlighter.registerLanguage('yaml', yaml);
|
|
41
|
-
SyntaxHighlighter.registerLanguage('diff', diff);
|
|
42
|
-
SyntaxHighlighter.registerLanguage('bash', bash);
|
|
43
|
-
SyntaxHighlighter.registerLanguage('markdown', markdown);
|
|
18
|
+
Object.keys(languagesInfo).forEach(key => {
|
|
19
|
+
SyntaxHighlighter.registerLanguage(key, languagesInfo[key]);
|
|
20
|
+
});
|
|
44
21
|
registered = true;
|
|
45
22
|
}
|
|
46
23
|
|
|
@@ -7,8 +7,9 @@ import { useDisableNav, useLocaleSiteData } from '../../logic';
|
|
|
7
7
|
import { SideMenu } from '../../components/LocalSideBar';
|
|
8
8
|
import { Overview } from '../../components/Overview';
|
|
9
9
|
import { TabDataContext } from '../../logic/TabDataContext';
|
|
10
|
+
import { QueryStatus } from '../Layout';
|
|
10
11
|
import styles from './index.module.scss';
|
|
11
|
-
import { Content, usePageData } from '@/runtime';
|
|
12
|
+
import { Content, useLocation, usePageData } from '@/runtime';
|
|
12
13
|
|
|
13
14
|
export interface DocLayoutProps {
|
|
14
15
|
beforeDocFooter?: React.ReactNode;
|
|
@@ -28,18 +29,19 @@ export function DocLayout(props: DocLayoutProps) {
|
|
|
28
29
|
const { themeConfig } = siteData;
|
|
29
30
|
const localesData = useLocaleSiteData();
|
|
30
31
|
const sidebar = localesData.sidebar || {};
|
|
31
|
-
|
|
32
|
-
const disableNavbar = useDisableNav();
|
|
32
|
+
const [disableNavbar] = useDisableNav();
|
|
33
33
|
// siderbar Priority
|
|
34
34
|
// 1. frontmatter.sidebar
|
|
35
35
|
// 2. themeConfig.locales.sidebar
|
|
36
36
|
// 3. themeConfig.sidebar
|
|
37
37
|
const hasSidebar =
|
|
38
38
|
frontmatter?.sidebar !== false && Object.keys(sidebar).length > 0;
|
|
39
|
+
|
|
39
40
|
const outlineTitle =
|
|
40
41
|
localesData?.outlineTitle || themeConfig?.outlineTitle || 'ON THIS PAGE';
|
|
41
42
|
const isOverviewPage = frontmatter?.overview ?? false;
|
|
42
|
-
const hasFooter = frontmatter?.footer ?? true;
|
|
43
|
+
const [hasFooter, setHasFooter] = useState(frontmatter?.footer ?? true);
|
|
44
|
+
const location = useLocation();
|
|
43
45
|
|
|
44
46
|
const getHasAside = () => {
|
|
45
47
|
// if in iframe, default value is false
|
|
@@ -56,6 +58,14 @@ export function DocLayout(props: DocLayoutProps) {
|
|
|
56
58
|
setHasAside(getHasAside());
|
|
57
59
|
}, [page, siteData]);
|
|
58
60
|
|
|
61
|
+
useEffect(() => {
|
|
62
|
+
const query = new URLSearchParams(location.search);
|
|
63
|
+
const footer = query.get('footer');
|
|
64
|
+
if (footer === QueryStatus.Hide) {
|
|
65
|
+
setHasFooter(false);
|
|
66
|
+
}
|
|
67
|
+
}, []);
|
|
68
|
+
|
|
59
69
|
return (
|
|
60
70
|
<div
|
|
61
71
|
className={`${styles.docLayout} pt-0`}
|
|
@@ -66,7 +76,7 @@ export function DocLayout(props: DocLayoutProps) {
|
|
|
66
76
|
{beforeDoc}
|
|
67
77
|
{hasSidebar ? <SideMenu /> : null}
|
|
68
78
|
<div
|
|
69
|
-
className={`${styles.content} rspress-doc-container flex flex-shrink-0`}
|
|
79
|
+
className={`${styles.content} rspress-doc-container flex flex-shrink-0 m-auto`}
|
|
70
80
|
>
|
|
71
81
|
<div className="w-full">
|
|
72
82
|
{isOverviewPage ? (
|
|
@@ -9,6 +9,11 @@ import type { NavProps } from '../../components/Nav';
|
|
|
9
9
|
import { usePageData, Content, removeBase, withBase } from '@/runtime';
|
|
10
10
|
import { useDisableNav, useLocaleSiteData } from '@/theme-default/logic';
|
|
11
11
|
|
|
12
|
+
export enum QueryStatus {
|
|
13
|
+
Show = '1',
|
|
14
|
+
Hide = '0',
|
|
15
|
+
}
|
|
16
|
+
|
|
12
17
|
export type LayoutProps = {
|
|
13
18
|
top?: React.ReactNode;
|
|
14
19
|
bottom?: React.ReactNode;
|
|
@@ -56,7 +61,7 @@ export const Layout: React.FC<LayoutProps> = props => {
|
|
|
56
61
|
} = page;
|
|
57
62
|
const localesData = useLocaleSiteData();
|
|
58
63
|
const defaultLang = siteData.lang || '';
|
|
59
|
-
const hideNavbar = useDisableNav();
|
|
64
|
+
const [hideNavbar, setHideNavbar] = useDisableNav();
|
|
60
65
|
// Always show sidebar by default
|
|
61
66
|
// Priority: front matter title > h1 title
|
|
62
67
|
let title = (frontmatter?.title as string) ?? articleTitle;
|
|
@@ -129,6 +134,25 @@ export const Layout: React.FC<LayoutProps> = props => {
|
|
|
129
134
|
}
|
|
130
135
|
}
|
|
131
136
|
}, []);
|
|
137
|
+
|
|
138
|
+
// Control the display of the navbar, sidebar and aside
|
|
139
|
+
useEffect(() => {
|
|
140
|
+
const query = new URLSearchParams(location.search);
|
|
141
|
+
const navbar = query.get('navbar');
|
|
142
|
+
const sidebar = query.get('sidebar');
|
|
143
|
+
const aside = query.get('outline');
|
|
144
|
+
if (navbar === QueryStatus.Hide) {
|
|
145
|
+
setHideNavbar(true);
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
if (sidebar === QueryStatus.Hide) {
|
|
149
|
+
document.documentElement.style.setProperty('--rp-sidebar-width', '0');
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
if (aside === QueryStatus.Hide) {
|
|
153
|
+
document.documentElement.style.setProperty('--rp-aside-width', '0');
|
|
154
|
+
}
|
|
155
|
+
}, []);
|
|
132
156
|
return (
|
|
133
157
|
<div>
|
|
134
158
|
<Helmet>
|
|
@@ -11,8 +11,11 @@ export function useDisableNav() {
|
|
|
11
11
|
siteData: { themeConfig },
|
|
12
12
|
page: { frontmatter = {} },
|
|
13
13
|
} = usePageData();
|
|
14
|
+
const initialState =
|
|
15
|
+
!(frontmatter?.navbar ?? true) || themeConfig?.hideNavbar === 'always';
|
|
16
|
+
const [disableNav, setDisableNav] = useState<boolean>(initialState);
|
|
14
17
|
// Priority: frontmatter.navbar > themeConfig.hideNavbar
|
|
15
|
-
return
|
|
18
|
+
return [disableNav, setDisableNav] as const;
|
|
16
19
|
}
|
|
17
20
|
|
|
18
21
|
export function useHiddenNav() {
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
.navScreenMenuGroup {
|
|
2
|
-
height: 39px;
|
|
3
|
-
overflow: hidden;
|
|
4
|
-
transition: border-color 0.5s;
|
|
5
|
-
}
|
|
6
|
-
.navScreenMenuGroup.open {
|
|
7
|
-
padding-bottom: 10px;
|
|
8
|
-
height: auto;
|
|
9
|
-
}
|
|
10
|
-
.button {
|
|
11
|
-
display: flex;
|
|
12
|
-
justify-content: center;
|
|
13
|
-
align-items: center;
|
|
14
|
-
padding: 8px 0 7px 0;
|
|
15
|
-
width: 100%;
|
|
16
|
-
line-height: 24px;
|
|
17
|
-
font-size: 14px;
|
|
18
|
-
font-weight: 500;
|
|
19
|
-
color: var(--rp-c-text-1);
|
|
20
|
-
transition: color 0.25s;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
.buttonSpan {
|
|
24
|
-
display: flex;
|
|
25
|
-
align-items: center;
|
|
26
|
-
height: 24px;
|
|
27
|
-
padding-right: 4px;
|
|
28
|
-
}
|
|
29
|
-
.navScreenMenuGroup .items {
|
|
30
|
-
visibility: hidden;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
.navScreenMenuGroup.open .items {
|
|
34
|
-
visibility: visible;
|
|
35
|
-
}
|
|
36
|
-
.down {
|
|
37
|
-
transition: all 0.5s;
|
|
38
|
-
}
|
|
39
|
-
.open.down {
|
|
40
|
-
transform: rotate(180deg);
|
|
41
|
-
}
|