easyops-cn / docusaurus-search-local

Offline/local search for Docusaurus v2/v3
https://easyops-cn.github.io/docusaurus-search-local/
MIT License
712 stars 90 forks source link

Invalid search result url with docusaurus 3.4.0 #408

Closed TimKolberger closed 5 months ago

TimKolberger commented 5 months ago

Starting with docusaurus@3.4.0 and docusaurus-search-local@0.41.0 the search results point to an invalid url.

Seems like an issue with the baseUrl.

Reproduction

  1. Go to https://timkolberger.github.io/docusaurus-plugin-structurizr
  2. Search for "CI Environments" and select the first result
  3. 404 Page

https://github.com/easyops-cn/docusaurus-search-local/assets/16899513/0ef1f5da-bc49-449f-8478-6784d662e83d

Source: https://github.com/TimKolberger/docusaurus-plugin-structurizr/tree/main/apps/docs

weareoutman commented 5 months ago

I found you're using actions/configure-pages to set baseUrl which has output.base_path not ending with / [1], as Docusaurus expected (at least our search plugin expects it).

Can you manually append / for baseUrl in https://github.com/TimKolberger/docusaurus-plugin-structurizr/blob/c6d224877bf2c5f389e0023825d7c565ed49d4fd/apps/docs/docusaurus.config.mts#L15 ?

[1] https://github.com/actions/configure-pages/blob/e1bedb377708461b49c882870df192bdec04b996/src/output-pages-base-url.test.js#L40

TimKolberger commented 5 months ago

Thanks for the fast reply!

I added a trailing slash like you suggested, but the issue persists.

Commit https://github.com/TimKolberger/docusaurus-plugin-structurizr/commit/16146d5701be9704ea4b74677b1f9549562f5c8d

TimKolberger commented 5 months ago

I encountered this issue on multiple docusaurus sites at work. The reproduction is just the only public one. All docs deployed on GitLab Pages, GitHub Pages and nginx Deployments have the same issue.

Since this only occurred when renovate merged the docusaurus 3.4.0 updates, I think the issue is buried in this plugin code, or somewhere in the docusaurus router code (the release touched some routing code in docusaurus itself). But I could not pinpoint it yet.

anonid-top commented 5 months ago

@TimKolberger @weareoutman @easyops-eve I already fixed this, how i can push my code to your repo? Thank you!

TimKolberger commented 5 months ago

@anonid-top looks like you created a fork of this repo (not mine). See this GitHub docs on how to create a PR from a fork: https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/creating-a-pull-request-from-a-fork

anonid-top commented 5 months ago

@TimKolberger I already make Pull Request by guide as this link, please help me check it is valid or not I fork to my repo because tomorow i don't have permission and i don't know how to commit my change to your repo. Sorry for my bad knowledge

weareoutman commented 5 months ago

@TimKolberger Try 0.41.1

Thanks to @anonid-top for helping to address the issue.

TimKolberger commented 5 months ago

works as expected. Thank you!