Chore: 更新框架到 React Router 7

修复迁移到 Tailwind 4 之后的样式差异
修复 404 页面的异常并调整样式
优化分页器组件的无障碍化,Span 标签替换成 Button
This commit is contained in:
2026-05-20 16:07:04 +08:00
parent 0a9ae15732
commit 13a09d6995
34 changed files with 2076 additions and 6941 deletions
+41
View File
@@ -0,0 +1,41 @@
import Article from "~/components/common/article";
import { siteTitle } from "~/utils";
import type { Route } from "./+types/page";
export function meta({ loaderData }: Route.MetaArgs) {
return [
{ title: loaderData ? siteTitle(loaderData.data.title) : "404" },
{ name: "description", content: loaderData?.data.desc },
];
}
export async function loader({ params }: Route.LoaderArgs) {
const slug = params["*"];
const page = (await fetch(
`https://paul.ren/api/page/get?slug=${slug}&html`,
).then((res) => res.json())) as API.Response<API.Page.IPageData>;
if (page.status === "Failed") {
throw new Response("Not Found", { status: 404 });
}
return page;
}
export default function DynamicPage({ loaderData }: Route.ComponentProps) {
const page = loaderData;
return (
<main className="px-2 py-24 max-w-3xl mx-auto">
<section className="mb-12">
<h1 className="text-center text-5xl/tight md:text-7xl/tight mb-4">{page.data.title}</h1>
<p className="text-center opacity-60">{page.data.desc}</p>
</section>
<section className="p-5 bg-white rounded-xl border-b-4 border-b-cyan-200">
<Article html={page.data.content} />
</section>
</main>
);
}