Skip to content

Commit

Permalink
docs: Replacing the Blog framework from hexo to vitepress
Browse files Browse the repository at this point in the history
  • Loading branch information
sujit-168 committed Nov 11, 2023
0 parents commit 139a468
Show file tree
Hide file tree
Showing 96 changed files with 10,780 additions and 0 deletions.
90 changes: 90 additions & 0 deletions .github/workflows/deploy-pages.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
name: Deploy Pages

on:
# 推送时执行
push:
branches: [main, master]
# pr 时执行
pull_request:
branches: [main, master]
# 定时执行,字段含义:分钟 小时 日 月 星期
# 注意:
# 1.采用的是 UTC 时间
# 即,你配置的 0 0 * * *(UTC)00:00 实际上是(GMT+0800)08:00
# 只有你配置为 00 16 * * *(UTC)16:00 实际上才是 GMT+0800)00:00
# 2.官方声明:schedule 事件在 GitHub Actions 工作流运行期间负载过高时可能会延迟。高负载时间包括每小时的开始时间。为了降低延迟的可能性,建议将您的工作流程安排在不同时间运行。
# 例如:笔者之前设定的定时规则为 0 0 * * *(UTC),实际(GMT+0800)执行时间通常在 9:10 ~ 10:00,甚至会出现在 10:00 之后执行的情况
# 3.建议不只是定时执行的时候注意时间,自己 push 时也注意时间,早点休息
# 例如:笔者多次亲身经历,凌晨时间 pages build and deployment 任务大概能持续 8 分钟的 Current status: deployment_queued 状态,
# 即使能进入 Current status: deployment_in_progress 和 Current status: syncing_files 状态,如果文件多点,没一会儿就 Error: Timeout reached, aborting! 超时失败了
schedule:
- cron: 30 17 * * *
# 可手动执行
workflow_dispatch:

jobs:
# 任务1: 部署 GitHub Pages
deploy-github-pages:
runs-on: ubuntu-latest
steps:
# 1、检出源码
- name: Checkout
uses: actions/checkout@v3
with:
# 默认只拉取分支最近一次的 commit,可能会导致一些文章的 GitInfo 变量无法获取,设为 0 代表拉取所有分支所有提交
fetch-depth: 0
# 2、配置 Git
# 主要是 quotePath,默认情况下,文件名包含中文时,git 会使用引号把文件名括起来,这会导致 action 中无法读取 :GitInfo 变量
- name: Git Configuration
run: |
git config --global core.quotePath false
git config --global core.autocrlf false
git config --global core.safecrlf true
git config --global core.ignorecase false
# 3、安装 PNPM
- name: Setup PNPM
uses: pnpm/action-setup@v2
with:
version: latest
# 4、安装 Node 环境
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: 18
registry-url: https://registry.npmjs.org
cache: pnpm
# 5、安装依赖
- name: Install dependencies
run: pnpm i --frozen-lockfile
# 6、打包
- name: Build
run: pnpm build
# 7、部署 GitHub Pages
- name: Deploy GitHub Pages
uses: JamesIves/github-pages-deploy-action@v4
with:
BRANCH: pages
FOLDER: docs/.vitepress/dist

# 任务2: 部署 Gitee Pages
# deploy-gitee-pages:
# runs-on: ubuntu-latest
# steps:
# # 1、同步内容到 Gitee
# - name: Sync to Gitee
# uses: wearerequired/git-mirror-action@master #使用 action 库
# env:
# SSH_PRIVATE_KEY: ${{ secrets.GITEE_RSA_PRIVATE_KEY }} #Gitee 私钥
# with:
# source-repo: [email protected]:Charles7c/charles7c.github.io.git #GitHub 源仓库地址
# destination-repo: [email protected]:Charles7c/charles7c.git #Gitee 目标仓库地址
# # 2、部署 Gitee Pages
# - name: Deploy Gitee Pages
# # 手动执行时只同步内容,不进行部署
# if: github.event_name != 'workflow_dispatch'
# uses: yanglbme/gitee-pages-action@main
# with:
# gitee-username: ${{ secrets.GITEE_USERNAME }} #Gitee 用户名
# gitee-password: ${{ secrets.GITEE_PASSWORD }} #Gitee 密码
# gitee-repo: Charles7c/charles7c #Gitee 仓库
# branch: pages #要部署的分支,默认是 master,若是其他分支,则需要指定(指定的分支必须存在)
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.autocorrectignore
.history
.vscode
node_modules
cache
dist
47 changes: 47 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<h1>
<p align="center">甦傑的个人博客</p>
</h1>

博客功能单元相对较少,比较注重简约,内容
主要用于记录我的学习经验及所遇问题的解决过程

## 内容
- 机器人技术
- 机器学习与深度学习
- ROS与SLAM技术
- 算法与Leetcode刷题笔记
- C/C++,Python,Linux
- 顶刊顶会Paper笔记

暂时就先定下这些内容,希望对自我提升有所帮助

## 更新日志

### 2021-02-24
1.~~添加book篇~~

2.添加linkedin分享

3.添加了置顶文章,欢迎各位

### 2021-03-01
1.添加research篇

2.~~添加Coverletter个人简历篇~~

3.~~借助briefcake实现博客订阅功能~~

### 2022-02-28
1.添加SLAM篇


## 特别鸣谢
- [vitepress](https://vitepress.dev/)
- [vitejs/vite](https://vitejs.dev/)
- [Charles7c](https://github.com/Charles7c/charles7c.github.io.git)
- [冰冻大西瓜](https://bddxg.top/)

## License
Copyright © 2019
Admin:JIT_SU
E-mail: [email protected]
25 changes: 25 additions & 0 deletions article.data.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import fs from 'node:fs';
import path from 'node:path';
import parseFrontmatter from 'gray-matter';

const excludedFiles = ['index.md', 'tags.md', 'archives.md', 'me.md'];

export default {
watch: ['./docs/**/*.md'],
load(watchedFiles) {
// 排除不必要文件
const articleFiles = watchedFiles.filter(file => {
const filename = path.basename(file);
return !excludedFiles.includes(filename);
});
// 解析文章 Frontmatter
return articleFiles.map(articleFile => {
const articleContent = fs.readFileSync(articleFile, 'utf-8');
const { data } = parseFrontmatter(articleContent);
return {
...data,
path: articleFile.substring(articleFile.lastIndexOf('/docs/') + 6).replace(/\.md$/, ''),
}
})
}
}
118 changes: 118 additions & 0 deletions docs/.vitepress/config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
import { defineConfig } from 'vitepress';
import { withMermaid } from 'vitepress-plugin-mermaid';
import { metaData } from './config/constants';
import { head } from './config/head';
import { markdown } from './config/markdown';
import { themeConfig } from './config/theme';

export default withMermaid(
defineConfig({
lang: metaData.lang,
title: metaData.title,
description: metaData.description,

cleanUrls: true,
lastUpdated: true, // 显示最后更新时间

head, // <head>内标签配置
markdown: markdown, // Markdown配置
vue: {
template: {
compilerOptions: {
isCustomElement: (tag) => customElements.includes(tag),
},
},
},
themeConfig, // 主题配置
}),
);

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',
];
23 changes: 23 additions & 0 deletions docs/.vitepress/config/constants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
const site = 'https://blog.sujie-168.top';

export const metaData = {
lang: 'zh-CN',
locale: 'zh_CN',
title: 'sujie-168',
description: '我的个人技术博客',
site,
image: `${site}/logo.jpg`,
base: 'docs/',
// 多语言
locales: {
root: {
label: '简体中文',
lang: 'Zh_CN',
},
en: {
label: 'English',
lang: 'en',
link: '/en/',
},
},
};
65 changes: 65 additions & 0 deletions docs/.vitepress/config/head.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
import type { HeadConfig } from 'vitepress';
import { metaData } from './constants';

export const head: HeadConfig[] = [
['link', { rel: 'icon', href: '/favicon.ico' }],
['meta', { name: 'author', content: 'sujie' }],
['meta', { name: 'keywords', content: '甦傑的个人技术博客' }],

// get picture no referrer, such as aliyun-oss, the follower code change " <meta name="referrer" content="no-referrer" /> " in .html file
['meta', { name:'referrer', content:'no-referrer'}],

// Microsoft bing record verify
['meta', { name:'msvalidate.01', content:'64573C71C3541C3C362B887BACDF3A93' }],

['meta', { name: 'HandheldFriendly', content: 'True' }],
['meta', { name: 'MobileOptimized', content: '320' }],
['meta', { name: 'theme-color', content: '#3c8772' }],

['meta', { property: 'og:type', content: 'website' }],
['meta', { property: 'og:locale', content: metaData.locale }],
['meta', { property: 'og:title', content: metaData.title }],
['meta', { property: 'og:description', content: metaData.description }],
['meta', { property: 'og:site', content: metaData.site }],
['meta', { property: 'og:site_name', content: metaData.title }],
['meta', { property: 'og:image', content: metaData.image }],

// 百度统计代码:https://tongji.baidu.com
['script', {}, `var _hmt = _hmt || [];
(function() {
var hm = document.createElement("script");
hm.src = "https://hm.baidu.com/hm.js?53af4b1a12fbe40810ca7ad39f8db9c7";
var s = document.getElementsByTagName("script")[0];
s.parentNode.insertBefore(hm, s);
})();`],
// 页面访问量统计
['script', {}, `
window.addEventListener('load', function() {
let oldHref = document.location.href, bodyDOM = document.querySelector('body');
const observer = new MutationObserver(function(mutations) {
if (oldHref != document.location.href) {
oldHref = document.location.href;
getPv()
window.requestAnimationFrame(function() {
let tmp = document.querySelector('body');
if(tmp != bodyDOM) {
bodyDOM = tmp;
observer.observe(bodyDOM, config);
}
})
}
});
const config = {
childList: true,
subtree: true
};
observer.observe(bodyDOM, config);
getPv()
}, true);
function getPv() {
xhr = new XMLHttpRequest();
xhr.open('GET', 'https://api.sujit-168.top/blog/pv?pageUrl=' + location.href);
xhr.send();
}`]
];
Loading

0 comments on commit 139a468

Please sign in to comment.