Open h3nkk44 opened 2 weeks ago
it is duplicating somehow
Seeing same behaviour in previously working docs
I see the same problem for my website :(
I have the same problem since a few weeks.
I wonder how that could be related to an incompatibility between Node, Docusaurus and CMFCMFSearchLocal. In my package-lock.json file I have the following :
{ "name": "myDoc", "version": "0.0.0", "dependencies": { "@cmfcmf/docusaurus-search-local": "^0.11.0", "@docusaurus/core": "^3.4.0", "@docusaurus/preset-classic": "^3.4.0", "@docusaurus/theme-mermaid": "^3.4.0", "@mdx-js/react": "^3.0.0", "clsx": "^1.2.1", "prism-react-renderer": "^1.3.5", "react": "^18.2.0", "react-dom": "^18.2.0", "reveal.js": "^5.0.0", "swagger-ui-react": "^4.18.1" }, "devDependencies": { "@docusaurus/module-type-aliases": "^3.4.0", "@tsconfig/docusaurus": "^2.0.2" }, "engines": { "node": ">=16.14" } }
CMF and React are locked, but not Node, so there might be something happening here ?
This https://github.com/cmfcmf/docusaurus-search-local/pull/216 should resolve, can you test applying patch?
diff --git a/node_modules/@cmfcmf/docusaurus-search-local/lib/server/parse.js b/node_modules/@cmfcmf/docusaurus-search-local/lib/server/parse.js
index bf41fa2..50bf040 100644
--- a/node_modules/@cmfcmf/docusaurus-search-local/lib/server/parse.js
+++ b/node_modules/@cmfcmf/docusaurus-search-local/lib/server/parse.js
@@ -109,7 +109,9 @@ function html2text(html, type, url = "?") {
// <a class="hash-link" href="#first-header" title="Direct link to heading">#</a>
.not("a[aria-hidden=true], a.hash-link")
.text();
- const hash = $(heading).find("a.hash-link").attr("href") || "";
+ const linkHash = $(heading).find("a.hash-link").attr("href") || ""
+ const [, hashPart] = linkHash.split("#")
+ const hash = hashPart ? `#${hashPart}` : "";
let $sectionElements;
if ($(heading).parents(".markdown").length === 0) {
// $(heading) is the page title
1 - copy patch above
2 - In the root of your docsaurus project run command: pbpaste | git apply
or use patch-package
Este problema #216 deve ser resolvido. Você pode testar a aplicação do patch?
diff --git a/node_modules/@cmfcmf/docusaurus-search-local/lib/server/parse.js b/node_modules/@cmfcmf/docusaurus-search-local/lib/server/parse.js index bf41fa2..50bf040 100644 --- a/node_modules/@cmfcmf/docusaurus-search-local/lib/server/parse.js +++ b/node_modules/@cmfcmf/docusaurus-search-local/lib/server/parse.js @@ -109,7 +109,9 @@ function html2text(html, type, url = "?") { // <a class="hash-link" href="#first-header" title="Direct link to heading">#</a> .not("a[aria-hidden=true], a.hash-link") .text(); - const hash = $(heading).find("a.hash-link").attr("href") || ""; + const linkHash = $(heading).find("a.hash-link").attr("href") || "" + const [, hashPart] = linkHash.split("#") + const hash = hashPart ? `#${hashPart}` : ""; let $sectionElements; if ($(heading).parents(".markdown").length === 0) { // $(heading) is the page title
como aplicar o patch?
1 - copie o patch acima 2 - Na raiz do seu projeto docsaurus execute o comando:
pbpaste | git apply
ou use patch-package
I just tried @fxamauri solution and it worked, thanks @fxamauri
Please describe the bug you are seeing
Hi,
I installed this plugin to an empty docusaurus project and run all the command without any customization or modifications. When i build and serve the project the search works and shows results fine, but the path where the result is pointing is not working correct.
I dont know if this is a undocumentened config or bug.
As you can see from the image the path is duplicating after the docs part.
"https://symmetrical-space-doodle-x5rrrgx9pq4hv74v-3000.app.github.dev/docs/tutorial-extras/translate-your-site/docs/tutorial-extras/translate-your-site#start-your-localized-site"
When it should be:
"https://symmetrical-space-doodle-x5rrrgx9pq4hv74v-3000.app.github.dev/docs/tutorial-extras/translate-your-site#start-your-localized-site"
Thanks!
How can we best reproduce the bug?
Which version of Docusaurus and @cmfcmf/docusaurus-search-local are you using?
Latest that are available
Which Node.js version are you using?
22.3.0
Which theme are you using?
Yes, I am using @docusaurus/theme-classic
How does your plugin config look like?
Default config
Additional context
No response