Skip to content

Commit

Permalink
feat(doc): Use VitePress instead of Vuepress (#515)
Browse files Browse the repository at this point in the history
  • Loading branch information
Ahoo-Wang authored Jan 2, 2024
1 parent 2a3b52c commit 01fd5c9
Show file tree
Hide file tree
Showing 84 changed files with 2,741 additions and 21 deletions.
64 changes: 45 additions & 19 deletions .github/workflows/document-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,35 +11,61 @@
# limitations under the License.
#

name: Document Build and Deploy
name: Documentation Build and Deploy
on:
push:
paths:
- 'document/**'
- 'documentation/**'
pull_request:
paths:
- 'documentation/**'
workflow_dispatch:
permissions:
contents: write

jobs:
build-and-deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@master

- name: Build and Deploy
uses: jenkey2011/vuepress-deploy@master
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 18

- name: Build VitePress site
working-directory: documentation
run: npm add -D vitepress && npm run docs:build

- name: Deploy to gh-pages
uses: crazy-max/ghaction-github-pages@v4
env:
ACCESS_TOKEN: ${{ secrets.ACCESS_TOKEN }}
TARGET_REPO: Ahoo-Wang/CosId
TARGET_BRANCH: gh-pages
BUILD_SCRIPT: cd document && yarn && yarn docs:build
BUILD_DIR: docs/.vuepress/dist/
CNAME: cosid.ahoo.me

- name: Build and Deploy With Site Base
uses: jenkey2011/vuepress-deploy@master
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
target_branch: gh-pages
build_dir: documentation/docs/.vitepress/dist/
fqdn: cosid.ahoo.me

- name: Build VitePress site with SITE_BASE
working-directory: documentation
env:
SITE_BASE: /cosid/
ACCESS_TOKEN: ${{ secrets.ACCESS_TOKEN }}
TARGET_REPO: Ahoo-Wang/CosId
TARGET_BRANCH: gh-pages-with-site-base
BUILD_SCRIPT: cd document && yarn && yarn docs:build
BUILD_DIR: docs/.vuepress/dist/
CNAME: cosid.ahoo.me
run: npm add -D vitepress && npm run docs:build

- name: Deploy to gh-pages-with-site-base
uses: crazy-max/ghaction-github-pages@v4
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
target_branch: gh-pages-with-site-base
build_dir: documentation/docs/.vitepress/dist/

- name: Sync to Gitee
uses: wearerequired/git-mirror-action@master
env:
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
with:
source-repo: "[email protected]:Ahoo-Wang/CosId.git"
destination-repo: "[email protected]:AhooWang/CosId.git"
2 changes: 1 addition & 1 deletion document/docs/guide/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ UUID最大的缺陷是随机的、无序的,当用于主键时会导致数据
- ZookeeperMachineIdDistributor: 使用**ZooKeeper**作为机器号的分发存储,同时还会存储`MachineId`的上一次时间戳,用于**启动时时钟回拨**的检查。

<p align="center" >
<img :src="$withBase('/assets/design/RedisMachineIdDistributor.png')" alt="RedisMachineIdDistributor"/>
<img :src="$withBase('/assets/design/MachineIdDistributor.png')" alt="RedisMachineIdDistributor"/>
</p>

<p align="center">
Expand Down
2 changes: 1 addition & 1 deletion document/docs/guide/cosid-redis.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
## SpringRedisMachineIdDistributor

<p align="center" >
<img :src="$withBase('/assets/design/RedisMachineIdDistributor.png')" alt="SegmentId"/>
<img :src="$withBase('/assets/design/MachineIdDistributor.png')" alt="SegmentId"/>
</p>

<p align="center">
Expand Down
5 changes: 5 additions & 0 deletions documentation/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
node_modules
.temp
cache
docs/.vitepress/dist
docs/.vitepress/public/dokka
59 changes: 59 additions & 0 deletions documentation/docs/.vitepress/config.mts
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
import {defineConfig} from 'vitepress'
import {SITE_BASE} from "./configs/SITE_BASE";
import {head} from "./configs/head";
import {navbar} from "./configs/navbar";
import {sidebar} from "./configs/sidebar";
import {withMermaid} from "vitepress-plugin-mermaid";

let hostname = 'https://cosid.ahoo.me/';
if (SITE_BASE == '/wow/') {
hostname = 'https://ahoowang.gitee.io/cosid/'
}

// https://vitepress.dev/reference/site-config
let userConfig = defineConfig({
lang: 'zh-CN',
title: "CosId",
description: "通用、灵活、高性能的分布式ID生成器",
ignoreDeadLinks: 'localhostLinks',
head: head,
base: SITE_BASE,
sitemap: {
hostname: hostname
},
appearance: 'dark',
themeConfig: {
logo: '/logo.png',
siteTitle: '分布式ID生成器 | CosId',
editLink: {
pattern: 'https://github.com/Ahoo-Wang/CosId/edit/main/documentation/docs/:path'
},
lastUpdated: {
text: '上次更新'
},
outline: {
label: '本页目录',
level: [2, 3]
},
aside: true,
search: {provider: 'local',},
// https://vitepress.dev/reference/default-theme-config
nav: navbar,
sidebar: sidebar,
socialLinks: [
{icon: 'github', link: 'https://github.com/Ahoo-Wang/CosId'}
],
externalLinkIcon: true,
footer: {
message: 'Released under the Apache 2.0 License.',
copyright: 'Copyright © 2022-present <a href="https://github.com/Ahoo-Wang" target="_blank">Ahoo Wang</a>'
},
notFound: {
title: '页面未找到',
quote: '你访问的页面不存在。',
linkText: '返回首页'
}
}
})

export default withMermaid(userConfig)
14 changes: 14 additions & 0 deletions documentation/docs/.vitepress/configs/SITE_BASE.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/*
* Copyright [2021-present] [ahoo wang <[email protected]> (https://github.com/Ahoo-Wang)].
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

export const SITE_BASE: '/' | `/${string}/` = process.env.SITE_BASE || "/"
40 changes: 40 additions & 0 deletions documentation/docs/.vitepress/configs/head.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*
* Copyright [2021-present] [ahoo wang <[email protected]> (https://github.com/Ahoo-Wang)].
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

import {SITE_BASE} from "./SITE_BASE";
import {HeadConfig} from "vitepress";

export const head: HeadConfig[] = [
['link', {rel: 'icon', href: `${SITE_BASE}favicon.ico`}],
['meta', {
name: 'keywords',
content: '通用, 灵活, 高性能的分布式ID生成器'
}],
['meta', {'http-equiv': 'cache-control', content: 'no-cache, no-store, must-revalidate'}],
['meta', {'http-equiv': 'pragma', content: 'no-cache'}],
['meta', {'http-equiv': 'expires', content: '0'}],
['meta', {name: 'application-name', content: 'CosId'}],
['meta', {name: 'theme-color', content: '#5f67ee'}],
[
'script',
{async: '', src: 'https://www.googletagmanager.com/gtag/js?id=G-SP6EEGK56L'}
],
[
'script',
{},
`window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'G-SP6EEGK56L');`
]
]
52 changes: 52 additions & 0 deletions documentation/docs/.vitepress/configs/navbar.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import {DefaultTheme} from "vitepress/types/default-theme";

export const navbar: DefaultTheme.NavItem[] = [
{
text: '指南',
link: '/guide/getting-started',
activeMatch: '^/guide/'
},
{
text: '配置',
link: '/reference/config/basic',
activeMatch: '^/reference/config/'
},
{
text: "资源",
items: [
{
text: '开源项目 - 微服务治理',
items: [
{
text: 'Wow - 基于 DDD & EventSourcing 的现代响应式 CQRS 架构微服务开发框架',
link: 'https://github.com/Ahoo-Wang/Wow'
},
{
text: 'CoSky - 高性能、低成本微服务治理平台',
link: 'https://github.com/Ahoo-Wang/CoSky'
},
{
text: 'CoSec - 基于 RBAC 和策略的多租户响应式安全框架',
link: 'https://github.com/Ahoo-Wang/CoSec'
},
{
text: 'CoCache - 分布式一致性二级缓存框架',
link: 'https://github.com/Ahoo-Wang/CoCache'
},
{
text: 'Simba - 易用、灵活的分布式锁服务',
link: 'https://github.com/Ahoo-Wang/Simba'
}
]
}
]
},
{
text: `更新日志`,
link: `https://github.com/Ahoo-Wang/CosId/releases`
},
{
text: `Gitee`,
link: `https://gitee.com/AhooWang/CosId`
}
]
111 changes: 111 additions & 0 deletions documentation/docs/.vitepress/configs/sidebar.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
/*
* Copyright [2021-present] [ahoo wang <[email protected]> (https://github.com/Ahoo-Wang)].
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

import {DefaultTheme} from "vitepress/types/default-theme";

export const sidebar: DefaultTheme.Sidebar = {
'/guide/': [
{
base: '/guide/',
text: '指南',
collapsed: false,
items: [
{text: '简介', link: 'introduction'},
{text: '快速上手', link: 'getting-started'},
{text: 'SnowflakeId', link: 'snowflake'},
{text: 'SegmentId', link: 'segment'},
{text: 'SegmentChainId', link: 'segment-chain'},
{text: 'CosIdGenerator', link: 'cosid-generator'},
{text: 'CosIdProxy', link: 'cosid-proxy'},
],
}, {
base: '/guide/extensions/',
text: '扩展',
collapsed: false,
items: [
{text: 'Redis', link: 'cosid-redis'},
{text: 'Jdbc', link: 'cosid-jdbc'},
{text: 'MongoDB', link: 'cosid-mongo'},
{text: 'Zookeeper', link: 'cosid-zookeeper'},
{text: 'MyBatis', link: 'cosid-mybatis'},
{text: 'Jackson', link: 'cosid-jackson'},
{text: 'Spring-Data-Jdbc', link: 'cosid-spring-data-jdbc'},
{text: 'Spring-Boot-Starter', link: 'cosid-spring-boot-starter'},
{text: 'Activiti', link: 'cosid-activiti'},
{text: 'Flowable', link: 'cosid-flowable'},
{text: 'Axon', link: 'cosid-axon'},
{text: 'ShardingSphere', link: 'cosid-shardingsphere'},
{text: '兼容性测试套件', link: 'cosid-test'},
],
}, {
base: '/guide/faq/',
text: 'FAQ',
collapsed: false,
items: [
{text: '常见问题', link: 'faq'},
{text: '性能评测', link: 'perf-test'},
{text: 'CosId VS 美团 Leaf', link: 'Performance-CosId-Leaf'},
],
}, {
base: '/guide/advanced/',
text: '深入',
collapsed: false,
items: [
{text: 'IdGenerator', link: 'id-generator'},
{text: 'IdConverter', link: 'id-converter'},
{text: 'IdGeneratorProvider', link: 'provider'},
{text: 'Sharding', link: 'sharding'},
],
}, {
text: '配置',
link: '/reference/config/basic'
}
],
'/reference/': [
{
text: '配置',
base: '/reference/config/',
collapsed: false,
items: [
{text: '基础', link: 'basic'},
{text: '工作进程号', link: 'machine'},
{text: 'Snowflake', link: 'snowflake'},
{text: 'Segment', link: 'segment'},
{text: 'Zookeeper', link: 'zookeeper'},
{text: 'ShardingSphere', link: 'shardingsphere'},
],
},
// {
// text: 'API',
// base: '/reference/api/',
// collapsed: false,
// items: [
// {text: 'IdGenerator', link: 'id-generator'},
// {text: 'IdConverter', link: 'id-converter'},
// {text: 'IdGeneratorProvider', link: 'provider'},
// {text: 'CosIdGenerator', link: 'cosid-generator'},
// {text: 'Segment', link: 'segment'},
// {text: 'SnowflakeId', link: 'snowflake'},
// {text: 'Sharding', link: 'sharding'},
// ],
// },
{
text: '博客',
base: '/reference/blog/',
collapsed: false,
items: [
{text: 'ShardingSphere 集成 CosId 实战', link: 'ShardingSphere-Integration-CosId'}
],
}
]
}
3 changes: 3 additions & 0 deletions documentation/docs/guide/advanced/cosid-annotation.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# CosIdAnnotationSupport

TODO
Loading

0 comments on commit 01fd5c9

Please sign in to comment.