feat: 优化博客内容标题 描述
This commit is contained in:
@@ -14,6 +14,7 @@ import { Skeleton } from "@/components/ui/skeleton";
|
|||||||
import { BlogComments } from "./components/BlogComments";
|
import { BlogComments } from "./components/BlogComments";
|
||||||
import Image from "next/image";
|
import Image from "next/image";
|
||||||
import { BlogAPI } from "@/lib/api/client";
|
import { BlogAPI } from "@/lib/api/client";
|
||||||
|
import { useEffect } from "react";
|
||||||
|
|
||||||
export default function Blog() {
|
export default function Blog() {
|
||||||
const params = useParams();
|
const params = useParams();
|
||||||
@@ -34,6 +35,16 @@ export default function Blog() {
|
|||||||
() => BlogAPI.getBlog(id, password || undefined),
|
() => 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 (
|
return (
|
||||||
<div className="w-full overflow-x-hidden">
|
<div className="w-full overflow-x-hidden">
|
||||||
<div className="max-w-200 mx-auto px-5 overflow-x-hidden mb-10">
|
<div className="max-w-200 mx-auto px-5 overflow-x-hidden mb-10">
|
||||||
|
|||||||
Reference in New Issue
Block a user