Skip to content
This repository was archived by the owner on Nov 2, 2024. It is now read-only.

Commit 26e5704

Browse files
authored
docs(themes): add documents for deploying themes (#7)
1 parent 8b1b606 commit 26e5704

File tree

14 files changed

+569
-1
lines changed

14 files changed

+569
-1
lines changed

components/Icons/GitHub.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import { SVGProps } from "react";
2+
3+
export function UilGithub(props: SVGProps<SVGSVGElement>) {
4+
return (
5+
<svg xmlns="http://www.w3.org/2000/svg" width="1.5em" height="1.5em" viewBox="0 0 24 24" {...props}><path fill="currentColor" d="M12 2.247a10 10 0 0 0-3.162 19.487c.5.088.687-.212.687-.475c0-.237-.012-1.025-.012-1.862c-2.513.462-3.163-.613-3.363-1.175a3.636 3.636 0 0 0-1.025-1.413c-.35-.187-.85-.65-.013-.662a2.001 2.001 0 0 1 1.538 1.025a2.137 2.137 0 0 0 2.912.825a2.104 2.104 0 0 1 .638-1.338c-2.225-.25-4.55-1.112-4.55-4.937a3.892 3.892 0 0 1 1.025-2.688a3.594 3.594 0 0 1 .1-2.65s.837-.262 2.75 1.025a9.427 9.427 0 0 1 5 0c1.912-1.3 2.75-1.025 2.75-1.025a3.593 3.593 0 0 1 .1 2.65a3.869 3.869 0 0 1 1.025 2.688c0 3.837-2.338 4.687-4.563 4.937a2.368 2.368 0 0 1 .675 1.85c0 1.338-.012 2.413-.012 2.75c0 .263.187.575.687.475A10.005 10.005 0 0 0 12 2.247Z"></path></svg>
6+
)
7+
}

components/ToGitHub/index.tsx

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import { UilGithub } from "@components/Icons/GitHub";
2+
import { Cards, Card } from "nextra/components";
3+
4+
export function ToGitHub({ repo }) {
5+
return (
6+
<Cards num={1}>
7+
<Card
8+
arrow
9+
href={`https://github.com/${repo}`}
10+
title={`${repo} - GitHub`}
11+
icon={<UilGithub />}
12+
children
13+
// @ts-ignore
14+
target="_blank"
15+
/>
16+
</Cards>
17+
);
18+
}

components/Video/index.tsx

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
import { useEffect, useRef } from 'react';
2+
3+
export default function Video({ src }) {
4+
const videoRef = useRef(null);
5+
6+
useEffect(() => {
7+
const options = {
8+
root: null,
9+
rootMargin: '0px',
10+
threshold: 0.5,
11+
};
12+
13+
const handleIntersection = (entries) => {
14+
entries.forEach((entry) => {
15+
if (entry.isIntersecting) {
16+
videoRef.current.play();
17+
} else {
18+
videoRef.current.pause();
19+
}
20+
});
21+
};
22+
23+
const observer = new IntersectionObserver(handleIntersection, options);
24+
observer.observe(videoRef.current);
25+
26+
return () => {
27+
videoRef.current && observer.unobserve(videoRef.current);
28+
};
29+
}, [src]);
30+
31+
return (
32+
<video
33+
ref={videoRef}
34+
muted
35+
autoPlay
36+
playsInline
37+
loop
38+
controls
39+
className="mt-6 rounded-xl border dark:border-zinc-800"
40+
>
41+
<source src={src} type="video/mp4" />
42+
</video>
43+
);
44+
}

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
"@vercel/og": "^0.5.8",
2222
"autoprefixer": "^10.4.14",
2323
"clsx": "^1.2.1",
24+
"copy-to-clipboard": "^3.3.3",
2425
"framer-motion": "^10.12.18",
2526
"next": "^13.4.9",
2627
"nextra": "latest",

pages/_meta.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,11 @@
1717
},
1818
"themes": {
1919
"type": "page",
20-
"title": "前端主题"
20+
"title": "前端主题",
21+
"href": "/themes",
22+
"theme": {
23+
"layout": "raw"
24+
}
2125
},
2226
"development": {
2327
"title": "系统开发",

pages/themes/_meta.json

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"index": {
3+
"title": "主题目录"
4+
},
5+
"shiro": {
6+
"title": "部署 Shiro 主题",
7+
"theme": {
8+
"layout": "default"
9+
}
10+
},
11+
"kami": {
12+
"title": "部署 Kami 主题",
13+
"theme": {
14+
"layout": "default"
15+
}
16+
},
17+
"yun": {
18+
"title": "部署 Yun 主题",
19+
"theme": {
20+
"layout": "default"
21+
}
22+
}
23+
}

pages/themes/index.mdx

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
---
2+
title: 前端主题
3+
---
4+
5+
import { Card, Cards } from "nextra/components";
6+
7+
{<h1 className="mt-10 mb-4 text-center text-[2.5rem] font-bold tracking-tight">前端主题</h1>}
8+
9+
{<p className="mb-16 text-center text-lg text-gray-500 dark:text-gray-400">基于 Mix Space 后端 API 开发的前端主题 <br/> 点击查看主题部署指南</p>}
10+
11+
<div className="m-8 mt-0">
12+
<Cards>
13+
<ThemeCard title="Shiro - @Innei" href="/themes/shiro">
14+
<>
15+
![Shiro Preview](./shiro_preview.png)
16+
</>
17+
</ThemeCard>
18+
<ThemeCard title="Kami - @Innei" href="/themes/kami">
19+
<>
20+
![Kami Preview](./kami_preview.png)
21+
</>
22+
</ThemeCard>
23+
<ThemeCard title="Yun - @Innei" href="/themes/yun">
24+
<>
25+
![Yun Preview](./yun_preview.png)
26+
</>
27+
</ThemeCard>
28+
</Cards>
29+
</div>
30+
31+
32+
export const ThemeCard = Object.assign(
33+
// Copy card component and add default props
34+
Card.bind(),
35+
{
36+
displayName: "ThemeCard",
37+
defaultProps: {
38+
image: true,
39+
arrow: true,
40+
target: "_self",
41+
},
42+
}
43+
);
44+
45+
<style global jsx>{`
46+
.nextra-cards img {
47+
aspect-ratio: 12/6.3;
48+
object-fit: cover;
49+
}
50+
`}</style>

pages/themes/kami.mdx

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# Kami 主题
2+
3+
import { ToGitHub } from '@components/ToGitHub';
4+
5+
<ToGitHub repo="mx-space/kami" />
6+
7+
import { Callout, Steps } from "nextra/components";
8+
9+
<Callout type="warning">
10+
下一个代替项目将会是 Shiro,当它完成之时,我便不再投入任何精力到 Kami 中。迎接未来总需要舍弃一些东西,非常感谢大家三年来使用 Kami,不管你是谁,都需要对你说声谢谢。**—— Innei**
11+
</Callout>
12+
13+
由于 Kami 主题将不再维护,此文档将不再更新,但是你仍然可以使用它。
14+
15+
<Steps>
16+
### 克隆项目
17+
18+
```bash
19+
git clone https://github.com/mx-space/kami.git --depth=1
20+
cd kami && git fetch --tags && git checkout $(git rev-list --tags --max-count=1)
21+
```
22+
23+
### 安装依赖
24+
25+
```bash
26+
git lfs fetch --all
27+
git lfs pull
28+
pnpm i
29+
```
30+
31+
### 配置 ENV
32+
33+
1. 复制 .env.example 为 .env
34+
2. 编辑 .env 文件,它看起来应该是这个样子的
35+
36+
```env
37+
# API 地址
38+
NEXT_PUBLIC_API_URL=https://server.test.cn/api/v2
39+
# GATEWAY 地址
40+
NEXT_PUBLIC_GATEWAY_URL=https://server.test.cn
41+
#前端使用的配置项名字
42+
NEXT_PUBLIC_SNIPPET_NAME=kami
43+
# 如果使用 CDN, 修改产物前缀;一般留空
44+
ASSETPREFIX=
45+
```
46+
47+
### 开始构建
48+
49+
```bash
50+
pnpm build
51+
```
52+
53+
### 启动前端
54+
55+
```bash
56+
pnpm prod:pm2
57+
```
58+
</Steps>

pages/themes/kami_preview.png

1.94 MB
Loading

0 commit comments

Comments
 (0)