feat: 站点单页、时间线导入与行级 BBCode 短代码
首页右栏接入单页入口与公告置顶/全部页;Markdown 编辑器支持可视化时间线与 Git 导入;隐藏块改为 [hide]/[timeline] 命名闭合,并修复单页/公告 GORM 更新只改 updated_at 的问题。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -1,9 +1,12 @@
|
||||
import type { Metadata } from "next";
|
||||
import Link from "next/link";
|
||||
import { cookies } from "next/headers";
|
||||
import { notFound } from "next/navigation";
|
||||
import { ChevronRight, Megaphone } from "lucide-react";
|
||||
import { fetchAnnouncementDetail } from "@/lib/api";
|
||||
import { authCookieHeader } from "@/lib/cookies";
|
||||
import { formatDate } from "@/lib/format";
|
||||
import { getMeCached } from "@/lib/serverData";
|
||||
import MarkdownBody from "@/components/MarkdownBody";
|
||||
|
||||
interface PageProps {
|
||||
@@ -28,10 +31,15 @@ export async function generateMetadata({ params }: PageProps): Promise<Metadata>
|
||||
|
||||
export default async function AnnouncementPage({ params }: PageProps) {
|
||||
const { id } = await params;
|
||||
const data = await fetchAnnouncementDetail(id).catch(() => null);
|
||||
const cookie = authCookieHeader(await cookies());
|
||||
const [data, me] = await Promise.all([
|
||||
fetchAnnouncementDetail(id, cookie || undefined).catch(() => null),
|
||||
getMeCached(cookie || undefined),
|
||||
]);
|
||||
if (!data) notFound();
|
||||
|
||||
const a = data.announcement;
|
||||
const loginHref = `/login?redirect=${encodeURIComponent(`/announcement/${id}`)}`;
|
||||
const jsonLd = {
|
||||
"@context": "https://schema.org",
|
||||
"@type": "Article",
|
||||
@@ -55,12 +63,21 @@ export default async function AnnouncementPage({ params }: PageProps) {
|
||||
首页
|
||||
</Link>
|
||||
<ChevronRight size={13} />
|
||||
<span style={{ color: "var(--accent)" }}>站点公告</span>
|
||||
<Link href="/announcements" className="hover:text-[var(--accent)] transition-colors">
|
||||
站点公告
|
||||
</Link>
|
||||
<ChevronRight size={13} />
|
||||
<span className="truncate" style={{ color: "var(--accent)" }}>
|
||||
{a.title}
|
||||
</span>
|
||||
</nav>
|
||||
|
||||
<article className="panel p-6 sm:p-8">
|
||||
<div className="flex items-center justify-between gap-3 flex-wrap">
|
||||
<span className={`j13-anno-tag is-${a.tag_color}`}>{a.tag}</span>
|
||||
<div className="flex items-center gap-2 flex-wrap">
|
||||
{a.pinned ? <span className="badge-pin">置顶</span> : null}
|
||||
<span className={`j13-anno-tag is-${a.tag_color}`}>{a.tag}</span>
|
||||
</div>
|
||||
<time className="meta text-[12px] tabular-nums" dateTime={a.created_at}>
|
||||
{formatDate(a.created_at)}
|
||||
</time>
|
||||
@@ -77,7 +94,11 @@ export default async function AnnouncementPage({ params }: PageProps) {
|
||||
className="mt-5 pt-5"
|
||||
style={{ borderTop: "1px solid var(--line)" }}
|
||||
>
|
||||
<MarkdownBody content={a.content} />
|
||||
<MarkdownBody
|
||||
content={a.content}
|
||||
loggedIn={!!me.user}
|
||||
loginHref={loginHref}
|
||||
/>
|
||||
</div>
|
||||
</article>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user