Skip to content

Commit 6ecf6a1

Browse files
authored
Use first heading for page title instead of frontmatter field (#329)
1 parent 82fc597 commit 6ecf6a1

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

src/components/docs-page.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import getTableOfContents from "../utils/get-table-of-contents"
2727
import hasBreadcrumbs from "../utils/has-breadcrumbs"
2828

2929
const DocsPage = ({ pageContext: page, children, location }) => {
30-
const title = getPageTitle(page)
30+
const title = getPageTitle(page, true)
3131
const pageType = getPageType(page)
3232
const tableOfContents = getTableOfContents(page)
3333

src/utils/get-page-title.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
1-
export default ({ frontmatter, headings }) => {
1+
export default ({ frontmatter, headings }, useHeading=false) => {
22
if (!frontmatter) return "Not found"
33

4+
if (useHeading) {
5+
return (headings.length && headings[0].value) || frontmatter.title
6+
}
7+
48
return frontmatter.title || (headings.length && headings[0].value)
59
}

0 commit comments

Comments
 (0)