Compare commits

..

No commits in common. "f47501d79decaf5d22281b58edd75b7953dc6483" and "715d6c9b7be9b535e6896c19fad41d4d36d0f89b" have entirely different histories.

3 changed files with 12 additions and 56 deletions

View file

@ -14,14 +14,13 @@ const lang = getLangFromUrl(Astro.url);
const t = getTranslations(lang);
const headerTitle = lang === "zh" ? "Cloverta的博客" : "Cloverta's blog";
const pageTitle = t.home.title;
const rssLink = lang === "zh" ? "/rss.xml" : "/en/rss.xml"
---
<BaseLayout pageTitle=`${headerTitle} - ${t.banner.subtitle}`>
<h1 class="page-title">
<span>{pageTitle}</span>
<a
href={rssLink}
href={`/rss.xml`}
target="_blank"
rel="noopener noreferrer"
aria-label="RSS Feed"

View file

@ -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>',
});
}

View file

@ -1,34 +1,26 @@
import rss from '@astrojs/rss';
import { pagesGlobToRssItems } from '@astrojs/rss';
import { getCollection } from 'astro:content';
export async function GET(context) {
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()
);
const posts = await getCollection("blog");
return rss({
title: 'Cloverta的博客',
description: '在这里,发现更多(雾)欢迎来到三叶的博客🥳',
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) => {
const [, ...slugParts] = post.id.split('/');
const slug = slugParts.join('/');
return {
return ({
title: post.data.title,
pubDate: post.data.pubDate,
description: post.data.description,
link: `/zh/posts/${slug}/`,
};
link: `/${postLang}/posts/${slug}/`,
})
}),
customData: '<language>zh-CN</language>',
});
customData: `<language>en-us</language>`,
})
}