File tree Expand file tree Collapse file tree 2 files changed +10
-2
lines changed Expand file tree Collapse file tree 2 files changed +10
-2
lines changed Original file line number Diff line number Diff line change @@ -96,9 +96,10 @@ export function transformSearchItems(items, options) {
9696 // For English, baseUrl is /docs/, so we want /tutorial
9797
9898 try {
99- // Parse the URL to safely extract the pathname
99+ // Parse the URL to safely extract the pathname and hash
100100 const urlObj = new URL ( url ) ;
101101 const pathname = urlObj . pathname ;
102+ const hash = urlObj . hash ;
102103
103104 if ( currentLocale !== 'en' ) {
104105 // Remove /docs/{locale} prefix, keeping the leading slash
@@ -119,6 +120,9 @@ export function transformSearchItems(items, options) {
119120 url = pathname ;
120121 }
121122 }
123+
124+ // Append the hash back to the URL
125+ url += hash ;
122126 } catch ( e ) {
123127 // If URL parsing fails, assume it's already a relative path
124128 // and use the original transformation logic as fallback
Original file line number Diff line number Diff line change @@ -215,11 +215,12 @@ function SearchPageContent() {
215215 // For non-English locales, the baseUrl is /docs/{locale}/
216216 // Algolia returns URLs like /docs/{locale}/path
217217 // We need to make them relative: path (without leading slash)
218- // Parse the URL to safely extract the pathname
218+ // Parse the URL to safely extract the pathname and hash
219219 let processedUrl = url ;
220220 try {
221221 const urlObj = new URL ( url ) ;
222222 const pathname = urlObj . pathname ;
223+ const hash = urlObj . hash ;
223224
224225 if ( currentLocale !== 'en' ) {
225226 const prefix = `/docs/${ currentLocale } ` ;
@@ -236,6 +237,9 @@ function SearchPageContent() {
236237 processedUrl = pathname ;
237238 }
238239 }
240+
241+ // Append the hash back to the URL
242+ processedUrl += hash ;
239243 } catch ( e ) {
240244 // Fallback to original logic if parsing fails
241245 if ( currentLocale !== 'en' ) {
You can’t perform that action at this time.
0 commit comments