mirror of
https://github.com/ClovertaTheTrilobita/SanYeCao-blog.git
synced 2026-07-03 15:41:26 +00:00
Compare commits
10 commits
56e8ad5b0d
...
c2aa6c2a68
| Author | SHA1 | Date | |
|---|---|---|---|
| c2aa6c2a68 | |||
| c626bdbb07 | |||
|
|
6ac21acc63 | ||
| 6b804c3519 | |||
| 141c15f557 | |||
| 04d81bd3a5 | |||
| cd7e72caee | |||
|
|
11ddcb4ae0 | ||
| 0775eb7927 | |||
| 08bdca532a |
8 changed files with 224 additions and 46 deletions
119
.github/workflows/deploy-blog.yml
vendored
119
.github/workflows/deploy-blog.yml
vendored
|
|
@ -1,43 +1,106 @@
|
||||||
name: Deploy Astro Blog
|
name: Sync and Deploy Astro Blog
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- blog-content
|
- master
|
||||||
paths:
|
|
||||||
- 'src/blog/**'
|
|
||||||
- 'src/friends/**'
|
|
||||||
- 'package.json'
|
|
||||||
- 'package-lock.json'
|
|
||||||
- 'astro.config.mjs'
|
|
||||||
- 'astro.config.ts'
|
|
||||||
- 'public/**'
|
|
||||||
- '.github/workflows/deploy-blog.yml'
|
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
|
|
||||||
discussion:
|
|
||||||
types: [created, category_changed]
|
|
||||||
|
|
||||||
discussion_comment:
|
|
||||||
types: [created, edited, deleted]
|
|
||||||
|
|
||||||
concurrency:
|
concurrency:
|
||||||
group: deploy-blog
|
group: deploy-blog
|
||||||
cancel-in-progress: true
|
cancel-in-progress: true
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
|
sync-blog-content:
|
||||||
|
if: github.event_name == 'push'
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
permissions:
|
||||||
|
contents: write
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout repository
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
|
|
||||||
|
- name: Configure git
|
||||||
|
run: |
|
||||||
|
git config user.name "github-actions[bot]"
|
||||||
|
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
|
||||||
|
|
||||||
|
- name: Checkout blog-content branch
|
||||||
|
run: |
|
||||||
|
git checkout blog-content
|
||||||
|
git pull origin blog-content
|
||||||
|
|
||||||
|
- name: Merge master into blog-content
|
||||||
|
run: |
|
||||||
|
git merge origin/master --no-edit
|
||||||
|
|
||||||
|
- name: Push blog-content
|
||||||
|
run: |
|
||||||
|
git push origin blog-content
|
||||||
|
|
||||||
build-and-deploy:
|
build-and-deploy:
|
||||||
if: >
|
needs: sync-blog-content
|
||||||
github.event_name == 'push' ||
|
if: github.event_name == 'push'
|
||||||
github.event_name == 'workflow_dispatch' ||
|
runs-on: ubuntu-latest
|
||||||
(
|
|
||||||
github.event_name == 'discussion' &&
|
env:
|
||||||
github.event.discussion.category.slug == 'comments'
|
DEPLOY_HOST: ${{ vars.DEPLOY_HOST }}
|
||||||
) ||
|
DEPLOY_PORT: ${{ vars.DEPLOY_PORT }}
|
||||||
(
|
DEPLOY_PATH: ${{ vars.DEPLOY_PATH }}
|
||||||
github.event_name == 'discussion_comment' &&
|
DEPLOY_USER: ${{ vars.DEPLOY_USER }}
|
||||||
github.event.discussion.category.slug == 'comments'
|
|
||||||
)
|
steps:
|
||||||
|
- name: Checkout blog-content branch
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
ref: blog-content
|
||||||
|
|
||||||
|
- name: Setup Node
|
||||||
|
uses: actions/setup-node@v4
|
||||||
|
with:
|
||||||
|
node-version: 24
|
||||||
|
cache: npm
|
||||||
|
|
||||||
|
- name: Install dependencies
|
||||||
|
run: npm ci
|
||||||
|
|
||||||
|
- name: Create .env file
|
||||||
|
run: |
|
||||||
|
cat > .env <<'EOF'
|
||||||
|
${{ secrets.ENV_FILE }}
|
||||||
|
EOF
|
||||||
|
|
||||||
|
- name: Build Astro site
|
||||||
|
run: npm run build
|
||||||
|
|
||||||
|
- name: Install rsync and ssh client
|
||||||
|
run: sudo apt-get update && sudo apt-get install -y rsync openssh-client
|
||||||
|
|
||||||
|
- name: Setup SSH
|
||||||
|
run: |
|
||||||
|
mkdir -p ~/.ssh
|
||||||
|
echo "${{ secrets.DEPLOY_SSH_KEY }}" > ~/.ssh/id_rsa
|
||||||
|
chmod 600 ~/.ssh/id_rsa
|
||||||
|
echo "${{ secrets.DEPLOY_KNOWN_HOSTS }}" > ~/.ssh/known_hosts
|
||||||
|
chmod 644 ~/.ssh/known_hosts
|
||||||
|
|
||||||
|
- name: Deploy to server
|
||||||
|
run: |
|
||||||
|
rsync -avz --delete \
|
||||||
|
--omit-dir-times \
|
||||||
|
--no-perms \
|
||||||
|
--no-owner \
|
||||||
|
--no-group \
|
||||||
|
-e "ssh -p ${DEPLOY_PORT}" \
|
||||||
|
dist/ \
|
||||||
|
${DEPLOY_USER}@${DEPLOY_HOST}:${DEPLOY_PATH}/
|
||||||
|
|
||||||
|
manual-deploy:
|
||||||
|
if: github.event_name == 'workflow_dispatch'
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
env:
|
env:
|
||||||
|
|
|
||||||
|
|
@ -86,6 +86,10 @@ For installation and deployment details, please refer to the official documentat
|
||||||
|
|
||||||
For details, see: <b>[ChangeLog-en.md](./docs/ChangeLog-en.md)</b>
|
For details, see: <b>[ChangeLog-en.md](./docs/ChangeLog-en.md)</b>
|
||||||
|
|
||||||
|
### 6. Older Versions
|
||||||
|
|
||||||
|
Older versions of GISCUS are available on the <b>[deprecated/giscus](https://github.com/ClovertaTheTrilobita/SanYeCao-blog/tree/deprecated/giscus)</b> branch, but they haven’t been updated in a while and may contain numerous issues.
|
||||||
|
|
||||||
<hr>
|
<hr>
|
||||||
|
|
||||||
## ⚖️ License
|
## ⚖️ License
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
# SanYeCao-Blog
|
# SanYeCao-Blog
|
||||||
|
|
||||||
[中文](README.md) | [English](README-en.md)
|
<p align="right">[<a href="./README.md">中文</a> | <a href="./README-en.md">English</a>]</p>
|
||||||
|
|
||||||
<p align="center"><br>
|
<p align="center"><br>
|
||||||
✨三叶草Blog✨<br>
|
✨三叶草Blog✨<br>
|
||||||
|
|
@ -88,6 +88,10 @@
|
||||||
|
|
||||||
详情请看:<b>[ChangeLog.md](./docs/ChangeLog.md)</b>
|
详情请看:<b>[ChangeLog.md](./docs/ChangeLog.md)</b>
|
||||||
|
|
||||||
|
### 6. 旧版本
|
||||||
|
|
||||||
|
支持GISCUS的旧版本在 <b>[deprecated/giscus](https://github.com/ClovertaTheTrilobita/SanYeCao-blog/tree/deprecated/giscus)</b> 分支上,但是它有些时候没更新了,可能会有诸多问题。
|
||||||
|
|
||||||
<hr>
|
<hr>
|
||||||
|
|
||||||
## ⚖️ 许可
|
## ⚖️ 许可
|
||||||
|
|
|
||||||
|
|
@ -143,7 +143,7 @@ const t = getTranslations(lang);
|
||||||
color: white;
|
color: white;
|
||||||
}
|
}
|
||||||
|
|
||||||
@media (max-width: 768px) {
|
@media (max-width: 700px) {
|
||||||
.site-nav-desktop {
|
.site-nav-desktop {
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,14 +1,32 @@
|
||||||
---
|
---
|
||||||
import "@/styles/global.css";
|
import "@/styles/global.css";
|
||||||
import Remark42Count from "@/components/remark42-counter.svelte";
|
import Remark42Count from "@/components/remark42-counter.svelte";
|
||||||
|
import { getLangFromUrl } from "@/i18n";
|
||||||
|
|
||||||
|
const lang = getLangFromUrl(Astro.url);
|
||||||
const data = Astro.props;
|
const data = Astro.props;
|
||||||
|
const tags = data.tags;
|
||||||
---
|
---
|
||||||
|
|
||||||
<li class="post-card">
|
<li class="post-card">
|
||||||
<a href={data.url} class="post-link" data-astro-reload>
|
<div class="post-link">
|
||||||
<div class="post-text">
|
<div class="post-text">
|
||||||
<span class="post-title">{data.title}</span>
|
<a href={data.url} class="post-title">
|
||||||
<span class="post-description">{data.description}</span>
|
{data.title}
|
||||||
|
</a>
|
||||||
|
|
||||||
|
<a href={data.url} class="post-description">
|
||||||
|
{data.description}
|
||||||
|
</a>
|
||||||
|
<div class="tags">
|
||||||
|
{
|
||||||
|
tags.map((tag: string) => (
|
||||||
|
<p class="tag">
|
||||||
|
<a href={`/${lang}/tags/${tag}`}>{tag}</a>
|
||||||
|
</p>
|
||||||
|
))
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="post-meta-row">
|
<div class="post-meta-row">
|
||||||
<span class="post-date">{data.date}</span>
|
<span class="post-date">{data.date}</span>
|
||||||
|
|
@ -20,13 +38,73 @@ const data = Astro.props;
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<img src={data.img} alt={data.title} class="post-image" loading="lazy" />
|
<a href={data.url} class="post-image-link">
|
||||||
</a>
|
<img src={data.img} alt={data.title} class="post-image" loading="lazy" />
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
</li>
|
</li>
|
||||||
|
|
||||||
<div class="section-divider"></div>
|
<div class="section-divider"></div>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
|
.tags {
|
||||||
|
display: flex;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
gap: 0.4rem;
|
||||||
|
margin-top: 0.5rem;
|
||||||
|
margin-bottom: 0.5rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tag {
|
||||||
|
font-family:
|
||||||
|
system-ui,
|
||||||
|
-apple-system,
|
||||||
|
BlinkMacSystemFont,
|
||||||
|
"Segoe UI",
|
||||||
|
Roboto,
|
||||||
|
Oxygen,
|
||||||
|
Ubuntu,
|
||||||
|
Cantarell,
|
||||||
|
"Open Sans",
|
||||||
|
"Helvetica Neue",
|
||||||
|
sans-serif;
|
||||||
|
|
||||||
|
margin: 0;
|
||||||
|
padding: 0.22em 0.65em;
|
||||||
|
font-size: 1rem;
|
||||||
|
line-height: 1.2;
|
||||||
|
border: 1px dashed #8b6b4a;
|
||||||
|
border-radius: 0;
|
||||||
|
background-color: transparent;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tag a {
|
||||||
|
color: #6f4e37;
|
||||||
|
text-decoration: none;
|
||||||
|
font-size: 0.8rem;
|
||||||
|
font-weight: 500;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tag a:hover {
|
||||||
|
text-decoration: underline;
|
||||||
|
}
|
||||||
|
|
||||||
|
:global(.dark) .tag {
|
||||||
|
border-color: #d8c7a1;
|
||||||
|
}
|
||||||
|
|
||||||
|
:global(.dark) .tag a {
|
||||||
|
color: #e6d8b8;
|
||||||
|
}
|
||||||
|
|
||||||
|
:global(.dark) .tag {
|
||||||
|
border-color: #d8c7a1;
|
||||||
|
}
|
||||||
|
|
||||||
|
:global(.dark) .tag a {
|
||||||
|
color: #e6d8b8;
|
||||||
|
}
|
||||||
|
|
||||||
.post-card {
|
.post-card {
|
||||||
list-style: none;
|
list-style: none;
|
||||||
margin: 0 0 1rem 0;
|
margin: 0 0 1rem 0;
|
||||||
|
|
@ -47,6 +125,7 @@ const data = Astro.props;
|
||||||
.post-text {
|
.post-text {
|
||||||
flex: 1;
|
flex: 1;
|
||||||
min-width: 0;
|
min-width: 0;
|
||||||
|
max-width: 40rem;
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
|
|
@ -57,7 +136,6 @@ const data = Astro.props;
|
||||||
.post-title {
|
.post-title {
|
||||||
font-family:
|
font-family:
|
||||||
system-ui,
|
system-ui,
|
||||||
sans-serif,
|
|
||||||
-apple-system,
|
-apple-system,
|
||||||
BlinkMacSystemFont,
|
BlinkMacSystemFont,
|
||||||
"Segoe UI",
|
"Segoe UI",
|
||||||
|
|
@ -66,9 +144,9 @@ const data = Astro.props;
|
||||||
Ubuntu,
|
Ubuntu,
|
||||||
Cantarell,
|
Cantarell,
|
||||||
"Open Sans",
|
"Open Sans",
|
||||||
"Helvetica Neue";
|
"Helvetica Neue",
|
||||||
color: inherit;
|
sans-serif;
|
||||||
font-weight: 700;
|
font-weight: 500;
|
||||||
font-size: 1.34rem;
|
font-size: 1.34rem;
|
||||||
line-height: 1.6;
|
line-height: 1.6;
|
||||||
display: -webkit-box;
|
display: -webkit-box;
|
||||||
|
|
@ -79,7 +157,9 @@ const data = Astro.props;
|
||||||
|
|
||||||
.post-description {
|
.post-description {
|
||||||
color: black;
|
color: black;
|
||||||
|
text-decoration: none;
|
||||||
font-weight: 400;
|
font-weight: 400;
|
||||||
|
font-size: 0.92rem;
|
||||||
font-style: italic;
|
font-style: italic;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -114,12 +194,12 @@ const data = Astro.props;
|
||||||
}
|
}
|
||||||
|
|
||||||
.post-image {
|
.post-image {
|
||||||
width: calc((1.6em * 4) * 16 / 9);
|
width: calc((1.6em * 4) * 16 / 10);
|
||||||
height: calc(1.6em * 4);
|
height: calc(1.6em * 4);
|
||||||
aspect-ratio: 16 / 9;
|
aspect-ratio: 16 / 10;
|
||||||
object-fit: cover;
|
object-fit: cover;
|
||||||
object-position: center;
|
object-position: center;
|
||||||
border-radius: 0.5rem;
|
border: 2px #94a0ab dashed;
|
||||||
flex-shrink: 0;
|
flex-shrink: 0;
|
||||||
display: block;
|
display: block;
|
||||||
}
|
}
|
||||||
|
|
@ -132,13 +212,14 @@ const data = Astro.props;
|
||||||
color: #aab7c4;
|
color: #aab7c4;
|
||||||
}
|
}
|
||||||
|
|
||||||
@media (max-width: 640px) {
|
@media (max-width: 600px) {
|
||||||
.post-link {
|
.post-link {
|
||||||
display: grid;
|
display: grid;
|
||||||
grid-template-columns: 1fr 120px;
|
grid-template-columns: 1fr 145px;
|
||||||
grid-template-areas:
|
grid-template-areas:
|
||||||
"title title"
|
"title title"
|
||||||
"desc image"
|
"desc image"
|
||||||
|
"tags image"
|
||||||
"meta image";
|
"meta image";
|
||||||
column-gap: 0.75rem;
|
column-gap: 0.75rem;
|
||||||
row-gap: 0.2rem;
|
row-gap: 0.2rem;
|
||||||
|
|
@ -165,9 +246,19 @@ const data = Astro.props;
|
||||||
}
|
}
|
||||||
|
|
||||||
.post-image {
|
.post-image {
|
||||||
|
border: none;
|
||||||
grid-area: image;
|
grid-area: image;
|
||||||
width: 120px;
|
width: 100%;
|
||||||
height: calc(120px * 9 / 16);
|
height: calc(145px * 10 / 16);
|
||||||
|
align-self: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.post-image-link {
|
||||||
|
grid-area: image;
|
||||||
|
align-self: center;
|
||||||
|
display: block;
|
||||||
|
width: 145px;
|
||||||
|
text-decoration: none;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
|
||||||
|
|
@ -37,6 +37,7 @@ const latestPosts = filteredPosts.slice(0, 5);
|
||||||
description={post.data.description}
|
description={post.data.description}
|
||||||
date={formattedDate}
|
date={formattedDate}
|
||||||
img={post.data.image.url}
|
img={post.data.image.url}
|
||||||
|
tags={post.data.tags}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
})
|
})
|
||||||
|
|
|
||||||
|
|
@ -53,6 +53,7 @@ const t = getTranslations(lang);
|
||||||
title={post.data.title}
|
title={post.data.title}
|
||||||
date={formattedDate}
|
date={formattedDate}
|
||||||
img={post.data.image.url}
|
img={post.data.image.url}
|
||||||
|
tags={post.data.tags}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
})
|
})
|
||||||
|
|
|
||||||
|
|
@ -39,6 +39,19 @@ const pageTitle = lang === "zh" ? "标签索引" : "Tag Index";
|
||||||
}
|
}
|
||||||
|
|
||||||
.tag {
|
.tag {
|
||||||
|
font-family:
|
||||||
|
system-ui,
|
||||||
|
-apple-system,
|
||||||
|
BlinkMacSystemFont,
|
||||||
|
"Segoe UI",
|
||||||
|
Roboto,
|
||||||
|
Oxygen,
|
||||||
|
Ubuntu,
|
||||||
|
Cantarell,
|
||||||
|
"Open Sans",
|
||||||
|
"Helvetica Neue",
|
||||||
|
sans-serif;
|
||||||
|
|
||||||
margin: 0;
|
margin: 0;
|
||||||
padding: 0.22em 0.65em;
|
padding: 0.22em 0.65em;
|
||||||
font-size: 1rem;
|
font-size: 1rem;
|
||||||
|
|
@ -51,6 +64,7 @@ const pageTitle = lang === "zh" ? "标签索引" : "Tag Index";
|
||||||
.tag a {
|
.tag a {
|
||||||
color: #6f4e37;
|
color: #6f4e37;
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
|
font-weight: 500;
|
||||||
}
|
}
|
||||||
|
|
||||||
.tag a:hover {
|
.tag a:hover {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue