mirror of
				https://github.com/zadam/trilium.git
				synced 2025-10-31 11:39:01 +01:00 
			
		
		
		
	fix(export/share): navigation in search not working
This commit is contained in:
		
							parent
							
								
									cf8089b07f
								
							
						
					
					
						commit
						08e66c18e7
					
				| @ -14,7 +14,7 @@ import becca from "../../../becca/becca"; | |||||||
| const shareThemeAssetDir = getShareThemeAssetDir(); | const shareThemeAssetDir = getShareThemeAssetDir(); | ||||||
| 
 | 
 | ||||||
| interface SearchIndexEntry { | interface SearchIndexEntry { | ||||||
|     id: string; |     id: string | null; | ||||||
|     title: string; |     title: string; | ||||||
|     content: string; |     content: string; | ||||||
|     path: string; |     path: string; | ||||||
| @ -94,6 +94,11 @@ export default class ShareThemeExportProvider extends ZipExportProvider { | |||||||
|         this.#saveIndex(rootMeta); |         this.#saveIndex(rootMeta); | ||||||
| 
 | 
 | ||||||
|         // Search index
 |         // Search index
 | ||||||
|  |         for (const item of this.searchIndex.values()) { | ||||||
|  |             if (!item.id) continue; | ||||||
|  |             item.id = this.getNoteTargetUrl(item.id, rootMeta); | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|         this.archive.append(JSON.stringify(Array.from(this.searchIndex.values()), null, 4), { name: "search-index.json" }); |         this.archive.append(JSON.stringify(Array.from(this.searchIndex.values()), null, 4), { name: "search-index.json" }); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -70,12 +70,15 @@ async function fetchResults(query: string): Promise<SearchResults> { | |||||||
|             keys: [ |             keys: [ | ||||||
|                 "title", |                 "title", | ||||||
|                 "content" |                 "content" | ||||||
|             ] |             ], | ||||||
|  |             includeScore: true | ||||||
|         }); |         }); | ||||||
| 
 | 
 | ||||||
|         const results = fuse.search<SearchResult>(query); |         const results = fuse.search<SearchResult>(query, { limit: 5 }); | ||||||
|  |         console.debug("Search results:", results); | ||||||
|         const processedResults = results.map(({ item, score }) => ({ |         const processedResults = results.map(({ item, score }) => ({ | ||||||
|             ...item, |             ...item, | ||||||
|  |             id: rootUrl + "/" + item.id, | ||||||
|             score |             score | ||||||
|         })); |         })); | ||||||
|         return { results: processedResults }; |         return { results: processedResults }; | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Elian Doran
						Elian Doran