Skip to content

Commit c979dcc

Browse files
committed
初始化博客框架
1 parent 1e4b0f4 commit c979dcc

47 files changed

Lines changed: 3890 additions & 0 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.eslintignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
/node_modules
2+
/.gitignore
3+
/.eslintignore

.github/workflows/deploy.yml

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
name: Deploy
2+
on:
3+
push:
4+
branches:
5+
- main
6+
7+
jobs:
8+
deploy:
9+
name: deploy
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v3
13+
14+
- name: Secrets
15+
env:
16+
SECRET_FILE: blog/.vitepress/secret.ts
17+
run: |
18+
echo "export const GITALK_ID = '${{ secrets.GITALK_ID }}';" >> ${SECRET_FILE}
19+
echo "export const GITALK_SECRET = '${{ secrets.GITALK_SECRET }}';" >> ${SECRET_FILE}
20+
echo "export const ALGOLIA_ID = '${{ secrets.ALGOLIA_ID }}';" >> ${SECRET_FILE}
21+
echo "export const ALGOLIA_SECRET = '${{ secrets.ALGOLIA_SECRET }}';" >> ${SECRET_FILE}
22+
23+
- uses: actions/setup-node@v3
24+
with:
25+
node-version: '18.13.0'
26+
27+
- uses: pnpm/action-setup@v2
28+
name: Install pnpm
29+
id: pnpm-install
30+
with:
31+
version: 7.25.0
32+
run_install: false
33+
34+
- name: Get pnpm store directory
35+
id: pnpm-cache
36+
shell: bash
37+
run: |
38+
echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT
39+
40+
- uses: actions/cache@v3
41+
name: Setup pnpm cache
42+
with:
43+
path: ${{ steps.pnpm-cache.outputs.STORE_PATH }}
44+
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
45+
restore-keys: |
46+
${{ runner.os }}-pnpm-store-
47+
48+
- name: Install dependencies
49+
run: pnpm install
50+
51+
- name: Build the project
52+
run: pnpm build
53+
54+
- name: Deploy
55+
uses: cpina/github-action-push-to-another-repository@main
56+
env:
57+
API_TOKEN_GITHUB: ${{ secrets.API_TOKEN_GITHUB }}
58+
with:
59+
source-directory: "blog/.vitepress/dist"
60+
destination-github-username: "makevyc"
61+
destination-repository-name: "makevyc.github.io"
62+
user-email: ${{ secrets.MAIL }}
63+
target-branch: master

.gitignore

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
node_modules/
2+
blog/.vitepress/dist
3+
blog/.vitepress/.temp
4+
blog/.vitepress/cache
5+
blog/.vitepress/secret.ts
6+
*.pdf
7+
backup/
8+
note.txt
9+
*.log
10+
.npmrc
11+
12+
### VisualStudioCode ###
13+
.vscode/*
14+
!.vscode/settings.json
15+
!.vscode/tasks.json
16+
!.vscode/launch.json
17+
!.vscode/extensions.json
18+
*.code-workspace
19+
20+
### VisualStudioCode Patch ###
21+
# Ignore all local history of files
22+
.history

.nvmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
18.13.0

blog/.vitepress/config.ts

Lines changed: 168 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,168 @@
1+
import { getBlogs } from "./theme/serverUtils";
2+
import mdKatex from "./theme/markdown-it-katex";
3+
import { buildBlogRSS } from "./theme/rss";
4+
import * as SECRETS from "./secret";
5+
import MarkdownIt from "markdown-it";
6+
7+
async function configs() {
8+
return {
9+
title: "makevyc的博客",
10+
head: [
11+
// live2d widget
12+
[
13+
"script",
14+
{
15+
src: "https://cdn.jsdelivr.net/gh/stevenjoezhang/live2d-widget@latest/autoload.js",
16+
}
17+
],
18+
// KaTex stylesheet for markdown-it-katex
19+
[
20+
"link",
21+
{
22+
rel: "stylesheet",
23+
href:
24+
"https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.11.1/katex.min.css",
25+
},
26+
],
27+
// markdown-it
28+
[
29+
"link",
30+
{
31+
rel: "stylesheet",
32+
href:
33+
"https://cdnjs.cloudflare.com/ajax/libs/github-markdown-css/4.0.0/github-markdown.min.css",
34+
},
35+
],
36+
// font-awesome
37+
[
38+
"link",
39+
{
40+
rel: "stylesheet",
41+
href:
42+
"https://cdn.jsdelivr.net/npm/font-awesome/css/font-awesome.min.css",
43+
},
44+
],
45+
// ionicons used in `about-me` page
46+
[
47+
"link",
48+
{
49+
rel: "stylesheet",
50+
href: "https://cdn.staticfile.org/ionicons/2.0.1/css/ionicons.min.css",
51+
},
52+
],
53+
// site resources
54+
[
55+
"link",
56+
{
57+
rel: "icon",
58+
type: "image/png",
59+
href: "/logo.png",
60+
},
61+
],
62+
[
63+
"meta",
64+
{
65+
name: "author",
66+
content: "makevyc",
67+
},
68+
],
69+
[
70+
"meta",
71+
{
72+
property: "og:title",
73+
content: "Home",
74+
},
75+
],
76+
[
77+
"meta",
78+
{
79+
property: "og:description",
80+
content: "Home of makevyc",
81+
},
82+
],
83+
],
84+
locales: {
85+
root: {
86+
label: 'English', lang: 'en',
87+
description: "Personal Blog",
88+
themeConfig: {
89+
lastUpdatedText: "Last Updated",
90+
nav: [
91+
{ text: "🏡Homepage", link: "/" },
92+
{ text: "🦹‍♂️About Me", link: "/about-me/" },
93+
{
94+
text: "📓Blogs",
95+
items: [
96+
{ text: "📃Archives", link: "/zh/blogs/" },
97+
{ text: "🔖Tags", link: "/zh/blogs/tags/" },
98+
],
99+
},
100+
{
101+
text: "🔥RSS",
102+
link: "https://makevyc.github.io/feed.xml",
103+
},
104+
],
105+
}
106+
},
107+
zh: {
108+
label: '中文', lang: 'zh-CN', link: '/zh/',
109+
description: "个人博客",
110+
themeConfig: {
111+
lastUpdatedText: "上次更新",
112+
nav: [
113+
{ text: "🏡主页", link: "/zh/" },
114+
{ text: "🦹‍♂️关于我", link: "/zh/about-me/" },
115+
{
116+
text: "📓博客",
117+
items: [
118+
{ text: "📃所有博客", link: "/zh/blogs/" },
119+
{ text: "🔖标签分类", link: "/zh/blogs/tags/" },
120+
],
121+
},
122+
{
123+
text: "🔥RSS",
124+
link: "https://makevyc.github.io/feed.xml",
125+
},
126+
],
127+
}
128+
},
129+
},
130+
themeConfig: {
131+
logo: "/assets/logo.png",
132+
homeLottie: "/assets/lottie-developer.json",
133+
i18nRouting: false,
134+
// refer to the `VPNavBarTitle.vue` in default theme,
135+
// we have to set it to null to disable the text in navigation bar,
136+
// the undefined is not applicable here,
137+
siteTitle: null,
138+
blogs: await getBlogs(),
139+
// select two latest posts to display on the index page
140+
latestNum: 2,
141+
// gitalk comments configurations
142+
gitalk: {
143+
admin: ["makevyc"],
144+
repo: 'makevyc.github.io',
145+
clientID: SECRETS.GITALK_ID,
146+
clientSecret: SECRETS.GITALK_SECRET,
147+
owner: "makevyc",
148+
},
149+
// algolia search configurations
150+
algolia: {
151+
indexName: 'forswornsio',
152+
appId: SECRETS.ALGOLIA_ID,
153+
apiKey: SECRETS.ALGOLIA_SECRET,
154+
},
155+
socialLinks: [
156+
{ icon: "github", link: "https://github.com/makevyc" },
157+
],
158+
},
159+
markdown: {
160+
config: (md: MarkdownIt) => {
161+
md.use(mdKatex);
162+
},
163+
},
164+
buildEnd: buildBlogRSS,
165+
};
166+
}
167+
168+
export default configs();
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
<template>
2+
<transition name="fade">
3+
<svg v-if="show" class="go-to-top" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 49.484 28.284"
4+
@click="scrollToTop">
5+
<g transform="translate(-229 -126.358)">
6+
<rect fill="currentColor" width="35" height="5" rx="2" transform="translate(229 151.107) rotate(-45)" />
7+
<rect fill="currentColor" width="35" height="5" rx="2"
8+
transform="translate(274.949 154.642) rotate(-135)" />
9+
</g>
10+
</svg>
11+
</transition>
12+
</template>
13+
14+
<script lang="ts" setup>
15+
import debounce from "lodash.debounce";
16+
import { ref, type Ref, computed, onMounted } from "vue";
17+
18+
const props = defineProps({
19+
threshold: {
20+
type: Number,
21+
default: 300,
22+
}
23+
});
24+
25+
let scrollTop: Ref<number> = ref(0);
26+
const show = computed(() => scrollTop.value > props.threshold);
27+
28+
const getScrollTop = () => {
29+
return window.pageYOffset
30+
|| document.documentElement.scrollTop
31+
|| document.body.scrollTop || 0
32+
};
33+
const scrollToTop = () => {
34+
window.scrollTo({ top: 0, behavior: 'smooth' });
35+
scrollTop.value = 0;
36+
};
37+
38+
onMounted(() => {
39+
scrollTop.value = getScrollTop()
40+
window.addEventListener('scroll', debounce(() => {
41+
scrollTop.value = getScrollTop();
42+
}, 100))
43+
});
44+
45+
</script>
46+
47+
<style scoped>
48+
.go-to-top {
49+
cursor: pointer;
50+
position: fixed;
51+
bottom: 2rem;
52+
right: 2.5rem;
53+
width: 2rem;
54+
color: #3ec650;
55+
z-index: 1;
56+
}
57+
58+
.go-to-top:hover {
59+
color: lighten(#3ec650, 30%);
60+
}
61+
62+
@media (max-width: 959px) {
63+
.go-to-top {
64+
display: none;
65+
}
66+
}
67+
68+
.fade-enter-active,
69+
.fade-leave-active {
70+
transition: opacity 0.3s;
71+
}
72+
73+
.fade-enter,
74+
.fade-leave-to {
75+
opacity: 0;
76+
}
77+
</style>
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<template>
2+
<div id="gitalk-container"></div>
3+
</template>
4+
<script lang="ts" setup>
5+
import "gitalk/dist/gitalk.css";
6+
import Gitalk from "gitalk";
7+
import { onMounted } from "vue";
8+
import { useData } from "vitepress";
9+
10+
const { theme } = useData();
11+
12+
const lang = location.href.includes('/zh/') ? 'zh-CN' : 'en';
13+
14+
const gitalk = new Gitalk({
15+
...theme.value.gitalk,
16+
id: location.pathname.substring(0, 50), // Ensure uniqueness and length less than 50
17+
language: lang,
18+
distractionFreeMode: true, // Facebook-like distraction free mode
19+
});
20+
21+
onMounted(() => {
22+
gitalk.render("gitalk-container");
23+
});
24+
</script>
25+
<style scoped>
26+
27+
</style>
28+

0 commit comments

Comments
 (0)