Skip to content

Commit 1a36469

Browse files
author
Dimitri POSTOLOV
authoredJan 28, 2024
add frontMatter.sidebarTitle only if frontMatter.title is empty (#2656)
* add `frontMatter.sidebarTitle` only if `frontMatter.title` is empty * fallback.display '*'
1 parent f64c70e commit 1a36469

File tree

4 files changed

+10
-5
lines changed

4 files changed

+10
-5
lines changed
 

‎.changeset/fast-readers-sleep.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'nextra': patch
3+
---
4+
5+
add `frontMatter.sidebarTitle` only if `frontMatter.title` is empty

‎docs/next-env.d.ts

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/// <reference types="next" />
22
/// <reference types="next/image-types/global" />
3+
/// <reference types="next/navigation-types/compat/navigation" />
34

45
// NOTE: This file should not be edited
56
// see https://nextjs.org/docs/basic-features/typescript for more information.

‎packages/nextra/src/client/normalize-pages.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ function extendMeta(
4242
return {
4343
...fallback,
4444
..._meta,
45-
display: metadata.display || _meta.display,
45+
display: metadata.display || _meta.display || fallback.display,
4646
theme
4747
}
4848
}

‎packages/nextra/src/server/page-map.ts

+3-4
Original file line numberDiff line numberDiff line change
@@ -125,16 +125,15 @@ async function collectFiles({
125125
// } else {
126126
const content = await fs.readFile(filePath, 'utf8')
127127
const { data } = grayMatter(content)
128-
const frontMatter = {
129-
sidebarTitle: pageTitleFromFilename(name),
130-
...data
128+
if (!data.title) {
129+
data.sidebarTitle = pageTitleFromFilename(name)
131130
}
132131
// }
133132

134133
return {
135134
name,
136135
route: fileRoute,
137-
frontMatter
136+
frontMatter: data
138137
}
139138
}
140139

0 commit comments

Comments
 (0)
Please sign in to comment.