Unverified Commit cb03a799 authored by Abe Chen's avatar Abe Chen Committed by GitHub

fix: <title> problem in example/blog-starter (#46122)



## Bug

Relate discussions: #38256

Occur in blog starter template. 

```
Warning: A title element received an array with more than 1 element as children. In browsers title Elements can only have Text Nodes as children. If the children being rendered output more than a single text node in aggregate the browser will display markup and comments as text in the title and hydration will likely fail and fall back to client rendering
    at title
    at head
    at Head (webpack-internal:///./node_modules/.pnpm/next@13.1.6_biqbaboplfbrettd7655fr4n2y/node_modules/next/dist/pages/_document.js:279:1)
    at html
    at Html (webpack-internal:///./node_modules/.pnpm/next@13.1.6_biqbaboplfbrettd7655fr4n2y/node_modules/next/dist/pages/_document.js:678:104)
    at Document
```
parent 08bb2698
...@@ -20,6 +20,7 @@ type Props = { ...@@ -20,6 +20,7 @@ type Props = {
export default function Post({ post, morePosts, preview }: Props) { export default function Post({ post, morePosts, preview }: Props) {
const router = useRouter() const router = useRouter()
const title = `${post.title} | Next.js Blog Example with ${CMS_NAME}`
if (!router.isFallback && !post?.slug) { if (!router.isFallback && !post?.slug) {
return <ErrorPage statusCode={404} /> return <ErrorPage statusCode={404} />
} }
...@@ -33,9 +34,7 @@ export default function Post({ post, morePosts, preview }: Props) { ...@@ -33,9 +34,7 @@ export default function Post({ post, morePosts, preview }: Props) {
<> <>
<article className="mb-32"> <article className="mb-32">
<Head> <Head>
<title> <title>{title}</title>
{post.title} | Next.js Blog Example with {CMS_NAME}
</title>
<meta property="og:image" content={post.ogImage.url} /> <meta property="og:image" content={post.ogImage.url} />
</Head> </Head>
<PostHeader <PostHeader
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment