mirror of
https://github.com/ClovertaTheTrilobita/SanYeCao-blog.git
synced 2026-07-03 23:51:26 +00:00
Compare commits
No commits in common. "f47501d79decaf5d22281b58edd75b7953dc6483" and "715d6c9b7be9b535e6896c19fad41d4d36d0f89b" have entirely different histories.
f47501d79d
...
715d6c9b7b
3 changed files with 12 additions and 56 deletions
|
|
@ -14,14 +14,13 @@ 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={rssLink}
|
href={`/rss.xml`}
|
||||||
target="_blank"
|
target="_blank"
|
||||||
rel="noopener noreferrer"
|
rel="noopener noreferrer"
|
||||||
aria-label="RSS Feed"
|
aria-label="RSS Feed"
|
||||||
|
|
|
||||||
|
|
@ -1,35 +0,0 @@
|
||||||
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,34 +1,26 @@
|
||||||
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("/");
|
||||||
|
|
||||||
items: zhPosts.map((post) => {
|
return ({
|
||||||
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: `/zh/posts/${slug}/`,
|
link: `/${postLang}/posts/${slug}/`,
|
||||||
};
|
})
|
||||||
}),
|
}),
|
||||||
|
customData: `<language>en-us</language>`,
|
||||||
customData: '<language>zh-CN</language>',
|
})
|
||||||
});
|
|
||||||
}
|
}
|
||||||
Loading…
Reference in a new issue