vigor-moon 1.0.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 +9 -0
- package/bin/vigor.js +2 -0
- package/dist/chunk-2M2XJKGT.js +607 -0
- package/dist/chunk-3EAR5BNQ.js +610 -0
- package/dist/chunk-3ZCIQMBL.js +608 -0
- package/dist/chunk-6SPQ2G5U.js +611 -0
- package/dist/chunk-7V4TYSIZ.mjs +619 -0
- package/dist/chunk-AT54N5D7.js +611 -0
- package/dist/chunk-BBRRUMIN.js +616 -0
- package/dist/chunk-BE2AQAQS.mjs +608 -0
- package/dist/chunk-BS6X4ZCI.js +608 -0
- package/dist/chunk-CG4W75R5.mjs +622 -0
- package/dist/chunk-D2WJMNSR.js +618 -0
- package/dist/chunk-DTA4ZJEQ.mjs +606 -0
- package/dist/chunk-ECPJL6H6.js +618 -0
- package/dist/chunk-EU5K7BUZ.mjs +612 -0
- package/dist/chunk-FAELXJ3Z.mjs +605 -0
- package/dist/chunk-GBGTGHKN.js +621 -0
- package/dist/chunk-HW7CAZGA.js +611 -0
- package/dist/chunk-IDQ7PFDG.mjs +619 -0
- package/dist/chunk-IPVDS3I7.mjs +609 -0
- package/dist/chunk-JHZIOXVJ.js +605 -0
- package/dist/chunk-KRBN43PO.js +606 -0
- package/dist/chunk-KTIICQHT.mjs +622 -0
- package/dist/chunk-KZQIA6WA.js +604 -0
- package/dist/chunk-L4MZ52TR.mjs +609 -0
- package/dist/chunk-LEOZIK2T.mjs +607 -0
- package/dist/chunk-LS3TOABU.js +61 -0
- package/dist/chunk-MHZT64KI.mjs +605 -0
- package/dist/chunk-NTJI6VKJ.mjs +619 -0
- package/dist/chunk-NWZZITYZ.mjs +606 -0
- package/dist/chunk-OS3F7QDD.js +606 -0
- package/dist/chunk-PJPXX4UA.mjs +605 -0
- package/dist/chunk-PW73M55D.mjs +611 -0
- package/dist/chunk-R6L6GYA4.mjs +607 -0
- package/dist/chunk-RNUPZ4CR.mjs +612 -0
- package/dist/chunk-SEIXDGYJ.mjs +615 -0
- package/dist/chunk-SO47EKIV.mjs +69 -0
- package/dist/chunk-SYCZ35ZW.js +604 -0
- package/dist/chunk-THZGRR4I.js +611 -0
- package/dist/chunk-TJ5NMLCW.js +614 -0
- package/dist/chunk-TYBNSCBA.mjs +611 -0
- package/dist/chunk-UGBCHWPA.js +621 -0
- package/dist/chunk-VD42YO6T.mjs +622 -0
- package/dist/chunk-VMNTKZYD.js +604 -0
- package/dist/chunk-W6MHPTGR.js +605 -0
- package/dist/chunk-WBSL45KV.mjs +617 -0
- package/dist/chunk-X5IY67V6.js +621 -0
- package/dist/chunk-XFGBQ3QD.mjs +612 -0
- package/dist/chunk-ZBAZASII.js +618 -0
- package/dist/chunk-ZGLENLKC.js +610 -0
- package/dist/chunk-ZN4CSBNG.mjs +612 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +296 -0
- package/dist/cli.mjs +296 -0
- package/dist/dev.d.ts +5 -0
- package/dist/dev.js +7 -0
- package/dist/dev.mjs +7 -0
- package/dist/index.d.ts +40 -0
- package/dist/index.js +6 -0
- package/dist/index.mjs +6 -0
- package/package.json +97 -0
- package/src/core/cli.ts +0 -0
- package/src/runtime/App.tsx +38 -0
- package/src/runtime/Content.tsx +27 -0
- package/src/runtime/client-entry.tsx +30 -0
- package/src/runtime/hooks.ts +8 -0
- package/src/runtime/index.ts +2 -0
- package/src/runtime/ssr-entry.tsx +24 -0
- package/src/theme-default/Layout/doc/doc.tsx +46 -0
- package/src/theme-default/Layout/doc/index.module.scss +154 -0
- package/src/theme-default/Layout/home/home.tsx +16 -0
- package/src/theme-default/Layout/index.tsx +38 -0
- package/src/theme-default/Layout/notFound/index.module.scss +7 -0
- package/src/theme-default/Layout/notFound/index.tsx +30 -0
- package/src/theme-default/component/Button/index.module.scss +36 -0
- package/src/theme-default/component/Button/index.tsx +42 -0
- package/src/theme-default/component/Link/index.module.scss +10 -0
- package/src/theme-default/component/Link/index.tsx +28 -0
- package/src/theme-default/component/feature/index.module.scss +10 -0
- package/src/theme-default/component/feature/index.tsx +28 -0
- package/src/theme-default/component/footer/index.module.scss +4 -0
- package/src/theme-default/component/footer/index.tsx +13 -0
- package/src/theme-default/component/hero/index.module.scss +5 -0
- package/src/theme-default/component/hero/index.tsx +48 -0
- package/src/theme-default/component/nav/index.module.scss +24 -0
- package/src/theme-default/component/nav/index.tsx +43 -0
- package/src/theme-default/component/nextPage/index.module.scss +43 -0
- package/src/theme-default/component/nextPage/index.tsx +64 -0
- package/src/theme-default/component/sidebar/index.module.scss +22 -0
- package/src/theme-default/component/sidebar/index.tsx +52 -0
- package/src/theme-default/component/switchTheme/index.module.scss +0 -0
- package/src/theme-default/component/switchTheme/index.tsx +9 -0
- package/src/theme-default/component/toc/activeScroll.ts +37 -0
- package/src/theme-default/component/toc/index.module.scss +7 -0
- package/src/theme-default/component/toc/index.tsx +60 -0
- package/src/theme-default/styles/base.css +92 -0
- package/src/theme-default/styles/vars.css +111 -0
- package/src/types/attributify-shims.d.ts +5 -0
- package/src/types/index.ts +129 -0
- package/src/types/types.d.ts +16 -0
package/package.json
ADDED
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "vigor-moon",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "SSG framework",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"module": "dist/index.mjs",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"bin": {
|
|
9
|
+
"vigor": "bin/vigor.js"
|
|
10
|
+
},
|
|
11
|
+
"keywords": [
|
|
12
|
+
"SSG",
|
|
13
|
+
"docs"
|
|
14
|
+
],
|
|
15
|
+
"author": "sungMoon",
|
|
16
|
+
"license": "MIT",
|
|
17
|
+
"files": [
|
|
18
|
+
"dist",
|
|
19
|
+
"bin",
|
|
20
|
+
"README.md",
|
|
21
|
+
"src/runtime",
|
|
22
|
+
"src/theme-default",
|
|
23
|
+
"src/types",
|
|
24
|
+
"src/core"
|
|
25
|
+
],
|
|
26
|
+
"devDependencies": {
|
|
27
|
+
"@iconify-json/carbon": "^1.1.16",
|
|
28
|
+
"@playwright/test": "1.26.1",
|
|
29
|
+
"@types/compression": "^1.7.2",
|
|
30
|
+
"@types/fs-extra": "^11.0.1",
|
|
31
|
+
"@types/hast": "^2.3.4",
|
|
32
|
+
"@types/mdast": "^3.0.10",
|
|
33
|
+
"@types/node": "^18.13.0",
|
|
34
|
+
"@types/polka": "^0.5.4",
|
|
35
|
+
"@types/react-dom": "^18.0.11",
|
|
36
|
+
"chalk": "^5.2.0",
|
|
37
|
+
"conventional-changelog-cli": "^2.2.2",
|
|
38
|
+
"enquirer": "^2.3.6",
|
|
39
|
+
"execa": "5.1.1",
|
|
40
|
+
"minimist": "^1.2.8",
|
|
41
|
+
"rehype-stringify": "^9.0.3",
|
|
42
|
+
"remark-parse": "^10.0.1",
|
|
43
|
+
"remark-rehype": "^10.1.0",
|
|
44
|
+
"rollup": "^3.14.0",
|
|
45
|
+
"semver": "^7.5.0",
|
|
46
|
+
"tsup": "^6.6.2",
|
|
47
|
+
"tsx": "^3.12.3",
|
|
48
|
+
"typescript": "^4.9.5",
|
|
49
|
+
"unified": "^10.1.2",
|
|
50
|
+
"unist-util-visit": "^4.1.2",
|
|
51
|
+
"vitest": "^0.28.4"
|
|
52
|
+
},
|
|
53
|
+
"dependencies": {
|
|
54
|
+
"@loadable/component": "^5.15.3",
|
|
55
|
+
"@mdx-js/rollup": "2.1.3",
|
|
56
|
+
"@types/react": "^18.0.27",
|
|
57
|
+
"@vitejs/plugin-react": "^3.1.0",
|
|
58
|
+
"acorn": "^8.8.2",
|
|
59
|
+
"cac": "^6.7.14",
|
|
60
|
+
"compression": "^1.7.4",
|
|
61
|
+
"fast-glob": "^3.2.12",
|
|
62
|
+
"fs-extra": "^11.1.0",
|
|
63
|
+
"github-slugger": "^2.0.0",
|
|
64
|
+
"hast-util-from-html": "^1.0.1",
|
|
65
|
+
"koa": "^2.14.1",
|
|
66
|
+
"mdast-util-mdxjs-esm": "^1.3.1",
|
|
67
|
+
"polka": "^0.5.2",
|
|
68
|
+
"react": "^18.2.0",
|
|
69
|
+
"react-dom": "^18.2.0",
|
|
70
|
+
"react-helmet-async": "1.3.0",
|
|
71
|
+
"react-router-dom": "6.4.3",
|
|
72
|
+
"rehype-autolink-headings": "^6.1.1",
|
|
73
|
+
"rehype-slug": "^5.1.0",
|
|
74
|
+
"remark-frontmatter": "^4.0.1",
|
|
75
|
+
"remark-gfm": "^3.0.1",
|
|
76
|
+
"remark-mdx": "^2.3.0",
|
|
77
|
+
"remark-mdx-frontmatter": "^2.1.1",
|
|
78
|
+
"remark-stringify": "^10.0.2",
|
|
79
|
+
"sass": "^1.60.0",
|
|
80
|
+
"serve": "^14.2.0",
|
|
81
|
+
"shiki": "^0.14.1",
|
|
82
|
+
"sirv": "^2.0.2",
|
|
83
|
+
"unocss": "^0.50.4",
|
|
84
|
+
"vite": "^4.1.1"
|
|
85
|
+
},
|
|
86
|
+
"scripts": {
|
|
87
|
+
"start": "tsup --watch",
|
|
88
|
+
"build": "tsup",
|
|
89
|
+
"test:unit": "vitest run",
|
|
90
|
+
"test:watch": "vitest",
|
|
91
|
+
"test:e2e": "playwright test",
|
|
92
|
+
"prepare:e2e": "tsx scripts/e2e.ts",
|
|
93
|
+
"release": "tsx scripts/release.ts",
|
|
94
|
+
"changelog": "conventional-changelog -p angular -i CHANGELOG.md -s"
|
|
95
|
+
},
|
|
96
|
+
"readme": "# a static site automation framework\r\n\r\n# 毕业设计\r\n## 静态网站自动化构建框架\r\n将我的毕业设计取名为vigor.<br />\r\n特意选v字开头的单词,代表着使用vue、vite和nodejs开发。 <br />\r\n寓意青春活力,作为不知不觉已经过去20年青春的段落结尾,接下来要开启新的生活也是新的人生阶段,希望自己将来在对线生活的路上满腔热忱。\r\n\r\n\r\n"
|
|
97
|
+
}
|
package/src/core/cli.ts
ADDED
|
File without changes
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { matchRoutes } from "react-router-dom";
|
|
2
|
+
import { routes } from "vigor:routes";
|
|
3
|
+
import siteData from "vigor:site-data";
|
|
4
|
+
import { Layout } from "../theme-default/Layout";
|
|
5
|
+
import { Route } from '../node/plugin/plugin-routes/index';
|
|
6
|
+
import { PageData } from "types";
|
|
7
|
+
|
|
8
|
+
export async function initPageData(routePath: string): Promise<PageData> {
|
|
9
|
+
const matched = matchRoutes(routes, routePath);
|
|
10
|
+
|
|
11
|
+
if (matched) {
|
|
12
|
+
const route = matched[0].route as Route;
|
|
13
|
+
// 获取路由组件编译后的模块内容
|
|
14
|
+
const moduleInfo = await route.preload();
|
|
15
|
+
return {
|
|
16
|
+
title: moduleInfo.title,
|
|
17
|
+
pageType: moduleInfo?.frontmatter?.pageType ?? "doc",
|
|
18
|
+
siteData: siteData,
|
|
19
|
+
frontmatter: moduleInfo.frontmatter,
|
|
20
|
+
pagePath: routePath,
|
|
21
|
+
// 这边有一个类型错误,应该是上面的moduleInfo那边产生了类型不匹配的问题
|
|
22
|
+
toc: moduleInfo.toc as any
|
|
23
|
+
}
|
|
24
|
+
} else {
|
|
25
|
+
return {
|
|
26
|
+
title: "404",
|
|
27
|
+
pageType: "404",
|
|
28
|
+
siteData,
|
|
29
|
+
pagePath: routePath,
|
|
30
|
+
frontmatter: {}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export function App() {
|
|
37
|
+
return <Layout />
|
|
38
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
// import A from "../../docs/guide/a";
|
|
2
|
+
// import B from "../../docs/b";
|
|
3
|
+
// import Index from "../../docs/guide/index";
|
|
4
|
+
import { routes } from "vigor:routes";
|
|
5
|
+
import { useRoutes } from 'react-router-dom';
|
|
6
|
+
|
|
7
|
+
// 以下代码是展示路由结构,已经通过插件自动化生成了,所以不再需要手动添加。
|
|
8
|
+
// 自动化添加路由的插件会根据目录结构创建路由,再转化为相应代码。
|
|
9
|
+
// const routes = [
|
|
10
|
+
// {
|
|
11
|
+
// path: "/guide",
|
|
12
|
+
// element: <Index />
|
|
13
|
+
// },
|
|
14
|
+
// {
|
|
15
|
+
// path: "/guide/a",
|
|
16
|
+
// element: <A />
|
|
17
|
+
// },
|
|
18
|
+
// {
|
|
19
|
+
// path: "/b",
|
|
20
|
+
// element: <B />
|
|
21
|
+
// }
|
|
22
|
+
// ]
|
|
23
|
+
|
|
24
|
+
export const Content = () => {
|
|
25
|
+
const rootElement = useRoutes(routes);
|
|
26
|
+
return rootElement;
|
|
27
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { createRoot } from "react-dom/client"
|
|
2
|
+
import { App } from "./App";
|
|
3
|
+
import siteData from "vigor:site-data";
|
|
4
|
+
import { BrowserRouter } from "react-router-dom"
|
|
5
|
+
import { initPageData } from "./App";
|
|
6
|
+
import { contextData } from "./hooks";
|
|
7
|
+
import { HelmetProvider} from "react-helmet-async";
|
|
8
|
+
|
|
9
|
+
async function runderInBrowser() {
|
|
10
|
+
const containerEl = document.getElementById("root");
|
|
11
|
+
|
|
12
|
+
if (!containerEl) {
|
|
13
|
+
throw new Error("#root element not found");
|
|
14
|
+
}
|
|
15
|
+
// 初始化页面数据
|
|
16
|
+
const pageData = await initPageData(location.pathname);
|
|
17
|
+
createRoot(containerEl).render(
|
|
18
|
+
// 自定义head
|
|
19
|
+
<HelmetProvider>
|
|
20
|
+
<contextData.Provider value={ pageData }>
|
|
21
|
+
<BrowserRouter>
|
|
22
|
+
<App />
|
|
23
|
+
</BrowserRouter>
|
|
24
|
+
</contextData.Provider>
|
|
25
|
+
</HelmetProvider>
|
|
26
|
+
|
|
27
|
+
);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
runderInBrowser();
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { App } from "./App";
|
|
2
|
+
import { renderToString } from "react-dom/server"
|
|
3
|
+
import { StaticRouter } from "react-router-dom/server"
|
|
4
|
+
import { initPageData } from "./App";
|
|
5
|
+
import { contextData } from "./hooks";
|
|
6
|
+
import { HelmetProvider } from 'react-helmet-async';
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
// SSR渲染器
|
|
10
|
+
export async function render(pagePath: string, helmetContext: object) {
|
|
11
|
+
const pageData = await initPageData(pagePath);
|
|
12
|
+
return renderToString(
|
|
13
|
+
<HelmetProvider context={helmetContext}>
|
|
14
|
+
<contextData.Provider value={pageData}>
|
|
15
|
+
<StaticRouter location={pagePath}>
|
|
16
|
+
<App />
|
|
17
|
+
</StaticRouter>
|
|
18
|
+
</contextData.Provider>
|
|
19
|
+
</HelmetProvider>
|
|
20
|
+
);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
// 从路由插件中导出路由信息,方便ssr生产环境多路由打包
|
|
24
|
+
export { routes } from "vigor:routes";
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { useContextData } from "@runtime";
|
|
2
|
+
import { useLocation } from "react-router-dom";
|
|
3
|
+
import { Sidebar } from "../../component/sidebar";
|
|
4
|
+
import { Content } from "@runtime";
|
|
5
|
+
import { NextPage } from "../../component/nextPage";
|
|
6
|
+
import { TocComponent } from "../../component/toc";
|
|
7
|
+
import styles from "./index.module.scss";
|
|
8
|
+
import "./index.module.scss"
|
|
9
|
+
|
|
10
|
+
export function DocPage() {
|
|
11
|
+
const { siteData, toc } = useContextData();
|
|
12
|
+
const sidebarData = siteData.themeConfig?.sidebar || {};
|
|
13
|
+
// 拿到当前具体处于哪个侧边栏的item中
|
|
14
|
+
// 目的是获取到具体路径,然后对当前路径的导航栏保持高亮
|
|
15
|
+
const { pathname } = useLocation();
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
const matchedSidebarKey = Object.keys(sidebarData).find((key) => {
|
|
19
|
+
if (pathname.startsWith(key)) {
|
|
20
|
+
return true;
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
const matchedSidebar = sidebarData[matchedSidebarKey] || [];
|
|
25
|
+
|
|
26
|
+
return (
|
|
27
|
+
<div flex="~" >
|
|
28
|
+
<div w="1/4">
|
|
29
|
+
<Sidebar sidebarData={matchedSidebar} pathname={pathname} />
|
|
30
|
+
</div>
|
|
31
|
+
<div pt="22" w="3/4" className={styles.vigorDoc} flex="~">
|
|
32
|
+
<div w="2/3" className="vigor-doc">
|
|
33
|
+
<div className="divider-bottom">
|
|
34
|
+
<Content />
|
|
35
|
+
</div>
|
|
36
|
+
<div>
|
|
37
|
+
<NextPage />
|
|
38
|
+
</div>
|
|
39
|
+
</div>
|
|
40
|
+
<div className={styles.tocContainer} w="1/4" h="100vw" pl="20" >
|
|
41
|
+
<TocComponent headers={toc}></TocComponent>
|
|
42
|
+
</div>
|
|
43
|
+
</div>
|
|
44
|
+
</div>
|
|
45
|
+
);
|
|
46
|
+
}
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
.vigor-doc h1,
|
|
2
|
+
.vigor-doc h2,
|
|
3
|
+
.vigor-doc h3,
|
|
4
|
+
.vigor-doc h4,
|
|
5
|
+
.vigor-doc h5,
|
|
6
|
+
.vigor-doc h6 {
|
|
7
|
+
position: relative;
|
|
8
|
+
font-weight: 600;
|
|
9
|
+
outline: none;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
.vigor-doc h1 {
|
|
13
|
+
letter-spacing: -0.02em;
|
|
14
|
+
line-height: 40px;
|
|
15
|
+
font-size: 30px;
|
|
16
|
+
margin-bottom: 40px;
|
|
17
|
+
color: var(--vigor-c-h1-text);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
.vigor-doc h2 {
|
|
21
|
+
margin: 48px 0 16px;
|
|
22
|
+
/* padding-top: 24px; */
|
|
23
|
+
letter-spacing: -0.02em;
|
|
24
|
+
line-height: 32px;
|
|
25
|
+
font-size: 24px;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
.vigor-doc h3 {
|
|
29
|
+
margin: 32px 0 0;
|
|
30
|
+
letter-spacing: -0.01em;
|
|
31
|
+
line-height: 28px;
|
|
32
|
+
font-size: 20px;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
.toc-container {
|
|
37
|
+
position: sticky;
|
|
38
|
+
top: 10vh;
|
|
39
|
+
height: 100vh;
|
|
40
|
+
overflow-x: hidden;
|
|
41
|
+
overflow-y: auto;
|
|
42
|
+
scrollbar-width: none;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
.vigor-doc .header-anchor {
|
|
46
|
+
float: left;
|
|
47
|
+
margin-left: -0.87em;
|
|
48
|
+
padding-right: 0.23em;
|
|
49
|
+
font-weight: 500;
|
|
50
|
+
opacity: 1;
|
|
51
|
+
transition: color 0.25s, opacity 0.25s;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
.vigor-doc h1 a,
|
|
55
|
+
.vigor-doc h2 a,
|
|
56
|
+
.vigor-doc h3 a,
|
|
57
|
+
.vigor-doc h4 a,
|
|
58
|
+
.vigor-doc h5 a,
|
|
59
|
+
.vigor-doc h6 a
|
|
60
|
+
{
|
|
61
|
+
text-indent: -9999em;
|
|
62
|
+
overflow: hidden;
|
|
63
|
+
float: left;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// /* 设置段落样式 */
|
|
67
|
+
.vigor-doc p {
|
|
68
|
+
margin: 0 0 16px;
|
|
69
|
+
padding: 0;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
/* 设置代码块样式 */
|
|
74
|
+
.vigor-doc pre {
|
|
75
|
+
margin: 0 0 16px;
|
|
76
|
+
padding: 16px;
|
|
77
|
+
background-color: #f8f8f8;
|
|
78
|
+
border: 1px solid #ccc;
|
|
79
|
+
border-radius: 10px;
|
|
80
|
+
font-size: 14px;
|
|
81
|
+
line-height: 1.4;
|
|
82
|
+
overflow: auto;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
.vigor-doc p code {
|
|
86
|
+
font-family: Consolas, Monaco, "Andale Mono", "Ubuntu Mono", monospace;
|
|
87
|
+
font-size: 0.9em;
|
|
88
|
+
color: var(--main-color);
|
|
89
|
+
background-color: var(--light-color);
|
|
90
|
+
padding: 0.2em 0.4em;
|
|
91
|
+
border-radius: 3px;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
.vigor-doc pre code {
|
|
95
|
+
font-family: Consolas, Monaco, 'Andale Mono', monospace;
|
|
96
|
+
font-size: 14px;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
/* 设置块引用样式 */
|
|
101
|
+
.vigor-doc blockquote {
|
|
102
|
+
margin: 0 0 16px;
|
|
103
|
+
padding: 16px;
|
|
104
|
+
background-color: #f8f8f8;
|
|
105
|
+
border-left: 4px solid #007bff;
|
|
106
|
+
color: #666;
|
|
107
|
+
font-style: italic;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/* 设置强调样式 */
|
|
111
|
+
.vigor-doc em, strong {
|
|
112
|
+
font-style: italic;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
.vigor-doc strong {
|
|
116
|
+
font-weight: 600;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/* 设置表格样式 */
|
|
120
|
+
.vigor-doc table {
|
|
121
|
+
border-collapse: collapse;
|
|
122
|
+
width: 100%;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
.vigor-doc th, td {
|
|
126
|
+
border: 1px solid #ccc;
|
|
127
|
+
padding: 8px;
|
|
128
|
+
text-align: left;
|
|
129
|
+
vertical-align: top;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
.vigor-doc th {
|
|
133
|
+
font-weight: 600;
|
|
134
|
+
background-color: #f8f8f8;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
/* 代码块 */
|
|
139
|
+
// pre {
|
|
140
|
+
// background-color: var(--light-color);
|
|
141
|
+
// border: 1px solid var(--main-color);
|
|
142
|
+
// padding: 1em;
|
|
143
|
+
// margin: 1em 0;
|
|
144
|
+
// overflow: auto;
|
|
145
|
+
// }
|
|
146
|
+
|
|
147
|
+
|
|
148
|
+
// .vigor-doc p code:hover {
|
|
149
|
+
// background-color: var(--main-color);
|
|
150
|
+
// color: var(--light-color);
|
|
151
|
+
// cursor: pointer
|
|
152
|
+
// }
|
|
153
|
+
|
|
154
|
+
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { useContextData } from "@runtime"
|
|
2
|
+
import { HeroComponent } from "../../component/hero";
|
|
3
|
+
import { FeatureComponent } from "../../component/feature";
|
|
4
|
+
import { FooterComponent } from "../../component/footer";
|
|
5
|
+
|
|
6
|
+
export function HomePage() {
|
|
7
|
+
const { frontmatter } = useContextData();
|
|
8
|
+
|
|
9
|
+
return (
|
|
10
|
+
<div className = "px-24 pt-30">
|
|
11
|
+
<HeroComponent hero={frontmatter.hero} />
|
|
12
|
+
<FeatureComponent features={frontmatter.features} />
|
|
13
|
+
<FooterComponent footer={ frontmatter.footer } />
|
|
14
|
+
</div>
|
|
15
|
+
)
|
|
16
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { useState } from "react"
|
|
2
|
+
import { useContextData } from "@runtime";
|
|
3
|
+
|
|
4
|
+
// 引入样式基础配置
|
|
5
|
+
import "../styles/base.css";
|
|
6
|
+
import "../styles/vars.css";
|
|
7
|
+
import "uno.css"
|
|
8
|
+
|
|
9
|
+
// 页面
|
|
10
|
+
import { Nav } from "../component/nav";
|
|
11
|
+
import { HomePage } from "./home/home";
|
|
12
|
+
import { DocPage } from "./doc/doc";
|
|
13
|
+
import { NotFoundPage } from "./notFound/index";
|
|
14
|
+
import { Helmet } from "react-helmet-async";
|
|
15
|
+
|
|
16
|
+
export function Layout() {
|
|
17
|
+
const pageData = useContextData();
|
|
18
|
+
const { pageType, title } = pageData;
|
|
19
|
+
const Content = () => {
|
|
20
|
+
if (pageType === "home") {
|
|
21
|
+
return <HomePage />
|
|
22
|
+
} else if (pageType === "doc") {
|
|
23
|
+
return <DocPage />
|
|
24
|
+
} else {
|
|
25
|
+
return <NotFoundPage />
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
return <div>
|
|
30
|
+
<Helmet>
|
|
31
|
+
<title>{ title }</title>
|
|
32
|
+
</Helmet>
|
|
33
|
+
<Nav />
|
|
34
|
+
<section>
|
|
35
|
+
{ Content() }
|
|
36
|
+
</section>
|
|
37
|
+
</div>
|
|
38
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import styles from "./index.module.scss";
|
|
2
|
+
|
|
3
|
+
const imgOssPath = "http://mingxuan3569.oss-cn-beijing.aliyuncs.com/image/404.png";
|
|
4
|
+
|
|
5
|
+
export function NotFoundPage() {
|
|
6
|
+
return (
|
|
7
|
+
<div flex="~" h="full">
|
|
8
|
+
<div w="1/2" h="full">
|
|
9
|
+
<h1 className={styles.h1}>404</h1>
|
|
10
|
+
<a
|
|
11
|
+
inline-block=""
|
|
12
|
+
border="1px solid brand"
|
|
13
|
+
rounded="2xl"
|
|
14
|
+
p="y-2 x-4"
|
|
15
|
+
text="sm brand"
|
|
16
|
+
font-medium=""
|
|
17
|
+
href={'/'}
|
|
18
|
+
aria-label="go to home"
|
|
19
|
+
relative="~"
|
|
20
|
+
className="left-58 top-20"
|
|
21
|
+
>
|
|
22
|
+
Take me home
|
|
23
|
+
</a>
|
|
24
|
+
</div>
|
|
25
|
+
<div relative="~" className="top-10" >
|
|
26
|
+
<img className="w-250 left-0" src={imgOssPath} alt="404" />
|
|
27
|
+
</div>
|
|
28
|
+
</div>
|
|
29
|
+
)
|
|
30
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
.button {
|
|
2
|
+
display: inline-block;
|
|
3
|
+
border: 1px solid transparent;
|
|
4
|
+
text-align: center;
|
|
5
|
+
font-weight: 500;
|
|
6
|
+
white-space: nowrap;
|
|
7
|
+
transition: color 0.25s, border-color 0.25s, background-color 0.25s;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
.button:active {
|
|
11
|
+
transition: color 0.1s, border-color 0.1s, background-color 0.1s;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
.button.medium {
|
|
15
|
+
border-radius: 20px;
|
|
16
|
+
padding: 0 20px;
|
|
17
|
+
line-height: 38px;
|
|
18
|
+
font-size: 14px;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.button.big {
|
|
22
|
+
border-radius: 24px;
|
|
23
|
+
padding: 0 24px;
|
|
24
|
+
line-height: 46px;
|
|
25
|
+
font-size: 16px;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
.button.brand {
|
|
29
|
+
background-color: var(--vigor-bg-brand);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
.button.alt {
|
|
33
|
+
background-color: var(--vigor-bg-alt);
|
|
34
|
+
opacity: 70%
|
|
35
|
+
}
|
|
36
|
+
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { Link } from "../Link";
|
|
3
|
+
import styles from "./index.module.scss";
|
|
4
|
+
|
|
5
|
+
interface ButtonTypes {
|
|
6
|
+
type?: string;
|
|
7
|
+
size?: "small" | "medium" | "big";
|
|
8
|
+
text: string;
|
|
9
|
+
theme: "brand" | "alt";
|
|
10
|
+
href: string;
|
|
11
|
+
external?: boolean;
|
|
12
|
+
className?: string;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
// 按钮组件
|
|
16
|
+
// 按钮组件主要有设定大小、主题和内外链接的自定义
|
|
17
|
+
export function Button(props: ButtonTypes) {
|
|
18
|
+
const {
|
|
19
|
+
theme = "brand",
|
|
20
|
+
href = "/",
|
|
21
|
+
size = "big",
|
|
22
|
+
external = false,
|
|
23
|
+
className = ""
|
|
24
|
+
} = props;
|
|
25
|
+
|
|
26
|
+
// 如果是外部链接
|
|
27
|
+
let type: string | typeof Link | null = null;
|
|
28
|
+
if (props.type === "button") {
|
|
29
|
+
type = "button"
|
|
30
|
+
} else if (props.type === "a") {
|
|
31
|
+
type = external ? "a" : Link;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
return React.createElement(
|
|
35
|
+
type ?? "a",
|
|
36
|
+
{
|
|
37
|
+
href,
|
|
38
|
+
className: `${styles.button} ${styles[size]} ${styles[theme]} ${className}`
|
|
39
|
+
},
|
|
40
|
+
props.text
|
|
41
|
+
)
|
|
42
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import styles from "./index.module.scss"
|
|
3
|
+
interface LinkType {
|
|
4
|
+
href?: string;
|
|
5
|
+
children?: React.ReactNode;
|
|
6
|
+
className?: string;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
// Link组件
|
|
10
|
+
// Link组件是用来区分外部链接和内部链接的,
|
|
11
|
+
// 如果是外部链接,那么会直接转到响应的超链接位置。
|
|
12
|
+
// 如果是内部链接,则转到响应路由位置
|
|
13
|
+
|
|
14
|
+
// 用正则来判断是否是以http或https作为开头的,如果是这两者作为开头,则是外部链接
|
|
15
|
+
const EXTERNAL_URL = /^https?/
|
|
16
|
+
|
|
17
|
+
export function Link(props: LinkType) {
|
|
18
|
+
const { href = "/", children, className = "" } = props;
|
|
19
|
+
const isExternal = EXTERNAL_URL.test(href);
|
|
20
|
+
|
|
21
|
+
// target和rel是a标签的两个属性
|
|
22
|
+
// target的值为_blank时,会另外打开一个网页展示超链接
|
|
23
|
+
// 在使用target时如果没有设置rel为noopener noreferrer会有安全风险,用来防止钓鱼网站
|
|
24
|
+
const target = isExternal ? '_blank' : '';
|
|
25
|
+
const rel = isExternal ? "noopener noreferrer" : undefined;
|
|
26
|
+
|
|
27
|
+
return <a href={href} rel={rel} target={target} className={`${className} ${styles.link}`}>{ children } </a>
|
|
28
|
+
}
|