mirror of
https://github.com/KazooTTT/kazoottt-blog.git
synced 2025-06-22 18:21:33 +08:00
feat: add rss
This commit is contained in:
@ -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' />
|
||||||
|
@ -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
5
src/icons/rss.svg
Normal 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 |
@ -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
|
||||||
|
@ -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}`
|
||||||
}))
|
}))
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
export { cn } from './tailwind'
|
export { cn } from './tailwind'
|
||||||
export {
|
export {
|
||||||
getAllPosts,
|
getAllPosts,
|
||||||
|
getAllSortedPosts,
|
||||||
sortMDByDate,
|
sortMDByDate,
|
||||||
getUniqueTags,
|
getUniqueTags,
|
||||||
getUniqueTagsWithCount,
|
getUniqueTagsWithCount,
|
||||||
|
@ -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()
|
||||||
|
Reference in New Issue
Block a user