feat: 优化博客内容标题 描述

This commit is contained in:
2025-12-20 23:09:35 +08:00
parent 4d30605872
commit d7c84ea0ce

View File

@@ -14,6 +14,7 @@ import { Skeleton } from "@/components/ui/skeleton";
import { BlogComments } from "./components/BlogComments";
import Image from "next/image";
import { BlogAPI } from "@/lib/api/client";
import { useEffect } from "react";
export default function Blog() {
const params = useParams();
@@ -34,6 +35,16 @@ export default function Blog() {
() => BlogAPI.getBlog(id, password || undefined),
)
useEffect(() => {
if (data) {
document.title = `${data.title} - 特恩的日志`;
const metaDescription = document.querySelector('meta[name="description"]');
if (metaDescription) {
metaDescription.setAttribute("content", data.description);
}
}
}, [data]);
return (
<div className="w-full overflow-x-hidden">
<div className="max-w-200 mx-auto px-5 overflow-x-hidden mb-10">