z3by / vuepress-plugin-flexsearch

Next-Generation full text search library for Vuepress
MIT License
41 stars 16 forks source link

link to the anchor of keyword #4

Closed taojunnan closed 1 year ago

taojunnan commented 4 years ago

If I search and get some result and click the result, I only can link to keyword page , how can I link to the anchor of keyword

z3by commented 4 years ago

Hey @taojunnan could you please give me the steps so I can reproduce this problem here? thanks.

taojunnan commented 4 years ago

Hello @z3by I have this page image If I search 123, I want to link to http://127.0.0.1:8080/guide/#second, not http://127.0.0.1:8080/guide/

z3by commented 4 years ago

I guess this is because the second is in the last section of the page.

taojunnan commented 4 years ago

@z3by sorry, I'm afraid not, I tested if hava 'third' or search abc, same problem.

z3by commented 4 years ago

Sorry! I miss understood the problem here, in fact this feature does not exist yet, if you can submit a PR that would be great!

taojunnan commented 4 years ago

@z3by I think this is a necessary feature, I'm focus on this but hava no idea yet.

husarcik commented 4 years ago

@taojunnan Have you made in progress on adding anchors? It appears that engines like Algolia return a anchor that is associated with the paragraph of text that was found. See below for some examples. I believe we'd have to parse the page and store it in a similar manner for Flexsearch. There is a gridsome plugin that does this I believe (https://github.com/thetre97/gridsome-plugin-flexsearch). I haven't looked into how in-depth the indexing code is.

EDIT: I'll try to make some progress if it hasn't been made yet as I need a better search feature without using Algolia.

image

image