Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
bkmashiro committed May 3, 2024
0 parents commit aa3702a
Show file tree
Hide file tree
Showing 26 changed files with 1,102 additions and 0 deletions.
91 changes: 91 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
name: Deploy Pages

# 触发条件,push到main分支或者pull request到main分支
on:
push:
branches: [main]
pull_request:
branches: [main]

# 支持手动在工作流上触发
workflow_dispatch:

# 设置时区
env:
TZ: Asia/Shanghai

# 权限设置
permissions:
# 允许读取仓库内容的权限。
contents: read
# 允许写入 GitHub Pages 的权限。
pages: write
# 允许写入 id-token 的权限。
id-token: write

# 并发控制配置
concurrency:
group: pages
cancel-in-progress: false

# 定义执行任务
jobs:
# 构建任务
build:

runs-on: ubuntu-latest

# node v20 运行
strategy:
matrix:
node-version: [20]

steps:
# 拉取代码
- name: Checkout
uses: actions/checkout@v3
with:
# 保留 Git 信息
fetch-depth: 0

# 设置使用 Node.js 版本
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}

# 使用 Bun
- uses: oven-sh/setup-bun@v1

# 安装依赖
- name: Install dependencies
run: bun install

# 构建项目
- name: Build blog project
run: |
echo ${{ github.workspace }}
bun run build
# 资源拷贝
- name: Build with Jekyll
uses: actions/jekyll-build-pages@v1
with:
source: ./docs/.vitepress/dist
destination: ./_site

# 上传 _site 的资源,用于后续部署
- name: Upload artifact
uses: actions/upload-pages-artifact@v3

# 部署任务
deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
needs: build
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
node_modules
dist
cache
.temp
.DS_Store
1 change: 1 addition & 0 deletions CNAME
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
blog.yuzhes.com
83 changes: 83 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
<h1 align="center"> VitePress @sugarat/theme </h1>

<p align="center">
简约风的 <a href="https://theme.sugarat.top" target="_blank"target="_blank">VitePress 博客主题</a> 示例运行项目。
</p>

<p align="center">
<a href="https://atqq.github.io/vitepress-blog-sugar-template/" target="_blank">GitHub Pages Demo</a>
</p>

## Usage

先安装 `pnpm`

```sh
npm i -g pnpm
```

安装依赖

```sh
pnpm install
```

开发启动

```sh
pnpm dev
```

构建

```sh
pnpm build
```

预览产物

```sh
pnpm serve
```

## Github Pages 部署

① Github Pages 开启 Git Actions 部署支持

![](https://img.cdn.sugarat.top/mdImg/sugar/8a2454c628d0e2abcc7a0451ddd7d2dc)

② 复制文件 `.github/workflows/deploy.yml` 到自己的项目相同目录下

示例项目已包含,可以直接进行下一步

③ 修改 `docs/.vitepress/config.mts` 里的构建配置

`base` 改为 `"/仓库名/"` 即可

```ts
// 省略无关代码
const base = '/vitepress-blog-sugar-template/'
export default defineConfig({
base,
})
```

④ 推送 `main` 分支即可

需要进一步修改部署和构建配置,详见`deploy.yml` 文件。

## Gitee Pages 部署

① 按照 [SPA](https://help.gitee.com/services/gitee-pages/spa-support) 要求添加 `.spa` 文件在`docs/public` 目录下

示例项目已包含,可以直接进行下一步

② 参照 `Usage` 部分构建代码

③ 推送构建后的页面资源到部署文档的分支

例如`gh-pages`

④ 参照[文档](https://help.gitee.com/services/gitee-pages/intro)选择分支和目录进行部署

*Gitee Pages 需要实名才能使用,同时需要人工审核。*
Binary file added bun.lockb
Binary file not shown.
3 changes: 3 additions & 0 deletions bunfig.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[install]
# 设置为淘宝源
registry = "https://registry.npmmirror.com"
125 changes: 125 additions & 0 deletions docs/.vitepress/blog-theme.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
// 主题独有配置
import { getThemeConfig } from '@sugarat/theme/node'

// 开启RSS支持(RSS配置)
// import type { Theme } from '@sugarat/theme'

// const baseUrl = 'https://sugarat.top'
// const RSS: Theme.RSSOptions = {
// title: '粥里有勺糖',
// baseUrl,
// copyright: 'Copyright (c) 2018-present, 粥里有勺糖',
// description: '你的指尖,拥有改变世界的力量(大前端相关技术分享)',
// language: 'zh-cn',
// image: 'https://img.cdn.sugarat.top/mdImg/MTY3NDk5NTE2NzAzMA==674995167030',
// favicon: 'https://sugarat.top/favicon.ico',
// }

// 所有配置项,详见文档: https://theme.sugarat.top/
const blogTheme = getThemeConfig({
// 开启RSS支持
// RSS,

// 搜索
// 默认开启pagefind离线的全文搜索支持(如使用其它的可以设置为false)
// 如果npx pagefind 时间过长,可以手动将其安装为项目依赖 pnpm add pagefind
// search: false,

// 页脚
footer: {
// message 字段支持配置为HTML内容,配置多条可以配置为数组
// message: '下面 的内容和图标都是可以修改的噢(当然本条内容也是可以隐藏的)',
copyright: 'baka_mashiro',
// icpRecord: {
// name: '蜀ICP备19011724号',
// link: 'https://beian.miit.gov.cn/'
// },
// securityRecord: {
// name: '公网安备xxxxx',
// link: 'https://www.beian.gov.cn/portal/index.do'
// },
version: false,
},

// 主题色修改
themeColor: 'el-blue',

// 文章默认作者
author: 'baka_mashiro',

// 友链
friend: [
{
nickname: 'Vitepress',
des: 'Vite & Vue Powered Static Site Generator',
avatar:
'https://vitepress.dev/vitepress-logo-large.webp',
url: 'https://vitepress.dev/',
},
],

// 公告
// popover: {
// title: '公告',
// body: [
// { type: 'text', content: '👇公众号👇---👇 微信 👇' },
// {
// type: 'image',
// src: 'https://img.cdn.sugarat.top/mdImg/MTYxNTAxODc2NTIxMA==615018765210~fmt.webp'
// },
// {
// type: 'text',
// content: '欢迎大家加群&私信交流'
// },
// {
// type: 'text',
// content: '文章首/文尾有群二维码',
// style: 'padding-top:0'
// },
// {
// type: 'button',
// content: '作者博客',
// link: 'https://sugarat.top'
// },
// {
// type: 'button',
// content: '加群交流',
// props: {
// type: 'success'
// },
// link: 'https://theme.sugarat.top/group.html',
// }
// ],
// duration: 0
// },
/*
<script src="https://giscus.app/client.js"
data-repo="bkmashiro/bkmashiro.github.io"
data-repo-id="MDEwOlJlcG9zaXRvcnkzMTY3MDI3MzU="
data-category="Announcements"
data-category-id="DIC_kwDOEuCAD84CfHPV"
data-mapping="pathname"
data-strict="0"
data-reactions-enabled="1"
data-emit-metadata="0"
data-input-position="bottom"
data-theme="preferred_color_scheme"
data-lang="zh-CN"
crossorigin="anonymous"
async>
</script>
*/
comment: {
type: 'giscus',
options: {
repo: 'bkmashiro/bkmashiro.github.io',
repoId: 'MDEwOlJlcG9zaXRvcnkzMTY3MDI3MzU=',
category: 'Announcements',
categoryId: 'DIC_kwDOEuCAD84CfHPV',
inputPosition: 'top'
},
mobileMinify: true
}
})

export { blogTheme }
62 changes: 62 additions & 0 deletions docs/.vitepress/config.mts
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
import { defineConfig } from 'vitepress'

// 导入主题的配置
import { blogTheme } from './blog-theme'

// 如果使用 GitHub/Gitee Pages 等公共平台部署
// 通常需要修改 base 路径,通常为“/仓库名/”
// @ts-ignore
const base = process.env.GITHUB_ACTIONS === 'true'
? '/bkmashiro.github.io/'
: '/'

// Vitepress 默认配置
// 详见文档:https://vitepress.dev/reference/site-config
const cfg = defineConfig({
// 继承博客主题(@sugarat/theme)
extends: blogTheme,
// base,
lang: 'zh-cn',
title: 'baka_mashiro\'s cave',
description: 'baka_mashiro\'s cave',
lastUpdated: true,
// 详见:https://vitepress.dev/zh/reference/site-config#head
head: [
// 配置网站的图标(显示在浏览器的 tab 上)
// ['link', { rel: 'icon', href: `${base}favicon.ico` }], // 修改了 base 这里也需要同步修改
['link', { rel: 'icon', href: '/favicon.ico' }]
],
themeConfig: {
// 展示 2,3 级标题在目录中
outline: {
level: [2, 3],
label: '目录'
},
// 默认文案修改
returnToTopLabel: '回到顶部',
sidebarMenuLabel: '相关文章',
lastUpdatedText: '上次更新于',

// 设置logo
logo: '/logo.png',
// editLink: {
// pattern:
// 'https://github.com/ATQQ/sugar-blog/tree/master/packages/blogpress/:path',
// text: '去 GitHub 上编辑内容'
// },
nav: [
{ text: '首页', link: '/' },
// { text: '关于作者', link: 'https://sugarat.top/aboutme.html' }
],
socialLinks: [
{
icon: 'github',
link: 'https://github.com/bkmashiro'
}
]
},
cleanUrls: true,

})

export default cfg
Binary file added docs/.vitepress/theme/assets/bg.webp
Binary file not shown.
9 changes: 9 additions & 0 deletions docs/.vitepress/theme/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import BlogTheme from '@sugarat/theme'

// 自定义样式重载
// import './style.scss'

// 自定义主题色
// import './user-theme.css'

export default BlogTheme
Loading

0 comments on commit aa3702a

Please sign in to comment.