Skip to content

Commit

Permalink
feat: 美化文档
Browse files Browse the repository at this point in the history
fix: 优化部分过时内容
  • Loading branch information
ikenxuan committed Jul 21, 2024
1 parent b3cbbd7 commit c61444c
Show file tree
Hide file tree
Showing 30 changed files with 452 additions and 155 deletions.
158 changes: 157 additions & 1 deletion docs/.vitepress/config.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,57 @@
import { defineConfig } from 'vitepress'
import timeline from 'vitepress-markdown-timeline'
import taskLists from "markdown-it-task-lists"
import mathjax3 from 'markdown-it-mathjax3'
import footnote_plugin from 'markdown-it-footnote'

export default defineConfig({
lang: 'zh-CN',
base: '/Karin',
title: 'karin',
description: '基于 Kritor 进行开发的nodejs机器人框架',
markdown: {
// 全局代码块行号显示
lineNumbers: true,
image: {
// 开启图片懒加载
lazyLoading: true,
},
config: (md) => {
// 时间线
md.use(timeline)
// 任务列表
md.use(taskLists)
// 公式
md.use(mathjax3)
// 脚注
md.use(footnote_plugin)
},
},
vue: {
template: {
compilerOptions: {
isCustomElement: (tag) => customElements.includes(tag),
},
},
},
// 移除地址的.html
cleanUrls: true,
// 显示最后更新时间
lastUpdated: true,
head: [
['link', { rel: 'icon', href: '/Karin/logo.png' }],
],
themeConfig: {
siteTitle: 'Karin主页',
logo: {
src: '/logo.png',
},
// 深浅模式文字翻译
darkModeSwitchLabel: '深浅模式',
editLink: {
pattern: 'https://github.com/KarinJS/Karin/edit/docs/docs/:path',
text: '在 GitHub 上编辑此页面',
},
outline: {
level: [2, 4],
label: '页面导航'
Expand Down Expand Up @@ -124,8 +169,28 @@ export default defineConfig({
],
},
socialLinks: [
{ icon: 'github', link: 'https://github.com/KarinJS/Karin' }
{ icon: 'github', link: 'https://github.com/KarinJS/Karin' },
{
icon: {
svg: '<svg t="1718335878865" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="1729" width="200" height="200"><path d="M512 1024C229.248 1024 0 794.752 0 512S229.248 0 512 0s512 229.248 512 512-229.248 512-512 512z m259.168-568.896h-290.752a25.28 25.28 0 0 0-25.28 25.28l-0.032 63.232c0 13.952 11.296 25.28 25.28 25.28h177.024a25.28 25.28 0 0 1 25.28 25.28v12.64a75.84 75.84 0 0 1-75.84 75.84h-240.224a25.28 25.28 0 0 1-25.28-25.28v-240.192a75.84 75.84 0 0 1 75.84-75.84h353.92a25.28 25.28 0 0 0 25.28-25.28l0.064-63.2a25.312 25.312 0 0 0-25.28-25.312H417.184a189.632 189.632 0 0 0-189.632 189.6v353.952c0 13.952 11.328 25.28 25.28 25.28h372.928a170.656 170.656 0 0 0 170.656-170.656v-145.376a25.28 25.28 0 0 0-25.28-25.28z" p-id="1730"></path></svg>',
},
link: 'https://gitee.com/KarinJS/Karin',
}
],
footer: {
message: "Released under the <a href='https://github.com/KarinJS/Karin/blob/dev/LICENSE'>GPL-3.0 License</a>",
copyright: "Copyright © 2024 <a href='https://github.com/KarinJS/Karin'>Karin</a>",
},
docFooter: {
prev: '上一页',
next: '下一页',
},
lastUpdatedText: '最后编辑于',
outlineTitle: '本页大纲',
// 侧边栏文字更改
sidebarMenuLabel: '目录',
// 返回顶部文字修改
returnToTopLabel: '返回顶部',
search: {
provider: 'algolia',
options: {
Expand Down Expand Up @@ -175,3 +240,94 @@ export default defineConfig({
}
}
})


const customElements = [
'mjx-container',
'mjx-assistive-mml',
'math',
'maction',
'maligngroup',
'malignmark',
'menclose',
'merror',
'mfenced',
'mfrac',
'mi',
'mlongdiv',
'mmultiscripts',
'mn',
'mo',
'mover',
'mpadded',
'mphantom',
'mroot',
'mrow',
'ms',
'mscarries',
'mscarry',
'mscarries',
'msgroup',
'mstack',
'mlongdiv',
'msline',
'mstack',
'mspace',
'msqrt',
'msrow',
'mstack',
'mstack',
'mstyle',
'msub',
'msup',
'msubsup',
'mtable',
'mtd',
'mtext',
'mtr',
'munder',
'munderover',
'semantics',
'math',
'mi',
'mn',
'mo',
'ms',
'mspace',
'mtext',
'menclose',
'merror',
'mfenced',
'mfrac',
'mpadded',
'mphantom',
'mroot',
'mrow',
'msqrt',
'mstyle',
'mmultiscripts',
'mover',
'mprescripts',
'msub',
'msubsup',
'msup',
'munder',
'munderover',
'none',
'maligngroup',
'malignmark',
'mtable',
'mtd',
'mtr',
'mlongdiv',
'mscarries',
'mscarry',
'msgroup',
'msline',
'msrow',
'mstack',
'maction',
'semantics',
'annotation',
'annotation-xml',
]
28 changes: 28 additions & 0 deletions docs/.vitepress/theme/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/* .vitepress\theme\index.ts */
import DefaultTheme from 'vitepress/theme'
import mediumZoom from 'medium-zoom'
import { onMounted, watch, nextTick } from 'vue'
import { useData, useRoute } from 'vitepress'
import 'vitepress-markdown-timeline/dist/theme/index.css'
import './style/index.css'

export default {
extends: DefaultTheme,
/** 响应式图片缩放 */
setup () {
const route = useRoute()
const initZoom = () => {
// 响应式的图片放大缩小
// mediumZoom('[data-zoomable]', { background: 'var(--vp-c-bg)' }); // 默认
mediumZoom('.main img', { background: 'var(--vp-c-bg)' }) // 不显式添加{data-zoomable}的情况下为所有图像启用此功能
}
onMounted(() => {
initZoom()
})
watch(
() => route.path,
() => nextTick(() => initZoom())
)
const { frontmatter } = useData()
},
}
3 changes: 3 additions & 0 deletions docs/.vitepress/theme/style/index.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
@import './var.css';
@import './vp-code-group.css';
@import './mathjax3.css';
9 changes: 9 additions & 0 deletions docs/.vitepress/theme/style/mathjax3.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
mjx-container {
display: inline-block;
margin: auto 2px -2px;
}

mjx-container>svg {
margin: auto;
display: inline-block;
}
60 changes: 60 additions & 0 deletions docs/.vitepress/theme/style/var.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/* var.css */
/* */
:root {
/* 主题色,浅色模式,深紫色调 */
/* 鼠标滑过高亮色,代码块高亮色,加粗高亮色 */
--vp-c-brand-1: #5224b6;
/* --vp-c-brand-1-2: #5224b6; */
--vp-c-brand-2: #352984;
--vp-c-brand-3: #6d68c1;
/* 主页logo大图底色 设置右图像渐变 */
--vp-home-hero-image-background-image: linear-gradient(-45deg, #f6abe9 50%, #ebe0ba 50%);
--vp-home-hero-image-filter: blur(150px);
}

/* 主题色,浅色模式,深紫色调 */
.dark {
--vp-c-brand-1: #C8ABFA;
--vp-c-brand-2: #3c30a4;
--vp-c-brand-3: #352984;
}

/* 移除链接跳转下划线 */
.vp-doc a {
text-decoration: none;
}

/* 提示框背景颜色 */
:root {
--vp-custom-block-tip-bg: var(--vp-c-green-soft);
--vp-home-hero-name-color: transparent;
--vp-home-hero-name-background: -webkit-linear-gradient(120deg, #6B7BF8, #F68BC6);
}

/* 提示框 */
.custom-block.tip {
border-color: var(--vp-c-green-2);
}

/* 警告框 */
.custom-block.warning {
/* border-color: #d97706; */
border-color: var(--vp-c-yellow-2);
}

/* 危险框 */
.custom-block.danger {
/* border-color: #f43f5e; */
border-color: var(--vp-c-red-2);
}

/** 响应式图片缩放覆盖范围 */
/** 最顶层 */
.medium-zoom-overlay {
z-index: 20;
}

.medium-zoom-image {
z-index: 9999 !important;
/* 给的值是21,但是实测盖不住,直接999 */
}
27 changes: 27 additions & 0 deletions docs/.vitepress/theme/style/vp-code-group.css.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/* .vitepress\theme\style\vp-code-group.css */

/* 代码块tab */
.vp-code-group .tabs {
padding-top: 30px;
}

/* 代码块tab-顶部小圆点 */
.vp-code-group .tabs::before {
background: #fc625d;
border-radius: 50%;
box-shadow: 20px 0 #fdbc40, 40px 0 #35cd4b;
content: ' ';
height: 12px;
width: 12px;
left: 12px;
margin-top: -20px;
position: absolute;
}


/* 代码组 */
.vp-code-group {
color: var(--vp-c-black-soft);
border-radius: 8px;
box-shadow: 0 10px 30px 0 rgb(0 0 0 / 40%);
}
1 change: 1 addition & 0 deletions docs/api/api.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# 正在编写中,咕咕咕~
2 changes: 1 addition & 1 deletion docs/api/index.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# 目录

> 咕咕咕~
> 正在编写中,咕咕咕~
## 标准API

Expand Down
Loading

0 comments on commit c61444c

Please sign in to comment.