@rspress/core 1.2.0 → 1.3.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/dist/index.d.ts +2 -0
- package/dist/index.js +53 -40
- package/dist/index.js.map +1 -1
- package/dist/loader.d.ts +1 -1
- package/dist/loader.js.map +1 -1
- package/dist/runtime/App.js +8 -4
- package/dist/runtime/clientEntry.js +7 -4
- package/dist/runtime/ssrEntry.js +2 -2
- package/package.json +19 -15
- package/runtime.ts +1 -1
- package/src/runtime/App.tsx +8 -4
- package/src/runtime/clientEntry.tsx +7 -4
- package/src/runtime/ssrEntry.tsx +2 -2
- package/theme.ts +2 -2
- package/dist/runtime/Content.d.ts +0 -6
- package/dist/runtime/Content.js +0 -33
- package/dist/runtime/NoSSR.d.ts +0 -4
- package/dist/runtime/NoSSR.js +0 -17
- package/dist/runtime/hooks.d.ts +0 -39
- package/dist/runtime/hooks.js +0 -54
- package/dist/runtime/index.d.ts +0 -6
- package/dist/runtime/index.js +0 -34
- package/dist/runtime/utils.d.ts +0 -8
- package/dist/runtime/utils.js +0 -45
- package/dist/theme/bundle.css +0 -2691
- package/dist/theme/bundle.d.ts +0 -176
- package/dist/theme/bundle.js +0 -4433
- package/dist/theme/bundle.js.map +0 -1
- package/dist/theme/index.js +0 -6
- package/src/runtime/Content.tsx +0 -43
- package/src/runtime/NoSSR.tsx +0 -16
- package/src/runtime/hooks.ts +0 -110
- package/src/runtime/index.ts +0 -17
- package/src/runtime/utils.ts +0 -46
- package/src/theme-default/assets/arrow-down.svg +0 -1
- package/src/theme-default/assets/arrow-right.svg +0 -1
- package/src/theme-default/assets/copy.svg +0 -1
- package/src/theme-default/assets/down.svg +0 -1
- package/src/theme-default/assets/github.svg +0 -1
- package/src/theme-default/assets/loading.svg +0 -1
- package/src/theme-default/assets/menu.svg +0 -1
- package/src/theme-default/assets/moon.svg +0 -3
- package/src/theme-default/assets/right.svg +0 -1
- package/src/theme-default/assets/small-menu.svg +0 -1
- package/src/theme-default/assets/success.svg +0 -1
- package/src/theme-default/assets/sun.svg +0 -11
- package/src/theme-default/assets/translator.svg +0 -1
- package/src/theme-default/components/Aside/index.css +0 -22
- package/src/theme-default/components/Aside/index.tsx +0 -75
- package/src/theme-default/components/BackDrop/index.module.scss +0 -14
- package/src/theme-default/components/BackDrop/index.tsx +0 -13
- package/src/theme-default/components/Button/index.module.scss +0 -68
- package/src/theme-default/components/Button/index.tsx +0 -40
- package/src/theme-default/components/DocFooter/index.module.scss +0 -60
- package/src/theme-default/components/DocFooter/index.tsx +0 -66
- package/src/theme-default/components/EditLink/index.module.scss +0 -11
- package/src/theme-default/components/EditLink/index.tsx +0 -18
- package/src/theme-default/components/HomeFeatures/index.module.scss +0 -50
- package/src/theme-default/components/HomeFeatures/index.tsx +0 -65
- package/src/theme-default/components/HomeFooter/index.tsx +0 -15
- package/src/theme-default/components/HomeHero/index.module.scss +0 -42
- package/src/theme-default/components/HomeHero/index.tsx +0 -75
- package/src/theme-default/components/Link/index.module.scss +0 -9
- package/src/theme-default/components/Link/index.tsx +0 -90
- package/src/theme-default/components/LocalSideBar/index.scss +0 -40
- package/src/theme-default/components/LocalSideBar/index.tsx +0 -39
- package/src/theme-default/components/Nav/NavBarTitle.tsx +0 -43
- package/src/theme-default/components/Nav/NavMenuGroup.tsx +0 -156
- package/src/theme-default/components/Nav/NavMenuSingleItem.tsx +0 -40
- package/src/theme-default/components/Nav/NavTranslations.tsx +0 -16
- package/src/theme-default/components/Nav/NavVersions.tsx +0 -16
- package/src/theme-default/components/Nav/index.module.scss +0 -115
- package/src/theme-default/components/Nav/index.tsx +0 -150
- package/src/theme-default/components/Nav/menuDataHooks.tsx +0 -75
- package/src/theme-default/components/NavHambmger/index.module.scss +0 -81
- package/src/theme-default/components/NavHambmger/index.tsx +0 -39
- package/src/theme-default/components/NavScreen/NavScreenMenuGroup.tsx +0 -95
- package/src/theme-default/components/NavScreen/index.module.scss +0 -88
- package/src/theme-default/components/NavScreen/index.tsx +0 -123
- package/src/theme-default/components/Overview/index.module.scss +0 -154
- package/src/theme-default/components/Overview/index.tsx +0 -136
- package/src/theme-default/components/PackageManagerTabs/icons/Bun.tsx +0 -101
- package/src/theme-default/components/PackageManagerTabs/icons/Npm.tsx +0 -16
- package/src/theme-default/components/PackageManagerTabs/icons/Pnpm.tsx +0 -22
- package/src/theme-default/components/PackageManagerTabs/icons/Yarn.tsx +0 -18
- package/src/theme-default/components/PackageManagerTabs/index.scss +0 -5
- package/src/theme-default/components/PackageManagerTabs/index.tsx +0 -110
- package/src/theme-default/components/Search/NoSearchResult.tsx +0 -13
- package/src/theme-default/components/Search/SearchPanel.tsx +0 -340
- package/src/theme-default/components/Search/SuggestItem.tsx +0 -135
- package/src/theme-default/components/Search/assets/close.svg +0 -1
- package/src/theme-default/components/Search/assets/file.svg +0 -1
- package/src/theme-default/components/Search/assets/header.svg +0 -1
- package/src/theme-default/components/Search/assets/jump.svg +0 -1
- package/src/theme-default/components/Search/assets/loading.svg +0 -1
- package/src/theme-default/components/Search/assets/search.svg +0 -1
- package/src/theme-default/components/Search/assets/title.svg +0 -1
- package/src/theme-default/components/Search/empty.svg +0 -4
- package/src/theme-default/components/Search/index.module.scss +0 -236
- package/src/theme-default/components/Search/index.tsx +0 -39
- package/src/theme-default/components/Search/logic/Provider.ts +0 -35
- package/src/theme-default/components/Search/logic/providers/LocalProvider.ts +0 -102
- package/src/theme-default/components/Search/logic/providers/RemoteProvider.ts +0 -40
- package/src/theme-default/components/Search/logic/search.ts +0 -341
- package/src/theme-default/components/Search/logic/util.test.ts +0 -21
- package/src/theme-default/components/Search/logic/util.ts +0 -127
- package/src/theme-default/components/Sidebar/SidebarGroup.tsx +0 -180
- package/src/theme-default/components/Sidebar/SidebarItem.tsx +0 -61
- package/src/theme-default/components/Sidebar/index.module.scss +0 -142
- package/src/theme-default/components/Sidebar/index.tsx +0 -156
- package/src/theme-default/components/SocialLinks/HiddenLinks.tsx +0 -30
- package/src/theme-default/components/SocialLinks/LinkContent.tsx +0 -90
- package/src/theme-default/components/SocialLinks/ShownLinks.tsx +0 -32
- package/src/theme-default/components/SocialLinks/index.module.scss +0 -18
- package/src/theme-default/components/SocialLinks/index.tsx +0 -36
- package/src/theme-default/components/SocialLinks/presetIcons.tsx +0 -165
- package/src/theme-default/components/SwitchAppearance/index.module.scss +0 -15
- package/src/theme-default/components/SwitchAppearance/index.tsx +0 -35
- package/src/theme-default/components/Tabs/index.module.scss +0 -46
- package/src/theme-default/components/Tabs/index.tsx +0 -123
- package/src/theme-default/components/Tag/index.tsx +0 -18
- package/src/theme-default/components/Toc/index.css +0 -18
- package/src/theme-default/components/Toc/index.tsx +0 -42
- package/src/theme-default/index.ts +0 -26
- package/src/theme-default/layout/DocLayout/docComponents/code.tsx +0 -112
- package/src/theme-default/layout/DocLayout/docComponents/hr.tsx +0 -10
- package/src/theme-default/layout/DocLayout/docComponents/index.module.scss +0 -69
- package/src/theme-default/layout/DocLayout/docComponents/index.tsx +0 -33
- package/src/theme-default/layout/DocLayout/docComponents/link.tsx +0 -22
- package/src/theme-default/layout/DocLayout/docComponents/list.tsx +0 -13
- package/src/theme-default/layout/DocLayout/docComponents/paragraph.tsx +0 -19
- package/src/theme-default/layout/DocLayout/docComponents/pre.tsx +0 -37
- package/src/theme-default/layout/DocLayout/docComponents/prisim-theme.ts +0 -73
- package/src/theme-default/layout/DocLayout/docComponents/table.tsx +0 -37
- package/src/theme-default/layout/DocLayout/docComponents/title.tsx +0 -40
- package/src/theme-default/layout/DocLayout/index.module.scss +0 -138
- package/src/theme-default/layout/DocLayout/index.tsx +0 -125
- package/src/theme-default/layout/HomeLayout/index.css +0 -18
- package/src/theme-default/layout/HomeLayout/index.tsx +0 -39
- package/src/theme-default/layout/Layout/index.tsx +0 -176
- package/src/theme-default/layout/NotFountLayout/index.tsx +0 -40
- package/src/theme-default/logic/TabDataContext.ts +0 -14
- package/src/theme-default/logic/index.ts +0 -8
- package/src/theme-default/logic/sideEffects.ts +0 -174
- package/src/theme-default/logic/useAppearance.ts +0 -57
- package/src/theme-default/logic/useEditLink.ts +0 -33
- package/src/theme-default/logic/useHiddenNav.ts +0 -58
- package/src/theme-default/logic/useLocaleSiteData.ts +0 -26
- package/src/theme-default/logic/useNav.ts +0 -36
- package/src/theme-default/logic/usePathUtils.ts +0 -73
- package/src/theme-default/logic/usePrevNextPage.ts +0 -40
- package/src/theme-default/logic/useSidebarData.ts +0 -73
- package/src/theme-default/logic/utils.ts +0 -38
- package/src/theme-default/styles/base.css +0 -102
- package/src/theme-default/styles/code.css +0 -177
- package/src/theme-default/styles/index.ts +0 -7
- package/src/theme-default/styles/scrollbar.css +0 -28
- package/src/theme-default/styles/vars.css +0 -81
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { useEditLink } from '../../logic';
|
|
2
|
-
import styles from './index.module.scss';
|
|
3
|
-
|
|
4
|
-
export default function EditLink() {
|
|
5
|
-
const editLinkObj = useEditLink();
|
|
6
|
-
|
|
7
|
-
if (!editLinkObj) {
|
|
8
|
-
return null;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
const { text, link } = editLinkObj;
|
|
12
|
-
|
|
13
|
-
return (
|
|
14
|
-
<a href={link} target="_blank" className={styles.editLink}>
|
|
15
|
-
{text}
|
|
16
|
-
</a>
|
|
17
|
-
);
|
|
18
|
-
}
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
@media (max-width: 640px) {
|
|
2
|
-
.grid-2,
|
|
3
|
-
.grid-4,
|
|
4
|
-
.grid-6 {
|
|
5
|
-
width: calc(100%);
|
|
6
|
-
}
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
@media (min-width: 640px) {
|
|
10
|
-
.grid-2,
|
|
11
|
-
.grid-4,
|
|
12
|
-
.grid-6 {
|
|
13
|
-
width: calc(100% / 2);
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
@media (min-width: 768px) {
|
|
18
|
-
.grid-2,
|
|
19
|
-
.grid-4 {
|
|
20
|
-
width: calc(100% / 2);
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
.grid-3,
|
|
24
|
-
.grid-6 {
|
|
25
|
-
width: calc(100% / 3);
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
@media (min-width: 960px) {
|
|
30
|
-
.grid-3 {
|
|
31
|
-
width: calc(100% / 4);
|
|
32
|
-
}
|
|
33
|
-
.grid-4 {
|
|
34
|
-
width: calc(100% / 3);
|
|
35
|
-
}
|
|
36
|
-
.grid-6 {
|
|
37
|
-
width: calc(100% / 2);
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
.featureCard {
|
|
42
|
-
background: var(--rp-home-feature-bg);
|
|
43
|
-
border: 1px solid transparent;
|
|
44
|
-
transition: all 0.3s;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
.featureCard:hover {
|
|
48
|
-
background: var(--rp-home-feature-hover-bg);
|
|
49
|
-
border: 1px solid var(--rp-c-brand);
|
|
50
|
-
}
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
import { FrontMatterMeta } from '@rspress/shared';
|
|
2
|
-
import styles from './index.module.scss';
|
|
3
|
-
|
|
4
|
-
const PRESET_COUNT = [2, 3, 4];
|
|
5
|
-
|
|
6
|
-
const getGridClass = (count?: number): string => {
|
|
7
|
-
if (!count) {
|
|
8
|
-
return '';
|
|
9
|
-
} else if (PRESET_COUNT.includes(count)) {
|
|
10
|
-
return `grid-${12 / count}`;
|
|
11
|
-
} else if (count % 3 === 0) {
|
|
12
|
-
return 'grid-4';
|
|
13
|
-
} else if (count % 2 === 0) {
|
|
14
|
-
return 'grid-6';
|
|
15
|
-
}
|
|
16
|
-
return '';
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
export function HomeFeature({ frontmatter }: { frontmatter: FrontMatterMeta }) {
|
|
20
|
-
const features = frontmatter?.features;
|
|
21
|
-
const gridClass = getGridClass(features?.length);
|
|
22
|
-
|
|
23
|
-
return (
|
|
24
|
-
<div className="overflow-hidden m-auto flex flex-wrap justify-between max-w-6xl">
|
|
25
|
-
{features?.map(feature => {
|
|
26
|
-
const { icon, title, details, link } = feature;
|
|
27
|
-
return (
|
|
28
|
-
<div
|
|
29
|
-
key={title}
|
|
30
|
-
className={`${
|
|
31
|
-
gridClass ? styles[gridClass] : 'w-full'
|
|
32
|
-
} rounded hover:var(--rp-c-brand)`}
|
|
33
|
-
>
|
|
34
|
-
<div className="h-full p-2">
|
|
35
|
-
<article
|
|
36
|
-
key={title}
|
|
37
|
-
className={`${styles.featureCard} h-full p-8 rounded-4xl border-transparent`}
|
|
38
|
-
style={{
|
|
39
|
-
cursor: link ? 'pointer' : 'auto',
|
|
40
|
-
}}
|
|
41
|
-
onClick={() => {
|
|
42
|
-
if (link) {
|
|
43
|
-
window.location.href = link;
|
|
44
|
-
}
|
|
45
|
-
}}
|
|
46
|
-
>
|
|
47
|
-
<div className="flex-center">
|
|
48
|
-
<div className="rspress-home-feature-icon w-12 h-12 text-3xl text-center">
|
|
49
|
-
{icon}
|
|
50
|
-
</div>
|
|
51
|
-
</div>
|
|
52
|
-
<h2 className="rspress-home-feature-title font-bold text-center">
|
|
53
|
-
{title}
|
|
54
|
-
</h2>
|
|
55
|
-
<p className="rspress-home-feature-detail leading-6 pt-2 text-sm text-text-2 font-medium">
|
|
56
|
-
{details}
|
|
57
|
-
</p>
|
|
58
|
-
</article>
|
|
59
|
-
</div>
|
|
60
|
-
</div>
|
|
61
|
-
);
|
|
62
|
-
})}
|
|
63
|
-
</div>
|
|
64
|
-
);
|
|
65
|
-
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { usePageData } from '@/runtime';
|
|
2
|
-
|
|
3
|
-
export function HomeFooter() {
|
|
4
|
-
const { siteData } = usePageData();
|
|
5
|
-
const { message } = siteData.themeConfig.footer || {};
|
|
6
|
-
return (
|
|
7
|
-
<footer className="absolute bottom-0 mt-12 py-8 px-6 sm:p-8 w-full border-t border-solid border-divider-light">
|
|
8
|
-
<div className="m-auto w-full text-center">
|
|
9
|
-
{message && (
|
|
10
|
-
<div className="font-meduim text-sm text-text-2">{message}</div>
|
|
11
|
-
)}
|
|
12
|
-
</div>
|
|
13
|
-
</footer>
|
|
14
|
-
);
|
|
15
|
-
}
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
.clip {
|
|
2
|
-
background: var(--rp-home-hero-name-background);
|
|
3
|
-
-webkit-background-clip: text;
|
|
4
|
-
background-clip: text;
|
|
5
|
-
-webkit-text-fill-color: var(--rp-home-hero-name-color);
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
.mask {
|
|
9
|
-
position: absolute;
|
|
10
|
-
background-image: conic-gradient(
|
|
11
|
-
from 180deg at 50% 50%,
|
|
12
|
-
var(--rp-c-brand) 0deg,
|
|
13
|
-
180deg,
|
|
14
|
-
#42d392 1turn
|
|
15
|
-
);
|
|
16
|
-
max-width: 500px;
|
|
17
|
-
width: 100%;
|
|
18
|
-
height: 500px;
|
|
19
|
-
border-radius: 100%;
|
|
20
|
-
mixblendmode: normal;
|
|
21
|
-
filter: blur(80px);
|
|
22
|
-
opacity: 0.05;
|
|
23
|
-
top: -100px;
|
|
24
|
-
transform: translateX(-50%);
|
|
25
|
-
z-index: 0;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
:global(.dark) .mask {
|
|
29
|
-
opacity: 0.15;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
@media (min-width: 640px) {
|
|
33
|
-
:global(.rspress-home-hero-image) {
|
|
34
|
-
width: 375px;
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
@media (max-width: 768px) {
|
|
39
|
-
.mask {
|
|
40
|
-
display: none;
|
|
41
|
-
}
|
|
42
|
-
}
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
import { FrontMatterMeta } from '@rspress/shared';
|
|
2
|
-
import { Button } from '../Button';
|
|
3
|
-
import styles from './index.module.scss';
|
|
4
|
-
import {
|
|
5
|
-
normalizeHrefInRuntime as normalizeHref,
|
|
6
|
-
normalizeImagePath,
|
|
7
|
-
} from '@/runtime';
|
|
8
|
-
|
|
9
|
-
const DEFAULT_HERO = {
|
|
10
|
-
name: 'modern',
|
|
11
|
-
text: 'modern ssg',
|
|
12
|
-
tagline: 'modern ssg',
|
|
13
|
-
actions: [],
|
|
14
|
-
image: undefined,
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
export function HomeHero({ frontmatter }: { frontmatter: FrontMatterMeta }) {
|
|
18
|
-
const hero = frontmatter?.hero || DEFAULT_HERO;
|
|
19
|
-
const hasImage = hero.image !== undefined;
|
|
20
|
-
const textMaxWidth = hasImage ? 'sm:max-w-xl' : 'sm:max-w-4xl';
|
|
21
|
-
return (
|
|
22
|
-
<div className="m-auto pt-0 px-6 pb-12 sm:pt-10 sm:px-16 md:pt-16 md:px-16 md:pb-16">
|
|
23
|
-
<div
|
|
24
|
-
className={styles.mask}
|
|
25
|
-
style={{
|
|
26
|
-
left: hasImage ? '75%' : '50%',
|
|
27
|
-
}}
|
|
28
|
-
></div>
|
|
29
|
-
<div className="m-auto flex flex-col md:flex-row max-w-6xl min-h-[50vh]">
|
|
30
|
-
<div className="flex flex-col justify-center text-center max-w-xl sm:max-w-4xl m-auto order-2 md:order-1">
|
|
31
|
-
<h1 className="font-bold text-3xl sm:text-6xl md:text-7xl m-auto sm:m-4 md:m-0 md:pb-3 lg:pb-2 leading-tight z-10">
|
|
32
|
-
<span className={styles.clip} style={{ lineHeight: '1.3' }}>
|
|
33
|
-
{hero.name}
|
|
34
|
-
</span>
|
|
35
|
-
</h1>
|
|
36
|
-
{hero.text?.length && (
|
|
37
|
-
<p
|
|
38
|
-
className={`mx-auto md:m-0 text-3xl sm:text-5xl md:text-6xl pb-2 font-bold z-10 ${textMaxWidth}`}
|
|
39
|
-
style={{ lineHeight: '1.2' }}
|
|
40
|
-
>
|
|
41
|
-
{hero.text}
|
|
42
|
-
</p>
|
|
43
|
-
)}
|
|
44
|
-
|
|
45
|
-
<p
|
|
46
|
-
className={`whitespace-pre-wrap pt-4 m-auto md:m-0 text-sm sm:tex-xl md:text-2xl text-text-2 font-medium z-10 ${textMaxWidth}`}
|
|
47
|
-
>
|
|
48
|
-
{hero.tagline}
|
|
49
|
-
</p>
|
|
50
|
-
<div className="flex flex-wrap justify-center gap-3 m--1.5 pt-8 z-10">
|
|
51
|
-
{hero.actions.map(action => (
|
|
52
|
-
<div className="flex flex-shrink-0 p-1" key={action.link}>
|
|
53
|
-
<Button
|
|
54
|
-
type="a"
|
|
55
|
-
text={action.text}
|
|
56
|
-
href={normalizeHref(action.link)}
|
|
57
|
-
theme={action.theme}
|
|
58
|
-
/>
|
|
59
|
-
</div>
|
|
60
|
-
))}
|
|
61
|
-
</div>
|
|
62
|
-
</div>
|
|
63
|
-
|
|
64
|
-
{hasImage ? (
|
|
65
|
-
<div className="rspress-home-hero-image md:flex-center m-auto order-1 md:order-2 sm:flex md:none lg:flex">
|
|
66
|
-
<img
|
|
67
|
-
src={normalizeImagePath(hero.image?.src)}
|
|
68
|
-
alt={hero.image?.alt}
|
|
69
|
-
/>
|
|
70
|
-
</div>
|
|
71
|
-
) : null}
|
|
72
|
-
</div>
|
|
73
|
-
</div>
|
|
74
|
-
);
|
|
75
|
-
}
|
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { matchRoutes, useLocation, useNavigate } from 'react-router-dom';
|
|
3
|
-
import nprogress from 'nprogress';
|
|
4
|
-
import { routes } from 'virtual-routes';
|
|
5
|
-
import styles from './index.module.scss';
|
|
6
|
-
import {
|
|
7
|
-
normalizeHrefInRuntime as normalizeHref,
|
|
8
|
-
normalizeRoutePath,
|
|
9
|
-
withBase,
|
|
10
|
-
} from '@/runtime';
|
|
11
|
-
import { scrollToTarget } from '@/theme-default/logic';
|
|
12
|
-
|
|
13
|
-
export interface LinkProps {
|
|
14
|
-
href?: string;
|
|
15
|
-
children?: React.ReactNode;
|
|
16
|
-
className?: string;
|
|
17
|
-
onNavigate?: () => void;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
nprogress.configure({ showSpinner: false });
|
|
21
|
-
|
|
22
|
-
const EXTERNAL_URL_RE = /^(https?:)?\/\//;
|
|
23
|
-
|
|
24
|
-
export function Link(props: LinkProps) {
|
|
25
|
-
const { href = '/', children, className = '', onNavigate } = props;
|
|
26
|
-
const isExternal = EXTERNAL_URL_RE.test(href);
|
|
27
|
-
const target = isExternal ? '_blank' : '';
|
|
28
|
-
const rel = isExternal ? 'noopener noreferrer' : undefined;
|
|
29
|
-
const withBaseUrl = isExternal ? href : withBase(normalizeHref(href));
|
|
30
|
-
const navigate = useNavigate();
|
|
31
|
-
const { pathname } = useLocation();
|
|
32
|
-
const inCurrentPage = withBaseUrl.startsWith(pathname);
|
|
33
|
-
const handleNavigate = async (
|
|
34
|
-
e: React.MouseEvent<HTMLAnchorElement, MouseEvent>,
|
|
35
|
-
) => {
|
|
36
|
-
e.preventDefault();
|
|
37
|
-
// handle hash link in current page
|
|
38
|
-
const hash = withBaseUrl.split('#')[1];
|
|
39
|
-
if (!isExternal && inCurrentPage && hash) {
|
|
40
|
-
const el = document.getElementById(hash);
|
|
41
|
-
if (el) {
|
|
42
|
-
scrollToTarget(el, true);
|
|
43
|
-
}
|
|
44
|
-
return;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
// handle normal link
|
|
48
|
-
if (!process.env.__SSR__) {
|
|
49
|
-
const matchedRoutes = matchRoutes(
|
|
50
|
-
routes,
|
|
51
|
-
normalizeRoutePath(withBaseUrl),
|
|
52
|
-
);
|
|
53
|
-
if (matchedRoutes?.length) {
|
|
54
|
-
const timer = setTimeout(() => {
|
|
55
|
-
nprogress.start();
|
|
56
|
-
}, 200);
|
|
57
|
-
await matchedRoutes[0].route.preload();
|
|
58
|
-
clearTimeout(timer);
|
|
59
|
-
nprogress.done();
|
|
60
|
-
}
|
|
61
|
-
onNavigate?.();
|
|
62
|
-
navigate(withBaseUrl, { replace: false });
|
|
63
|
-
}
|
|
64
|
-
};
|
|
65
|
-
|
|
66
|
-
if (!isExternal) {
|
|
67
|
-
return (
|
|
68
|
-
<a
|
|
69
|
-
className={`${styles.link} ${className} cursor-pointer`}
|
|
70
|
-
rel={rel}
|
|
71
|
-
target={target}
|
|
72
|
-
onClick={handleNavigate}
|
|
73
|
-
href={withBaseUrl}
|
|
74
|
-
>
|
|
75
|
-
{children}
|
|
76
|
-
</a>
|
|
77
|
-
);
|
|
78
|
-
} else {
|
|
79
|
-
return (
|
|
80
|
-
<a
|
|
81
|
-
href={withBaseUrl}
|
|
82
|
-
target={target}
|
|
83
|
-
rel={rel}
|
|
84
|
-
className={`${styles.link} ${className}`}
|
|
85
|
-
>
|
|
86
|
-
{children}
|
|
87
|
-
</a>
|
|
88
|
-
);
|
|
89
|
-
}
|
|
90
|
-
}
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
// Only appear on mobile
|
|
2
|
-
.rspress-sidebar-menu {
|
|
3
|
-
position: sticky;
|
|
4
|
-
top: 0;
|
|
5
|
-
left: 0;
|
|
6
|
-
z-index: 2;
|
|
7
|
-
display: flex;
|
|
8
|
-
justify-content: space-between;
|
|
9
|
-
align-items: center;
|
|
10
|
-
border-bottom: 1px solid var(--rp-c-divider-light);
|
|
11
|
-
width: 100%;
|
|
12
|
-
color: var(--rp-c-text-1);
|
|
13
|
-
background-color: var(--rp-c-bg);
|
|
14
|
-
padding-left: 10px;
|
|
15
|
-
> button {
|
|
16
|
-
padding: 12px;
|
|
17
|
-
transition: color 0.5s;
|
|
18
|
-
&:hover {
|
|
19
|
-
color: var(--rp-c-text-3);
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
@media (min-width: 960px) {
|
|
24
|
-
.rspress-sidebar-menu {
|
|
25
|
-
display: none;
|
|
26
|
-
}
|
|
27
|
-
.rspress-sidebar-back-drop {
|
|
28
|
-
display: none;
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
.rspress-sidebar-back-drop {
|
|
33
|
-
position: fixed;
|
|
34
|
-
top: 0;
|
|
35
|
-
right: 0;
|
|
36
|
-
bottom: 0;
|
|
37
|
-
left: 0;
|
|
38
|
-
z-index: var(--rp-z-index-backdrop);
|
|
39
|
-
background: rgba(0, 0, 0, 0.6);
|
|
40
|
-
}
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { Fragment, useEffect, useState } from 'react';
|
|
2
|
-
import { SideBar } from '../Sidebar';
|
|
3
|
-
import MenuIcon from '../../assets/menu.svg';
|
|
4
|
-
import './index.scss';
|
|
5
|
-
import { useLocation } from '@/runtime';
|
|
6
|
-
|
|
7
|
-
export function SideMenu() {
|
|
8
|
-
const [isSidebarOpen, setIsOpen] = useState<boolean>(false);
|
|
9
|
-
const { pathname } = useLocation();
|
|
10
|
-
|
|
11
|
-
function openSidebar() {
|
|
12
|
-
setIsOpen(true);
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
function closeSidebar() {
|
|
16
|
-
setIsOpen(false);
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
useEffect(() => {
|
|
20
|
-
setIsOpen(false);
|
|
21
|
-
}, [pathname]);
|
|
22
|
-
|
|
23
|
-
return (
|
|
24
|
-
<Fragment>
|
|
25
|
-
<div className="rspress-sidebar-menu">
|
|
26
|
-
<button onClick={openSidebar} className="flex-center">
|
|
27
|
-
<div className="text-md mr-2">
|
|
28
|
-
<MenuIcon />
|
|
29
|
-
</div>
|
|
30
|
-
<span className="text-sm">Menu</span>
|
|
31
|
-
</button>
|
|
32
|
-
</div>
|
|
33
|
-
<SideBar isSidebarOpen={isSidebarOpen} />
|
|
34
|
-
{isSidebarOpen ? (
|
|
35
|
-
<div onClick={closeSidebar} className="rspress-sidebar-back-drop" />
|
|
36
|
-
) : null}
|
|
37
|
-
</Fragment>
|
|
38
|
-
);
|
|
39
|
-
}
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import { useContext, useEffect, useState } from 'react';
|
|
2
|
-
import styles from './index.module.scss';
|
|
3
|
-
import {
|
|
4
|
-
ThemeContext,
|
|
5
|
-
normalizeImagePath,
|
|
6
|
-
usePageData,
|
|
7
|
-
withBase,
|
|
8
|
-
} from '@/runtime';
|
|
9
|
-
import { getLogoUrl, useLocaleSiteData } from '@/theme-default/logic';
|
|
10
|
-
|
|
11
|
-
export const NavBarTitle = () => {
|
|
12
|
-
const { siteData } = usePageData();
|
|
13
|
-
const localeData = useLocaleSiteData();
|
|
14
|
-
const { logo: rawLogo } = siteData;
|
|
15
|
-
const title = localeData.title ?? siteData.title;
|
|
16
|
-
const { theme } = useContext(ThemeContext);
|
|
17
|
-
const [logo, setLogo] = useState(getLogoUrl(rawLogo, theme));
|
|
18
|
-
|
|
19
|
-
useEffect(() => {
|
|
20
|
-
setLogo(getLogoUrl(rawLogo, theme));
|
|
21
|
-
}, [theme]);
|
|
22
|
-
|
|
23
|
-
return (
|
|
24
|
-
<div className={`${styles.navBarTitle}`}>
|
|
25
|
-
<a
|
|
26
|
-
href={withBase(localeData.langRoutePrefix || '/')}
|
|
27
|
-
className="flex items-center w-full h-full text-base font-semibold transition-opacity duration-300 hover:opacity-60"
|
|
28
|
-
>
|
|
29
|
-
{logo ? (
|
|
30
|
-
<img
|
|
31
|
-
src={normalizeImagePath(logo)}
|
|
32
|
-
alt="logo"
|
|
33
|
-
id="logo"
|
|
34
|
-
className="mr-4 rspress-logo"
|
|
35
|
-
style={{ height: '1.6rem' }}
|
|
36
|
-
/>
|
|
37
|
-
) : (
|
|
38
|
-
<span>{title}</span>
|
|
39
|
-
)}
|
|
40
|
-
</a>
|
|
41
|
-
</div>
|
|
42
|
-
);
|
|
43
|
-
};
|
|
@@ -1,156 +0,0 @@
|
|
|
1
|
-
import { useState } from 'react';
|
|
2
|
-
import {
|
|
3
|
-
NavItem,
|
|
4
|
-
NavItemWithChildren,
|
|
5
|
-
NavItemWithLink,
|
|
6
|
-
NavItemWithLinkAndChildren,
|
|
7
|
-
withoutBase,
|
|
8
|
-
} from '@rspress/shared';
|
|
9
|
-
import { Link } from '../Link';
|
|
10
|
-
import Down from '../../assets/down.svg';
|
|
11
|
-
import { Tag } from '../Tag';
|
|
12
|
-
import { NavMenuSingleItem } from './NavMenuSingleItem';
|
|
13
|
-
|
|
14
|
-
export interface NavMenuGroupItem {
|
|
15
|
-
text?: string | React.ReactElement;
|
|
16
|
-
link?: string;
|
|
17
|
-
items: NavItem[];
|
|
18
|
-
tag?: string;
|
|
19
|
-
// Design for i18n highlight.
|
|
20
|
-
activeValue?: string;
|
|
21
|
-
// Currrnt pathname.
|
|
22
|
-
pathname?: string;
|
|
23
|
-
// Base path.
|
|
24
|
-
base?: string;
|
|
25
|
-
// Locales
|
|
26
|
-
langs?: string[];
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
function ActiveGroupItem({ item }: { item: NavItemWithLink }) {
|
|
30
|
-
return (
|
|
31
|
-
<div
|
|
32
|
-
key={item.link}
|
|
33
|
-
className="rounded-2xl my-1 flex"
|
|
34
|
-
style={{
|
|
35
|
-
padding: '0.4rem 1.5rem 0.4rem 0.75rem',
|
|
36
|
-
}}
|
|
37
|
-
>
|
|
38
|
-
{item.tag && <Tag tag={item.tag} />}
|
|
39
|
-
<span className="text-brand">{item.text}</span>
|
|
40
|
-
</div>
|
|
41
|
-
);
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
function NormalGroupItem({ item }: { item: NavItemWithLink }) {
|
|
45
|
-
return (
|
|
46
|
-
<div key={item.link} className="font-medium my-1">
|
|
47
|
-
<Link href={item.link}>
|
|
48
|
-
<div
|
|
49
|
-
className="rounded-2xl hover:bg-mute"
|
|
50
|
-
style={{
|
|
51
|
-
padding: '0.4rem 1.5rem 0.4rem 0.75rem',
|
|
52
|
-
}}
|
|
53
|
-
>
|
|
54
|
-
<div className="flex">
|
|
55
|
-
{item.tag && <Tag tag={item.tag} />}
|
|
56
|
-
<span>{item.text}</span>
|
|
57
|
-
</div>
|
|
58
|
-
</div>
|
|
59
|
-
</Link>
|
|
60
|
-
</div>
|
|
61
|
-
);
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
export function NavMenuGroup(item: NavMenuGroupItem) {
|
|
65
|
-
const {
|
|
66
|
-
activeValue,
|
|
67
|
-
items: groupItems,
|
|
68
|
-
base = '',
|
|
69
|
-
link = '',
|
|
70
|
-
pathname = '',
|
|
71
|
-
} = item;
|
|
72
|
-
const [isOpen, setIsOpen] = useState(false);
|
|
73
|
-
const renderLinkItem = (item: NavItemWithLink) => {
|
|
74
|
-
const isLinkActive = new RegExp(item.activeMatch || item.link).test(
|
|
75
|
-
withoutBase(pathname, base),
|
|
76
|
-
);
|
|
77
|
-
if (activeValue === item.text || (!activeValue && isLinkActive)) {
|
|
78
|
-
return <ActiveGroupItem key={item.link} item={item} />;
|
|
79
|
-
}
|
|
80
|
-
return <NormalGroupItem key={item.link} item={item} />;
|
|
81
|
-
};
|
|
82
|
-
const renderGroup = (
|
|
83
|
-
item: NavItemWithChildren | NavItemWithLinkAndChildren,
|
|
84
|
-
) => {
|
|
85
|
-
return (
|
|
86
|
-
<div>
|
|
87
|
-
{'link' in item ? (
|
|
88
|
-
renderLinkItem(item as NavItemWithLink)
|
|
89
|
-
) : (
|
|
90
|
-
<p className="font-bold text-gray-400 my-1 not:first:border">
|
|
91
|
-
{item.text}
|
|
92
|
-
</p>
|
|
93
|
-
)}
|
|
94
|
-
{(item.items as NavItemWithLink[]).map(renderLinkItem)}
|
|
95
|
-
</div>
|
|
96
|
-
);
|
|
97
|
-
};
|
|
98
|
-
return (
|
|
99
|
-
<div
|
|
100
|
-
className="relative flex-center h-14"
|
|
101
|
-
onMouseLeave={() => setIsOpen(false)}
|
|
102
|
-
>
|
|
103
|
-
<button
|
|
104
|
-
onMouseEnter={() => setIsOpen(true)}
|
|
105
|
-
className="nav-menu-group-button flex-center items-center font-medium text-sm text-text-1 hover:text-text-2 transition-colors duration-200"
|
|
106
|
-
>
|
|
107
|
-
{link ? (
|
|
108
|
-
// @ts-expect-error item.text may be ReactElement
|
|
109
|
-
<NavMenuSingleItem {...item} rightIcon={<Down />} />
|
|
110
|
-
) : (
|
|
111
|
-
<>
|
|
112
|
-
<span
|
|
113
|
-
className="text-sm font-medium flex"
|
|
114
|
-
style={{
|
|
115
|
-
marginRight: '2px',
|
|
116
|
-
}}
|
|
117
|
-
>
|
|
118
|
-
<Tag tag={item.tag} />
|
|
119
|
-
{item.text}
|
|
120
|
-
</span>
|
|
121
|
-
<Down />
|
|
122
|
-
</>
|
|
123
|
-
)}
|
|
124
|
-
</button>
|
|
125
|
-
<div
|
|
126
|
-
className="nav-menu-group-content absolute mx-0.8 transition-opacity duration-300"
|
|
127
|
-
style={{
|
|
128
|
-
opacity: isOpen ? 1 : 0,
|
|
129
|
-
visibility: isOpen ? 'visible' : 'hidden',
|
|
130
|
-
right: 0,
|
|
131
|
-
top: '52px',
|
|
132
|
-
}}
|
|
133
|
-
>
|
|
134
|
-
<div
|
|
135
|
-
className="p-3 pr-2 w-full h-full max-h-100vh whitespace-nowrap"
|
|
136
|
-
style={{
|
|
137
|
-
boxShadow: 'var(--rp-shadow-3)',
|
|
138
|
-
zIndex: 100,
|
|
139
|
-
border: '1px solid var(--rp-c-divider-light)',
|
|
140
|
-
borderRadius: '2rem',
|
|
141
|
-
background: 'var(--rp-c-bg)',
|
|
142
|
-
}}
|
|
143
|
-
>
|
|
144
|
-
{/* The item could be a link or a sub group */}
|
|
145
|
-
{groupItems.map(item => {
|
|
146
|
-
return (
|
|
147
|
-
<div key={item.text}>
|
|
148
|
-
{'items' in item ? renderGroup(item) : renderLinkItem(item)}
|
|
149
|
-
</div>
|
|
150
|
-
);
|
|
151
|
-
})}
|
|
152
|
-
</div>
|
|
153
|
-
</div>
|
|
154
|
-
</div>
|
|
155
|
-
);
|
|
156
|
-
}
|