feat: add rss

This commit is contained in:
KazooTTT
2024-11-23 16:51:13 +08:00
parent 01c70257a1
commit 790c91c342
7 changed files with 22 additions and 6 deletions

View File

@ -1,5 +1,4 @@
import GitHubCalendar from "react-github-calendar"; import GitHubCalendar from "react-github-calendar";
import React from "react";
const GithubHotLine = () => { const GithubHotLine = () => {
return ( return (
<GitHubCalendar username='kazoottt' /> <GitHubCalendar username='kazoottt' />

View File

@ -48,6 +48,13 @@ import { Icon } from 'astro-icon/components'
> >
<Icon name="twitter" class="w-5 h-5" /> <Icon name="twitter" class="w-5 h-5" />
</a> </a>
<a
class='inline-block text-muted-foreground transition-all hover:text-muted-foreground/75'
href='/rss.xml'
aria-label="RSS Feed"
>
<Icon name="rss" class="w-5 h-5" />
</a>
</div> </div>
<!-- End Social Brands --> <!-- End Social Brands -->
</div> </div>

5
src/icons/rss.svg Normal file
View File

@ -0,0 +1,5 @@
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<path d="M4 11a9 9 0 0 1 9 9"/>
<path d="M4 4a16 16 0 0 1 16 16"/>
<circle cx="5" cy="19" r="1"/>
</svg>

After

Width:  |  Height:  |  Size: 293 B

View File

@ -45,7 +45,7 @@ const mdProjects = allPosts
.map((post) => ({ .map((post) => ({
title: post.data.title, title: post.data.title,
description: post.data.description || '', description: post.data.description || '',
url: post.data.projectUrl ? post.data.projectUrl : `/posts/${post.slug}`, url: post.data.projectUrl ? post.data.projectUrl : `/blog/${post.slug}`,
imagePath: post.data.coverImage, imagePath: post.data.coverImage,
altText: post.data.title, altText: post.data.title,
isExternal: !!post.data.projectUrl isExternal: !!post.data.projectUrl

View File

@ -1,17 +1,17 @@
import rss from '@astrojs/rss' import rss from '@astrojs/rss'
import { siteConfig } from '@/site-config' import { siteConfig } from '@/site-config'
import { getAllPosts } from '@/utils' import { getAllSortedPosts } from '@/utils'
export const GET = async () => { export const GET = async () => {
const posts = await getAllPosts() const posts = await getAllSortedPosts()
return rss({ return rss({
title: siteConfig.title, title: siteConfig.title,
description: siteConfig.description, description: siteConfig.description,
site: import.meta.env.SITE, site: import.meta.env.SITE,
items: posts.map((post) => ({ items: posts.map((post) => ({
title: post.data.title, title: post.data.title ?? '',
description: post.data.description, description: `${post.data.description ?? ''}\nfeedId:76245438397618182+userId:62156866798228480`,
pubDate: post.data.date, pubDate: post.data.date,
link: `/blog/${post.slug}` link: `/blog/${post.slug}`
})) }))

View File

@ -1,6 +1,7 @@
export { cn } from './tailwind' export { cn } from './tailwind'
export { export {
getAllPosts, getAllPosts,
getAllSortedPosts,
sortMDByDate, sortMDByDate,
getUniqueTags, getUniqueTags,
getUniqueTagsWithCount, getUniqueTagsWithCount,

View File

@ -8,6 +8,10 @@ export async function getAllPosts() {
}) })
} }
export async function getAllSortedPosts() {
return sortMDByDate(await getAllPosts())
}
export function sortMDByDate(posts: Array<CollectionEntry<'post'>>) { export function sortMDByDate(posts: Array<CollectionEntry<'post'>>) {
return posts.sort((a, b) => { return posts.sort((a, b) => {
const aDate = new Date(a.data.date).valueOf() const aDate = new Date(a.data.date).valueOf()