修复:启用评论组件
24
.github/workflows/deploy-pages.yml
vendored
@@ -17,24 +17,28 @@ jobs:
|
|||||||
# 任务1: 部署 GitHub Pages
|
# 任务1: 部署 GitHub Pages
|
||||||
deploy-github-pages:
|
deploy-github-pages:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
# 1、检出源码
|
# 1、检出源码
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v3
|
||||||
|
# 2、安装 Node 环境
|
||||||
# 2、安装模块并打包
|
- name: Setup Node
|
||||||
- name: Install and Build
|
uses: actions/setup-node@v3
|
||||||
run: |
|
with:
|
||||||
yarn install
|
node-version: 16
|
||||||
yarn build
|
cache: yarn
|
||||||
|
# 3、安装依赖
|
||||||
# 3、部署 GitHub Pages
|
- name: Install dependencies
|
||||||
|
run: yarn install --frozen-lockfile
|
||||||
|
# 4、打包
|
||||||
|
- name: Build
|
||||||
|
run: yarn build
|
||||||
|
# 5、部署 GitHub Pages
|
||||||
- name: Deploy GitHub Pages
|
- name: Deploy GitHub Pages
|
||||||
uses: JamesIves/github-pages-deploy-action@v4
|
uses: JamesIves/github-pages-deploy-action@v4
|
||||||
with:
|
with:
|
||||||
BRANCH: pages
|
BRANCH: pages
|
||||||
FOLDER: repos/.vitepress/dist
|
FOLDER: docs/.vitepress/dist
|
||||||
|
|
||||||
# 任务2: 部署 Gitee Pages
|
# 任务2: 部署 Gitee Pages
|
||||||
deploy-gitee-pages:
|
deploy-gitee-pages:
|
||||||
|
1
.gitignore
vendored
@@ -19,7 +19,6 @@ coverage/
|
|||||||
.vscode
|
.vscode
|
||||||
|
|
||||||
# Temp files
|
# Temp files
|
||||||
yarn.lock
|
|
||||||
package-lock.json
|
package-lock.json
|
||||||
.vite_opt_cache
|
.vite_opt_cache
|
||||||
|
|
||||||
|
23
README.md
@@ -41,35 +41,35 @@ yarn build
|
|||||||
- [x] 主页美化:参照 vite 文档主页进行美化
|
- [x] 主页美化:参照 vite 文档主页进行美化
|
||||||
- [x] 自定义页脚:支持ICP备案号、公安备案号、版权信息配置(符合大陆网站审核要求)
|
- [x] 自定义页脚:支持ICP备案号、公安备案号、版权信息配置(符合大陆网站审核要求)
|
||||||
- [x] 文章元数据信息显示:文章标题下显示作者、发布时间、所属分类、标签列表等信息
|
- [x] 文章元数据信息显示:文章标题下显示作者、发布时间、所属分类、标签列表等信息
|
||||||
- [x] 《我的标签》:模仿语雀标签页风格,https://www.yuque.com/r/语雀用户名/tags?tag=,另有标签云展示
|
- [x] 《我的标签》:模仿语雀标签页风格,另有标签云展示。语雀标签页地址:https://www.yuque.com/r/语雀用户名/tags?tag=
|
||||||
- [x] 《我的归档》:自定义时间轴,展示历史文章数据。年份前可展示生肖,可按分类、标签筛选
|
- [x] 《我的归档》:自定义时间轴,展示历史文章数据。年份前可展示生肖,可按分类、标签筛选
|
||||||
- [x] 更多细节优化:敬请发现
|
- [x] 更多细节优化:敬请发现
|
||||||
- [ ] 文章评论:Gitalk
|
- [x] 文章评论:目前仅支持Gitalk
|
||||||
|
|
||||||
## 部分页面截图
|
## 部分页面截图
|
||||||
|
|
||||||
### 主页美化
|
### 主页美化
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
### 文章元数据信息
|
### 文章元数据信息
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
### 我的标签
|
### 我的标签
|
||||||
|
|
||||||

|

|
||||||

|

|
||||||
|
|
||||||
### 我的归档
|
### 我的归档
|
||||||
|
|
||||||

|

|
||||||

|

|
||||||
|
|
||||||
### 文章评论(未完待续)
|
### 文章评论
|
||||||
|
|
||||||

|

|
||||||

|

|
||||||
|
|
||||||
## 致谢
|
## 致谢
|
||||||
|
|
||||||
@@ -80,6 +80,7 @@ yarn build
|
|||||||
- [brc-dd/vitepress-with-arco](https://github.com/brc-dd/vitepress-with-arco)
|
- [brc-dd/vitepress-with-arco](https://github.com/brc-dd/vitepress-with-arco)
|
||||||
- [clark-cui/vitepress-blog-zaun](https://github.com/clark-cui/vitepress-blog-zaun) (参考文章标签的数据处理方案)
|
- [clark-cui/vitepress-blog-zaun](https://github.com/clark-cui/vitepress-blog-zaun) (参考文章标签的数据处理方案)
|
||||||
- [dingqianwen/my-blog](https://github.com/dingqianwen/my-blog) (参考 Gitalk 配置暗黑主题)
|
- [dingqianwen/my-blog](https://github.com/dingqianwen/my-blog) (参考 Gitalk 配置暗黑主题)
|
||||||
|
- [Dedicatus546/Dedicatus546.github.io](https://github.com/Dedicatus546/Dedicatus546.github.io) (参考 Gitalk 跨域调用 API 失效的解决方案)
|
||||||
- [xiaoxian521/pure-admin-utils-docs](https://github.com/xiaoxian521/pure-admin-utils-docs) (参考词云组件的使用)
|
- [xiaoxian521/pure-admin-utils-docs](https://github.com/xiaoxian521/pure-admin-utils-docs) (参考词云组件的使用)
|
||||||
- [arco-design/arco-design-vue](https://github.com/arco-design/arco-design-vue) (使用部分组件及图标)
|
- [arco-design/arco-design-vue](https://github.com/arco-design/arco-design-vue) (使用部分组件及图标)
|
||||||
- [antvis/G2plot](https://github.com/antvis/G2plot) (使用部分图表)
|
- [antvis/G2plot](https://github.com/antvis/G2plot) (使用部分图表)
|
||||||
|
@@ -3,10 +3,10 @@ import matter from 'gray-matter'
|
|||||||
import fs from 'node:fs/promises'
|
import fs from 'node:fs/promises'
|
||||||
|
|
||||||
const articleData = await Promise.all(
|
const articleData = await Promise.all(
|
||||||
glob.sync('./repos/**/*.md', {
|
glob.sync('./docs/**/*.md', {
|
||||||
onlyFiles: true,
|
onlyFiles: true,
|
||||||
objectMode: true,
|
objectMode: true,
|
||||||
ignore: ['./repos/**/index.md', './repos/**/tags.md', './repos/**/archives.md', './repos/**/me.md'], // without !
|
ignore: ['./docs/**/index.md', './docs/**/tags.md', './docs/**/archives.md', './docs/**/me.md'], // without !
|
||||||
}).map(async (article) => {
|
}).map(async (article) => {
|
||||||
const file = matter.read(`${article.path}`)
|
const file = matter.read(`${article.path}`)
|
||||||
const { data, path } = file
|
const { data, path } = file
|
||||||
|
@@ -5,7 +5,6 @@ export const markdown: MarkdownOptions = {
|
|||||||
lineNumbers: true, // 启用行号
|
lineNumbers: true, // 启用行号
|
||||||
|
|
||||||
// 在所有文档的<h1>标签后添加<ArticleMetadata/>组件
|
// 在所有文档的<h1>标签后添加<ArticleMetadata/>组件
|
||||||
// 感谢: https://github.com/vuejs/vitepress/issues/1050
|
|
||||||
config: (md) => {
|
config: (md) => {
|
||||||
md.renderer.rules.heading_close = (tokens, idx, options, env, slf) => {
|
md.renderer.rules.heading_close = (tokens, idx, options, env, slf) => {
|
||||||
let htmlResult = slf.renderToken(tokens, idx, options, env, slf)
|
let htmlResult = slf.renderToken(tokens, idx, options, env, slf)
|
@@ -23,25 +23,25 @@ function getItemsByDate (path: string) {
|
|||||||
let items: DefaultTheme.SidebarItem[] = []
|
let items: DefaultTheme.SidebarItem[] = []
|
||||||
|
|
||||||
// 1.获取所有年份目录
|
// 1.获取所有年份目录
|
||||||
sync(`repos/${path}/*`, {
|
sync(`docs/${path}/*`, {
|
||||||
onlyDirectories: true,
|
onlyDirectories: true,
|
||||||
objectMode: true
|
objectMode: true
|
||||||
}).forEach(({ name }) => {
|
}).forEach(({ name }) => {
|
||||||
let year = name
|
let year = name
|
||||||
// 2.获取所有月份目录
|
// 2.获取所有月份目录
|
||||||
sync(`repos/${path}/${year}/*`, {
|
sync(`docs/${path}/${year}/*`, {
|
||||||
onlyDirectories: true,
|
onlyDirectories: true,
|
||||||
objectMode: true
|
objectMode: true
|
||||||
}).forEach(({ name }) => {
|
}).forEach(({ name }) => {
|
||||||
let month = name
|
let month = name
|
||||||
// 3.获取所有日期目录
|
// 3.获取所有日期目录
|
||||||
sync(`repos/${path}/${year}/${month}/*`, {
|
sync(`docs/${path}/${year}/${month}/*`, {
|
||||||
onlyDirectories: true,
|
onlyDirectories: true,
|
||||||
objectMode: true
|
objectMode: true
|
||||||
}).forEach(({ name }) => {
|
}).forEach(({ name }) => {
|
||||||
let day = name
|
let day = name
|
||||||
// 4.获取日期目录下的所有文章
|
// 4.获取日期目录下的所有文章
|
||||||
sync(`repos/${path}/${year}/${month}/${day}/*`, {
|
sync(`docs/${path}/${year}/${month}/${day}/*`, {
|
||||||
onlyFiles: true,
|
onlyFiles: true,
|
||||||
objectMode: true
|
objectMode: true
|
||||||
}).forEach(({ name }) => {
|
}).forEach(({ name }) => {
|
||||||
@@ -93,13 +93,13 @@ function getItems (path: string) {
|
|||||||
let items: DefaultTheme.SidebarItem[] = []
|
let items: DefaultTheme.SidebarItem[] = []
|
||||||
|
|
||||||
// 1.获取所有分组目录
|
// 1.获取所有分组目录
|
||||||
sync(`repos/${path}/*`, {
|
sync(`docs/${path}/*`, {
|
||||||
onlyDirectories: true,
|
onlyDirectories: true,
|
||||||
objectMode: true
|
objectMode: true
|
||||||
}).forEach(({ name }) => {
|
}).forEach(({ name }) => {
|
||||||
let groupName = name
|
let groupName = name
|
||||||
// 2.获取分组下的所有文章
|
// 2.获取分组下的所有文章
|
||||||
sync(`repos/${path}/${groupName}/*`, {
|
sync(`docs/${path}/${groupName}/*`, {
|
||||||
onlyFiles: true,
|
onlyFiles: true,
|
||||||
objectMode: true
|
objectMode: true
|
||||||
}).forEach(({ name }) => {
|
}).forEach(({ name }) => {
|
@@ -48,16 +48,15 @@ export const themeConfig: DefaultTheme.Config = {
|
|||||||
type: 'gitalk',
|
type: 'gitalk',
|
||||||
options: {
|
options: {
|
||||||
clientID: '1de126ce1fbdbe049709',
|
clientID: '1de126ce1fbdbe049709',
|
||||||
clientSecret: '97e359a006ba7b0d8e9d9bf38b83de59eb69ecba',
|
clientSecret: '035fe49874a43e5cefc28a99b7e40b1925319c62',
|
||||||
repo: 'charles7c.github.io-comments',
|
repo: 'charles7c.github.io-comments',
|
||||||
owner: 'Charles7c',
|
owner: 'Charles7c',
|
||||||
admin: ['Charles7c'],
|
admin: ['Charles7c'],
|
||||||
language: 'zh-CN',
|
language: 'zh-CN',
|
||||||
distractionFreeMode: false,
|
distractionFreeMode: false,
|
||||||
// 默认: https://cors-anywhere.azm.workers.dev/https://github.com/login/oauth/access_token
|
// 默认: https://cors-anywhere.azm.workers.dev/https://github.com/login/oauth/access_token
|
||||||
// 感谢: https://prohibitorum.top/2022/07/26/%E8%A7%A3%E5%86%B3-Gitalk-%E6%97%A0%E6%B3%95%E8%8E%B7%E5%8F%96-Github-Token-%E9%97%AE%E9%A2%98/
|
|
||||||
proxy: 'https://cors-server-ecru.vercel.app/github_access_token'
|
proxy: 'https://cors-server-ecru.vercel.app/github_access_token'
|
||||||
},
|
},
|
||||||
hideComments: true // 全局隐藏评论,默认 false
|
showComment: true // 是否显示评论
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -1,7 +1,7 @@
|
|||||||
<template>
|
<template>
|
||||||
<Layout>
|
<Layout>
|
||||||
<template #doc-after>
|
<template #doc-after>
|
||||||
<Comment v-if="!(theme.commentConfig?.hideComments ?? false)" />
|
<Comment v-if="(theme.commentConfig?.showComment ?? true) && (frontmatter?.showComment ?? true)" :commentConfig="theme.commentConfig" :key="md5(page.relativePath)" />
|
||||||
</template>
|
</template>
|
||||||
<template #layout-bottom>
|
<template #layout-bottom>
|
||||||
<Footer v-if="(theme.footerConfig?.showFooter ?? true) && (frontmatter?.showFooter ?? true)" />
|
<Footer v-if="(theme.footerConfig?.showFooter ?? true) && (frontmatter?.showFooter ?? true)" />
|
||||||
@@ -12,11 +12,12 @@
|
|||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import DefaultTheme from 'vitepress/theme'
|
import DefaultTheme from 'vitepress/theme'
|
||||||
import { useData } from 'vitepress'
|
import { useData } from 'vitepress'
|
||||||
|
import md5 from 'blueimp-md5'
|
||||||
import Comment from './components/Comment.vue'
|
import Comment from './components/Comment.vue'
|
||||||
import Footer from './components/Footer.vue'
|
import Footer from './components/Footer.vue'
|
||||||
|
|
||||||
const { Layout } = DefaultTheme
|
const { Layout } = DefaultTheme
|
||||||
const { theme, frontmatter } = useData()
|
const { page, theme, frontmatter } = useData()
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
49
docs/.vitepress/theme/components/Comment.vue
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
<template>
|
||||||
|
<div id="comment-container"></div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script lang="ts" setup>
|
||||||
|
import { reactive, toRefs, onMounted } from 'vue'
|
||||||
|
import { useData } from 'vitepress'
|
||||||
|
import md5 from 'blueimp-md5'
|
||||||
|
import Gitalk from 'gitalk'
|
||||||
|
import '../styles/gitalk.css'
|
||||||
|
|
||||||
|
// 定义属性
|
||||||
|
const props = defineProps({
|
||||||
|
commentConfig: Object
|
||||||
|
})
|
||||||
|
|
||||||
|
const data = reactive({
|
||||||
|
type: props.commentConfig?.type ?? 'gitalk',
|
||||||
|
options: props.commentConfig?.options ?? {}
|
||||||
|
})
|
||||||
|
const { type, options } = toRefs(data)
|
||||||
|
|
||||||
|
// 初始化评论组件配置
|
||||||
|
const { page } = useData()
|
||||||
|
let gitalk
|
||||||
|
if (type.value && type.value == 'gitalk') {
|
||||||
|
gitalk = new Gitalk({
|
||||||
|
clientID: options.value.clientID,
|
||||||
|
clientSecret: options.value.clientSecret,
|
||||||
|
repo: options.value.repo,
|
||||||
|
owner: options.value.owner,
|
||||||
|
admin: options.value.admin,
|
||||||
|
id: md5(page.value.relativePath),
|
||||||
|
language: options.value.language,
|
||||||
|
distractionFreeMode: options.value.distractionFreeMode,
|
||||||
|
proxy: options.value.pagerDirection
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 渲染评论组件
|
||||||
|
onMounted(() => {
|
||||||
|
if (type.value && type.value == 'gitalk') {
|
||||||
|
gitalk.render('comment-container')
|
||||||
|
}
|
||||||
|
})
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
</style>
|
@@ -3,6 +3,7 @@ title: 关于我
|
|||||||
aside: false
|
aside: false
|
||||||
editLink: false
|
editLink: false
|
||||||
lastUpdated: false
|
lastUpdated: false
|
||||||
|
showComment: false
|
||||||
---
|
---
|
||||||
|
|
||||||
<img width=100% src="../public/img/svg/about-me-header.svg" alt="头部图" />
|
<img width=100% src="../public/img/svg/about-me-header.svg" alt="头部图" />
|
@@ -3,6 +3,7 @@ title: 我的归档
|
|||||||
aside: false
|
aside: false
|
||||||
editLink: false
|
editLink: false
|
||||||
lastUpdated: false
|
lastUpdated: false
|
||||||
|
showComment: false
|
||||||
---
|
---
|
||||||
|
|
||||||
<Archive />
|
<Archive />
|
@@ -2,6 +2,7 @@
|
|||||||
editLink: false
|
editLink: false
|
||||||
lastUpdated: false
|
lastUpdated: false
|
||||||
aside: false
|
aside: false
|
||||||
|
showComment: false
|
||||||
---
|
---
|
||||||
|
|
||||||
# "杂碎"逆袭史
|
# "杂碎"逆袭史
|
@@ -2,6 +2,7 @@
|
|||||||
editLink: false
|
editLink: false
|
||||||
lastUpdated: false
|
lastUpdated: false
|
||||||
aside: false
|
aside: false
|
||||||
|
showComment: false
|
||||||
---
|
---
|
||||||
|
|
||||||
# Bug万象集
|
# Bug万象集
|
@@ -2,6 +2,7 @@
|
|||||||
editLink: false
|
editLink: false
|
||||||
lastUpdated: false
|
lastUpdated: false
|
||||||
aside: false
|
aside: false
|
||||||
|
showComment: false
|
||||||
---
|
---
|
||||||
|
|
||||||
# 方案春秋志
|
# 方案春秋志
|
Before Width: | Height: | Size: 66 KiB After Width: | Height: | Size: 66 KiB |
Before Width: | Height: | Size: 113 KiB After Width: | Height: | Size: 113 KiB |
Before Width: | Height: | Size: 20 KiB After Width: | Height: | Size: 20 KiB |
Before Width: | Height: | Size: 23 KiB After Width: | Height: | Size: 23 KiB |
Before Width: | Height: | Size: 99 KiB After Width: | Height: | Size: 99 KiB |
Before Width: | Height: | Size: 8.8 KiB After Width: | Height: | Size: 8.8 KiB |
Before Width: | Height: | Size: 18 KiB After Width: | Height: | Size: 18 KiB |
Before Width: | Height: | Size: 44 KiB After Width: | Height: | Size: 44 KiB |
Before Width: | Height: | Size: 23 KiB After Width: | Height: | Size: 23 KiB |
Before Width: | Height: | Size: 16 KiB After Width: | Height: | Size: 16 KiB |
Before Width: | Height: | Size: 39 KiB After Width: | Height: | Size: 39 KiB |
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 11 KiB |
Before Width: | Height: | Size: 40 KiB After Width: | Height: | Size: 40 KiB |
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 11 KiB |
Before Width: | Height: | Size: 19 KiB After Width: | Height: | Size: 19 KiB |
Before Width: | Height: | Size: 49 KiB After Width: | Height: | Size: 49 KiB |
Before Width: | Height: | Size: 42 KiB After Width: | Height: | Size: 42 KiB |
Before Width: | Height: | Size: 4.4 KiB After Width: | Height: | Size: 4.4 KiB |
Before Width: | Height: | Size: 47 KiB After Width: | Height: | Size: 47 KiB |
Before Width: | Height: | Size: 50 KiB After Width: | Height: | Size: 50 KiB |
Before Width: | Height: | Size: 69 KiB After Width: | Height: | Size: 69 KiB |
Before Width: | Height: | Size: 99 KiB After Width: | Height: | Size: 99 KiB |
Before Width: | Height: | Size: 42 KiB After Width: | Height: | Size: 42 KiB |
Before Width: | Height: | Size: 32 KiB After Width: | Height: | Size: 32 KiB |
Before Width: | Height: | Size: 89 KiB After Width: | Height: | Size: 89 KiB |
Before Width: | Height: | Size: 50 KiB After Width: | Height: | Size: 50 KiB |
Before Width: | Height: | Size: 37 KiB After Width: | Height: | Size: 37 KiB |
Before Width: | Height: | Size: 20 KiB After Width: | Height: | Size: 20 KiB |
Before Width: | Height: | Size: 31 KiB After Width: | Height: | Size: 31 KiB |
Before Width: | Height: | Size: 9.1 KiB After Width: | Height: | Size: 9.1 KiB |
Before Width: | Height: | Size: 23 KiB After Width: | Height: | Size: 23 KiB |
Before Width: | Height: | Size: 63 KiB After Width: | Height: | Size: 63 KiB |
Before Width: | Height: | Size: 21 KiB After Width: | Height: | Size: 21 KiB |
Before Width: | Height: | Size: 26 KiB After Width: | Height: | Size: 26 KiB |
Before Width: | Height: | Size: 24 KiB After Width: | Height: | Size: 24 KiB |
Before Width: | Height: | Size: 44 KiB After Width: | Height: | Size: 44 KiB |
Before Width: | Height: | Size: 217 KiB After Width: | Height: | Size: 217 KiB |
Before Width: | Height: | Size: 88 KiB After Width: | Height: | Size: 88 KiB |
Before Width: | Height: | Size: 83 KiB After Width: | Height: | Size: 83 KiB |
Before Width: | Height: | Size: 29 KiB After Width: | Height: | Size: 29 KiB |
Before Width: | Height: | Size: 28 KiB After Width: | Height: | Size: 28 KiB |
Before Width: | Height: | Size: 164 KiB After Width: | Height: | Size: 164 KiB |
Before Width: | Height: | Size: 79 KiB After Width: | Height: | Size: 79 KiB |
Before Width: | Height: | Size: 93 KiB After Width: | Height: | Size: 93 KiB |
Before Width: | Height: | Size: 82 KiB After Width: | Height: | Size: 82 KiB |
Before Width: | Height: | Size: 4.9 KiB After Width: | Height: | Size: 4.9 KiB |
Before Width: | Height: | Size: 20 KiB After Width: | Height: | Size: 20 KiB |
Before Width: | Height: | Size: 87 KiB After Width: | Height: | Size: 87 KiB |