Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
N
next.js
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Alex
next.js
Commits
49b3a7a0
Commit
49b3a7a0
authored
Apr 03, 2026
by
Jimmy Lai
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor: move definesTemplate to module scope with correct type
parent
573cea15
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
2 deletions
+9
-2
resolve-metadata.ts
packages/next/src/lib/metadata/resolve-metadata.ts
+9
-2
No files found.
packages/next/src/lib/metadata/resolve-metadata.ts
View file @
49b3a7a0
...
@@ -18,6 +18,7 @@ import type {
...
@@ -18,6 +18,7 @@ import type {
AbsoluteTemplateString
,
AbsoluteTemplateString
,
IconDescriptor
,
IconDescriptor
,
ResolvedIcons
,
ResolvedIcons
,
TemplateString
,
}
from
'./types/metadata-types'
}
from
'./types/metadata-types'
import
type
{
ParsedUrlQuery
}
from
'querystring'
import
type
{
ParsedUrlQuery
}
from
'querystring'
import
type
{
StaticMetadata
}
from
'./types/icons'
import
type
{
StaticMetadata
}
from
'./types/icons'
...
@@ -1135,6 +1136,14 @@ function freezeInDev<T extends object>(obj: T): T {
...
@@ -1135,6 +1136,14 @@ function freezeInDev<T extends object>(obj: T): T {
return
obj
return
obj
}
}
/**
* Returns true when the given title value is an object that explicitly defines
* a `template` key (i.e. it is a TemplateString, not a plain string).
*/
const
definesTemplate
=
(
title
:
string
|
TemplateString
|
null
|
undefined
):
boolean
=>
title
!=
null
&&
typeof
title
!==
'string'
&&
'template'
in
title
export
async
function
accumulateMetadata
(
export
async
function
accumulateMetadata
(
route
:
string
,
route
:
string
,
metadataItems
:
MetadataItems
,
metadataItems
:
MetadataItems
,
...
@@ -1213,8 +1222,6 @@ export async function accumulateMetadata(
...
@@ -1213,8 +1222,6 @@ export async function accumulateMetadata(
// that only set a plain string title must not reset the parent layout's
// that only set a plain string title must not reset the parent layout's
// template to null, because sibling parallel-route pages still need that
// template to null, because sibling parallel-route pages still need that
// template applied (see #77888).
// template applied (see #77888).
const
definesTemplate
=
(
title
:
Metadata
[
'title'
]
|
undefined
):
boolean
=>
title
!=
null
&&
typeof
title
!==
'string'
&&
'template'
in
title
titleTemplates
=
{
titleTemplates
=
{
title
:
definesTemplate
(
metadata
?.
title
)
title
:
definesTemplate
(
metadata
?.
title
)
?
resolvedMetadata
.
title
?.
template
||
null
?
resolvedMetadata
.
title
?.
template
||
null
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment