✨ RSS & Sitemap
This commit is contained in:
@ -11,6 +11,8 @@ export interface RelatedAccount {
|
||||
}
|
||||
|
||||
export const SITE_NAME = "Goatshed";
|
||||
export const SITE_DESCRIPTION = "山羊寒舍,在这里最终智羊工作室的最新动态。";
|
||||
export const SITE_URL = "https://smartsheep.studio"
|
||||
|
||||
export const RELATED_ACCOUNTS: RelatedAccount[] = [
|
||||
{ icon: <GitHubIcon />, platform: "GitHub", accountName: "@smartsheep-hq", link: "https://github.com/smartsheep-hq" },
|
||||
|
28
app/feed/route.ts
Normal file
28
app/feed/route.ts
Normal file
@ -0,0 +1,28 @@
|
||||
import RSS from "rss";
|
||||
import { SITE_DESCRIPTION, SITE_NAME, SITE_URL } from "@/app/consts";
|
||||
import { getSortedPosts } from "@/content/posts";
|
||||
|
||||
export async function GET() {
|
||||
const feed = new RSS({
|
||||
title: SITE_NAME,
|
||||
description: SITE_DESCRIPTION,
|
||||
site_url: SITE_URL,
|
||||
feed_url: `${SITE_URL}/feed`,
|
||||
language: "zh-CN"
|
||||
});
|
||||
|
||||
getSortedPosts().forEach((item) => {
|
||||
feed.item({
|
||||
url: `${SITE_URL}/p/${item.id}`,
|
||||
title: item.title,
|
||||
description: item.description ?? "No description yet.",
|
||||
date: item.date,
|
||||
});
|
||||
});
|
||||
|
||||
return new Response(feed.xml(), {
|
||||
headers: {
|
||||
"content-type": "application/xml"
|
||||
}
|
||||
});
|
||||
}
|
@ -3,7 +3,7 @@ import { ReactNode } from "react";
|
||||
import { ThemeProvider } from "@mui/material/styles";
|
||||
import { AppRouterCacheProvider } from "@mui/material-nextjs/v13-appRouter";
|
||||
import { CssBaseline } from "@mui/material";
|
||||
import { SITE_NAME } from "@/app/consts";
|
||||
import { SITE_DESCRIPTION, SITE_NAME } from "@/app/consts";
|
||||
import { theme } from "@/app/theme";
|
||||
|
||||
import "@fontsource/roboto/300.css";
|
||||
@ -16,15 +16,18 @@ import "./globals.css";
|
||||
import AppShell from "@/components/AppShell";
|
||||
|
||||
export const metadata: Metadata = {
|
||||
title: SITE_NAME,
|
||||
description: "山羊寒舍,在这里最终智羊工作室的最新动态。"
|
||||
title: {
|
||||
default: SITE_NAME,
|
||||
template: `${SITE_NAME} | %s`
|
||||
},
|
||||
description: SITE_DESCRIPTION,
|
||||
};
|
||||
|
||||
export default function RootLayout({ children }: Readonly<{
|
||||
children: ReactNode;
|
||||
}>) {
|
||||
return (
|
||||
<html lang="en">
|
||||
<html lang="zh-CN">
|
||||
<body>
|
||||
<AppRouterCacheProvider>
|
||||
<CssBaseline />
|
||||
|
@ -30,7 +30,7 @@ export default function PostList() {
|
||||
</Typography>
|
||||
</CardContent>
|
||||
<CardActions sx={{ paddingX: 4, paddingBottom: 2 }}>
|
||||
<Link href={`/posts/${post.id}`} passHref>
|
||||
<Link href={`/p/${post.id}`} passHref>
|
||||
<Button>Read more</Button>
|
||||
</Link>
|
||||
</CardActions>
|
||||
|
29
app/sitemap.ts
Normal file
29
app/sitemap.ts
Normal file
@ -0,0 +1,29 @@
|
||||
import { MetadataRoute } from "next";
|
||||
import { getSortedPosts, Post } from "@/content/posts";
|
||||
import { SITE_URL } from "@/app/consts";
|
||||
|
||||
export default function sitemap(): MetadataRoute.Sitemap {
|
||||
const posts = getSortedPosts();
|
||||
|
||||
return [
|
||||
{
|
||||
url: `${SITE_URL}/`,
|
||||
lastModified: new Date(),
|
||||
changeFrequency: "weekly",
|
||||
priority: 1
|
||||
},
|
||||
{
|
||||
url: `${SITE_URL}/posts`,
|
||||
lastModified: new Date(),
|
||||
changeFrequency: "daily",
|
||||
priority: 0.8
|
||||
},
|
||||
|
||||
...posts.map((item: Post) => ({
|
||||
url: `${SITE_URL}/posts/${item.id}`,
|
||||
lastModified: item.date,
|
||||
changeFrequency: "daily" as any,
|
||||
priority: 0.75
|
||||
}))
|
||||
];
|
||||
}
|
Reference in New Issue
Block a user