mirror of
https://github.com/ClovertaTheTrilobita/SanYeCao-blog.git
synced 2026-07-03 15:41:26 +00:00
Compare commits
2 commits
1bb9d56e03
...
2a4c090c5d
| Author | SHA1 | Date | |
|---|---|---|---|
| 2a4c090c5d | |||
| e6fb5a4519 |
7 changed files with 171 additions and 123 deletions
|
|
@ -14,13 +14,14 @@ const lang = getLangFromUrl(Astro.url);
|
||||||
const t = getTranslations(lang);
|
const t = getTranslations(lang);
|
||||||
const headerTitle = lang === "zh" ? "Cloverta的博客" : "Cloverta's blog";
|
const headerTitle = lang === "zh" ? "Cloverta的博客" : "Cloverta's blog";
|
||||||
const pageTitle = t.home.title;
|
const pageTitle = t.home.title;
|
||||||
|
const rssLink = lang === "zh" ? "/rss.xml" : "/en/rss.xml"
|
||||||
---
|
---
|
||||||
|
|
||||||
<BaseLayout pageTitle=`${headerTitle} - ${t.banner.subtitle}`>
|
<BaseLayout pageTitle=`${headerTitle} - ${t.banner.subtitle}`>
|
||||||
<h1 class="page-title">
|
<h1 class="page-title">
|
||||||
<span>{pageTitle}</span>
|
<span>{pageTitle}</span>
|
||||||
<a
|
<a
|
||||||
href={`/rss.xml`}
|
href={rssLink}
|
||||||
target="_blank"
|
target="_blank"
|
||||||
rel="noopener noreferrer"
|
rel="noopener noreferrer"
|
||||||
aria-label="RSS Feed"
|
aria-label="RSS Feed"
|
||||||
|
|
|
||||||
35
src/pages/en/rss.xml.js
Normal file
35
src/pages/en/rss.xml.js
Normal file
|
|
@ -0,0 +1,35 @@
|
||||||
|
import rss from '@astrojs/rss';
|
||||||
|
import { getCollection } from 'astro:content';
|
||||||
|
|
||||||
|
export async function GET(context) {
|
||||||
|
const posts = await getCollection('blog');
|
||||||
|
|
||||||
|
const enPosts = posts
|
||||||
|
.filter((post) => post.id.startsWith('en/'))
|
||||||
|
.sort(
|
||||||
|
(a, b) =>
|
||||||
|
new Date(b.data.pubDate).getTime() -
|
||||||
|
new Date(a.data.pubDate).getTime()
|
||||||
|
);
|
||||||
|
|
||||||
|
return rss({
|
||||||
|
title: "Cloverta's Blog",
|
||||||
|
description:
|
||||||
|
"Discover more here. Welcome to Cloverta's blog 🥳",
|
||||||
|
site: context.site,
|
||||||
|
|
||||||
|
items: enPosts.map((post) => {
|
||||||
|
const [, ...slugParts] = post.id.split('/');
|
||||||
|
const slug = slugParts.join('/');
|
||||||
|
|
||||||
|
return {
|
||||||
|
title: post.data.title,
|
||||||
|
pubDate: post.data.pubDate,
|
||||||
|
description: post.data.description,
|
||||||
|
link: `/en/posts/${slug}/`,
|
||||||
|
};
|
||||||
|
}),
|
||||||
|
|
||||||
|
customData: '<language>en-US</language>',
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
@ -1,26 +1,34 @@
|
||||||
import rss from '@astrojs/rss';
|
import rss from '@astrojs/rss';
|
||||||
import { pagesGlobToRssItems } from '@astrojs/rss';
|
|
||||||
import { getCollection } from 'astro:content';
|
import { getCollection } from 'astro:content';
|
||||||
|
|
||||||
export async function GET(context) {
|
export async function GET(context) {
|
||||||
const posts = await getCollection("blog");
|
const posts = await getCollection('blog');
|
||||||
|
|
||||||
|
const zhPosts = posts
|
||||||
|
.filter((post) => post.id.startsWith('zh/'))
|
||||||
|
.sort(
|
||||||
|
(a, b) =>
|
||||||
|
new Date(b.data.pubDate).getTime() -
|
||||||
|
new Date(a.data.pubDate).getTime()
|
||||||
|
);
|
||||||
|
|
||||||
return rss({
|
return rss({
|
||||||
title: 'Cloverta的博客',
|
title: 'Cloverta的博客',
|
||||||
description: '在这里,发现更多(雾)欢迎来到三叶的博客🥳',
|
description: '在这里,发现更多(雾)欢迎来到三叶的博客🥳',
|
||||||
site: context.site,
|
site: context.site,
|
||||||
items: await pagesGlobToRssItems(import.meta.glob('./**/*.md')),
|
|
||||||
items: posts.map((post) => {
|
|
||||||
const [postLang, ...slugParts] = post.id.split("/");
|
|
||||||
const slug = slugParts.join("/");
|
|
||||||
|
|
||||||
return ({
|
items: zhPosts.map((post) => {
|
||||||
|
const [, ...slugParts] = post.id.split('/');
|
||||||
|
const slug = slugParts.join('/');
|
||||||
|
|
||||||
|
return {
|
||||||
title: post.data.title,
|
title: post.data.title,
|
||||||
pubDate: post.data.pubDate,
|
pubDate: post.data.pubDate,
|
||||||
description: post.data.description,
|
description: post.data.description,
|
||||||
link: `/${postLang}/posts/${slug}/`,
|
link: `/zh/posts/${slug}/`,
|
||||||
})
|
};
|
||||||
}),
|
}),
|
||||||
customData: `<language>en-us</language>`,
|
|
||||||
})
|
customData: '<language>zh-CN</language>',
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
@ -4,6 +4,7 @@
|
||||||
@import "./latest-comments.css";
|
@import "./latest-comments.css";
|
||||||
@import "./variables.css";
|
@import "./variables.css";
|
||||||
@import "./dialog.css";
|
@import "./dialog.css";
|
||||||
|
@import "./posts.css";
|
||||||
|
|
||||||
pre {
|
pre {
|
||||||
padding: 1rem;
|
padding: 1rem;
|
||||||
|
|
@ -117,7 +118,7 @@ h1 {
|
||||||
|
|
||||||
|
|
||||||
a {
|
a {
|
||||||
color: #3D74B6;
|
color: var(--url-color);
|
||||||
font-weight: 700;
|
font-weight: 700;
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
}
|
}
|
||||||
|
|
@ -162,111 +163,3 @@ img {
|
||||||
height: auto;
|
height: auto;
|
||||||
display: block;
|
display: block;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 避免 Markdown 内容撑宽正文 */
|
|
||||||
.post-article,
|
|
||||||
.post-content {
|
|
||||||
min-width: 0;
|
|
||||||
max-width: 100%;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* 块级公式过长时独立横向滚动 */
|
|
||||||
.post-content .katex-display {
|
|
||||||
display: block;
|
|
||||||
width: 100%;
|
|
||||||
max-width: 100%;
|
|
||||||
overflow-x: auto;
|
|
||||||
overflow-y: hidden;
|
|
||||||
box-sizing: border-box;
|
|
||||||
padding: 0.25rem 0;
|
|
||||||
-webkit-overflow-scrolling: touch;
|
|
||||||
}
|
|
||||||
|
|
||||||
.post-content .katex-display > .katex {
|
|
||||||
display: inline-block;
|
|
||||||
min-width: max-content;
|
|
||||||
white-space: nowrap;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* =========================
|
|
||||||
Markdown details 下拉栏
|
|
||||||
========================= */
|
|
||||||
|
|
||||||
.post-content details {
|
|
||||||
min-width: 0;
|
|
||||||
max-width: 100%;
|
|
||||||
box-sizing: border-box;
|
|
||||||
margin: 1.5rem 0;
|
|
||||||
overflow: hidden;
|
|
||||||
|
|
||||||
border-top: 2px solid #1e3a5f;
|
|
||||||
border-radius: 0 0 0.5rem 0.5rem;
|
|
||||||
background: rgba(128, 128, 128, 0.14);
|
|
||||||
}
|
|
||||||
|
|
||||||
.post-content details summary {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
gap: 0.5rem;
|
|
||||||
|
|
||||||
min-width: 0;
|
|
||||||
max-width: 100%;
|
|
||||||
box-sizing: border-box;
|
|
||||||
padding: 0.8rem 0.9rem;
|
|
||||||
|
|
||||||
cursor: pointer;
|
|
||||||
font-weight: 600;
|
|
||||||
user-select: none;
|
|
||||||
list-style: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
.post-content details summary::-webkit-details-marker {
|
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
.post-content details summary::before {
|
|
||||||
content: "›";
|
|
||||||
display: inline-block;
|
|
||||||
flex: 0 0 auto;
|
|
||||||
font-size: 1.25rem;
|
|
||||||
line-height: 1;
|
|
||||||
transition: transform 0.2s ease;
|
|
||||||
}
|
|
||||||
|
|
||||||
.post-content details[open] summary::before {
|
|
||||||
transform: rotate(90deg);
|
|
||||||
}
|
|
||||||
|
|
||||||
.post-content details > :not(summary) {
|
|
||||||
min-width: 0;
|
|
||||||
max-width: 100%;
|
|
||||||
box-sizing: border-box;
|
|
||||||
margin-top: 0;
|
|
||||||
margin-bottom: 0;
|
|
||||||
padding-right: 1rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.post-content details > ol,
|
|
||||||
.post-content details > ul {
|
|
||||||
padding: 0.6rem 1rem 1rem 3rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.post-content details li {
|
|
||||||
margin: 0.8rem 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
blockquote {
|
|
||||||
margin: 1.25rem 0;
|
|
||||||
padding: 0.75rem 1rem;
|
|
||||||
border-left: 4px solid var(--deep-red);
|
|
||||||
background: rgba(128, 128, 128, 0.1);
|
|
||||||
border-radius: 0 0.4rem 0.4rem 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
blockquote p {
|
|
||||||
margin: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
blockquote p + p {
|
|
||||||
margin-top: 0.75rem;
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -38,7 +38,7 @@
|
||||||
margin: 0 0 14px 0;
|
margin: 0 0 14px 0;
|
||||||
padding: 0.6rem 1rem;
|
padding: 0.6rem 1rem;
|
||||||
border: 2px dashed #aeb8c2;
|
border: 2px dashed #aeb8c2;
|
||||||
background-color: #fbf5f2;
|
background-color: var(--comment-background);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
108
src/styles/posts.css
Normal file
108
src/styles/posts.css
Normal file
|
|
@ -0,0 +1,108 @@
|
||||||
|
|
||||||
|
/* 避免 Markdown 内容撑宽正文 */
|
||||||
|
.post-article,
|
||||||
|
.post-content {
|
||||||
|
min-width: 0;
|
||||||
|
max-width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 块级公式过长时独立横向滚动 */
|
||||||
|
.post-content .katex-display {
|
||||||
|
display: block;
|
||||||
|
width: 100%;
|
||||||
|
max-width: 100%;
|
||||||
|
overflow-x: auto;
|
||||||
|
overflow-y: hidden;
|
||||||
|
box-sizing: border-box;
|
||||||
|
padding: 0.25rem 0;
|
||||||
|
-webkit-overflow-scrolling: touch;
|
||||||
|
}
|
||||||
|
|
||||||
|
.post-content .katex-display > .katex {
|
||||||
|
display: inline-block;
|
||||||
|
min-width: max-content;
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* =========================
|
||||||
|
Markdown details 下拉栏
|
||||||
|
========================= */
|
||||||
|
|
||||||
|
.post-content details {
|
||||||
|
min-width: 0;
|
||||||
|
max-width: 100%;
|
||||||
|
box-sizing: border-box;
|
||||||
|
margin: 1.5rem 0;
|
||||||
|
overflow: hidden;
|
||||||
|
|
||||||
|
border-top: 2px solid #1e3a5f;
|
||||||
|
border-radius: 0 0 0.5rem 0.5rem;
|
||||||
|
background: rgba(128, 128, 128, 0.14);
|
||||||
|
}
|
||||||
|
|
||||||
|
.post-content details summary {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 0.5rem;
|
||||||
|
|
||||||
|
min-width: 0;
|
||||||
|
max-width: 100%;
|
||||||
|
box-sizing: border-box;
|
||||||
|
padding: 0.8rem 0.9rem;
|
||||||
|
|
||||||
|
cursor: pointer;
|
||||||
|
font-weight: 600;
|
||||||
|
user-select: none;
|
||||||
|
list-style: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.post-content details summary::-webkit-details-marker {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.post-content details summary::before {
|
||||||
|
content: "›";
|
||||||
|
display: inline-block;
|
||||||
|
flex: 0 0 auto;
|
||||||
|
font-size: 1.25rem;
|
||||||
|
line-height: 1;
|
||||||
|
transition: transform 0.2s ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
.post-content details[open] summary::before {
|
||||||
|
transform: rotate(90deg);
|
||||||
|
}
|
||||||
|
|
||||||
|
.post-content details > :not(summary) {
|
||||||
|
min-width: 0;
|
||||||
|
max-width: 100%;
|
||||||
|
box-sizing: border-box;
|
||||||
|
margin-top: 0;
|
||||||
|
margin-bottom: 0;
|
||||||
|
padding-right: 1rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.post-content details > ol,
|
||||||
|
.post-content details > ul {
|
||||||
|
padding: 0.6rem 1rem 1rem 3rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.post-content details li {
|
||||||
|
margin: 0.8rem 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
blockquote {
|
||||||
|
margin: 1.25rem 0;
|
||||||
|
padding: 0.75rem 1rem;
|
||||||
|
border-left: 4px solid var(--deep-red);
|
||||||
|
background: rgba(128, 128, 128, 0.1);
|
||||||
|
border-radius: 0 0.4rem 0.4rem 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
blockquote p {
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
blockquote p + p {
|
||||||
|
margin-top: 0.75rem;
|
||||||
|
}
|
||||||
|
|
@ -1,8 +1,11 @@
|
||||||
|
/* 默认配色 */
|
||||||
:root {
|
:root {
|
||||||
--deep-blue: #536493;
|
--deep-blue: #536493;
|
||||||
--deep-red: #ef5a6f;
|
--deep-red: #ef5a6f;
|
||||||
--background-color: #f9f2ed;
|
--background-color: #f9f2ed;
|
||||||
--text-color: #0E2F56;
|
--text-color: #0e2f56;
|
||||||
|
--url-color: #3D74B6;
|
||||||
|
--comment-background: #fbf5f2;
|
||||||
|
|
||||||
--background-color-dark: #1e1e1e;
|
--background-color-dark: #1e1e1e;
|
||||||
--text-color-dark: #e6e6e6;
|
--text-color-dark: #e6e6e6;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue