cmfcmf / docusaurus-search-local

Offline / Local Search for Docusaurus v2. Try it live at:
https://cmfcmf.github.io/OpenWeatherMap-PHP-API/
MIT License
437 stars 67 forks source link

Page title missing in search index #146

Closed kleinschmidtj closed 1 year ago

kleinschmidtj commented 1 year ago

Please describe the bug you are seeing

We are using this plugin on markdown files that do not have the title in the front matter. This results in this package using an empty string for the page title in the search index. When users type in a common subheading in the search ("Links"), for example, they're not able to differentiate which page this heading appears on.

image

Since front matter is optional in docusaurus, this package should support page titles as the first heading.

How can we best reproduce the bug?

  1. For a markdown file in a docusaurus project, add the title directly in the markdown body like so: # Page Title Here
  2. Delete any title field included in the front matter from the markdown file. (e.g. delete this: title: Page Title Here)
  3. Run yarn build
  4. Find the search index and look for the entry. The pageTitle field will be blank. {"id":1,"pageTitle":"" ... }

Which version of Docusaurus and @cmfcmf/docusaurus-search-local are you using?

├─ @cmfcmf/docusaurus-search-local@0.11.0 ├─ @docusaurus/core@2.0.0-rc.1 ├─ @docusaurus/cssnano-preset@2.0.0-rc.1 ├─ @docusaurus/logger@2.0.0-rc.1 ├─ @docusaurus/mdx-loader@2.0.0-rc.1 ├─ @docusaurus/module-type-aliases@2.0.0-rc.1 ├─ @docusaurus/plugin-client-redirects@2.0.0-rc.1 ├─ @docusaurus/plugin-content-blog@2.0.0-rc.1 ├─ @docusaurus/plugin-content-docs@2.0.0-rc.1 ├─ @docusaurus/plugin-content-pages@2.0.0-rc.1 ├─ @docusaurus/plugin-debug@2.0.0-rc.1 ├─ @docusaurus/plugin-google-analytics@2.0.0-rc.1 ├─ @docusaurus/plugin-google-gtag@2.0.0-rc.1 ├─ @docusaurus/plugin-sitemap@2.0.0-rc.1 ├─ @docusaurus/preset-classic@2.0.0-rc.1 ├─ @docusaurus/react-loadable@5.5.2 ├─ @docusaurus/theme-classic@2.0.0-rc.1 ├─ @docusaurus/theme-common@2.0.0-rc.1 ├─ @docusaurus/theme-search-algolia@2.0.0-rc.1 ├─ @docusaurus/theme-translations@2.0.0-rc.1 ├─ @docusaurus/types@2.0.0-rc.1 ├─ @docusaurus/utils-common@2.0.0-rc.1 ├─ @docusaurus/utils-validation@2.0.0-rc.1 └─ @docusaurus/utils@2.0.0-rc.1

Which Node.js version are you using?

v16.16.0

Which theme are you using?

No, I am using a custom theme

How does your plugin config look like?

No response

Additional context

No response