Skip to content

Commit

Permalink
fix(v1): Fix page title render issue when referred by search result
Browse files Browse the repository at this point in the history
When Algolia DocSearch query finds a match for a page's title, it attempts to generate
a permalink. Because the page title element (`h1`) does not have an `id`, Algolia
generates uses the `id` from closes parent element. Because of this, the page title
scrolls to a position that is slightly overlayed by the fixed top navigation bar.

This fix sets an `id` for the page title so that the search result is able to generate
a more accurate permalink.
  • Loading branch information
parkas2018 committed Oct 22, 2019
1 parent b65c1b2 commit 991cff1
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion packages/docusaurus-1.x/lib/core/Doc.js
Expand Up @@ -238,7 +238,9 @@ class Doc extends React.Component {
<header className="postHeader">
{editLink}
{!this.props.hideTitle && (
<h1 className="postHeaderTitle">{this.props.title}</h1>
<h1 id="__docusaurus" className="postHeaderTitle">
{this.props.title}
</h1>
)}
</header>
<article>
Expand Down

0 comments on commit 991cff1

Please sign in to comment.