diff --git a/CHANGELOG-2.x.md b/CHANGELOG-2.x.md index a874228a857a..fd154b2b5680 100644 --- a/CHANGELOG-2.x.md +++ b/CHANGELOG-2.x.md @@ -20,6 +20,7 @@ function Home() { ([#1860](https://github.com/facebook/Docusaurus/issues/1860)) ### Bug Fixes +- Fix MDX `@theme/Heading` component. If there is no id, it should not create anchor link. - Fixed a bug in which if `themeConfig.algolia` is not defined, the custom searchbar won't appear. If you've swizzled Algolia `SearchBar` component before, please update your source code otherwise CSS might break. See [#1909](https://github.com/facebook/docusaurus/pull/1909/files) for reference. ```js diff --git a/packages/docusaurus-theme-classic/src/theme/Heading/index.js b/packages/docusaurus-theme-classic/src/theme/Heading/index.js index 789e637a2790..eb596f8fd587 100644 --- a/packages/docusaurus-theme-classic/src/theme/Heading/index.js +++ b/packages/docusaurus-theme-classic/src/theme/Heading/index.js @@ -11,14 +11,19 @@ import React from 'react'; import './styles.css'; -const Heading = Tag => ({id, ...props}) => ( - - - {props.children} - -); +const Heading = Tag => ({id, ...props}) => { + if (!id) { + return ; + } + return ( + + + {props.children} + + ); +}; export default Heading;