@easyops-cn/docusaurus-search-local 0.41.0 → 0.41.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,13 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
4
 
5
+ ## [0.41.1](https://github.com/easyops-cn/docusaurus-search-local/compare/v0.41.0...v0.41.1) (2024-06-04)
6
+
7
+
8
+ ### Bug Fixes
9
+
10
+ * bump version only for handling hash link with url path, closes [#408](https://github.com/easyops-cn/docusaurus-search-local/issues/408) via [#410](https://github.com/easyops-cn/docusaurus-search-local/issues/410) ([9d76b81](https://github.com/easyops-cn/docusaurus-search-local/commit/9d76b81be5ac3dad8b32ee66ac24004a1724df16))
11
+
5
12
  ## [0.41.0](https://github.com/easyops-cn/docusaurus-search-local/compare/v0.40.1...v0.41.0) (2024-05-23)
6
13
 
7
14
 
package/README.md CHANGED
@@ -1 +1 @@
1
- See https://github.com/easyops-cn/docusaurus-search-local#readme.
1
+ See https://github.com/easyops-cn/docusaurus-search-local#readme
@@ -61,22 +61,29 @@ function scanDocuments(DocInfoWithFilePathList, config) {
61
61
  });
62
62
  }
63
63
  for (const section of sections) {
64
+ const trimmedHash = getTrimmedHash(section.hash, url);
64
65
  if (section.title !== pageTitle) {
66
+ if (trimmedHash === false) {
67
+ continue;
68
+ }
65
69
  headingDocuments.push({
66
70
  i: getNextDocId(),
67
71
  t: section.title,
68
72
  u: url,
69
- h: section.hash,
73
+ h: trimmedHash,
70
74
  p: titleId,
71
75
  });
72
76
  }
73
77
  if (section.content) {
78
+ if (trimmedHash === false) {
79
+ continue;
80
+ }
74
81
  contentDocuments.push({
75
82
  i: getNextDocId(),
76
83
  t: section.content,
77
84
  s: section.title || pageTitle,
78
85
  u: url,
79
- h: section.hash,
86
+ h: trimmedHash,
80
87
  p: titleId,
81
88
  });
82
89
  }
@@ -86,3 +93,15 @@ function scanDocuments(DocInfoWithFilePathList, config) {
86
93
  });
87
94
  }
88
95
  exports.scanDocuments = scanDocuments;
96
+ function getTrimmedHash(hash, url) {
97
+ if (hash && !hash.startsWith("#") && hash.includes("#")) {
98
+ // The hash link may contains URL path, we need to remove it.
99
+ if (hash.startsWith(url) && hash[url.length] === "#") {
100
+ return hash.slice(url.length);
101
+ }
102
+ // If the hash doesn't start with the URL, it's likely an external link.
103
+ // Don't know this will happen or not, but just in case.
104
+ return false;
105
+ }
106
+ return hash;
107
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@easyops-cn/docusaurus-search-local",
3
- "version": "0.41.0",
3
+ "version": "0.41.1",
4
4
  "description": "An offline/local search plugin for Docusaurus v3",
5
5
  "repository": "https://github.com/easyops-cn/docusaurus-search-local",
6
6
  "homepage": "https://github.com/easyops-cn/docusaurus-search-local",