shuding / nextra

Simple, powerful and flexible site generation framework with everything you love from Next.js.
https://nextra.site
MIT License
11.78k stars 1.28k forks source link

Integrate Pagefind for better search #2524

Open wottpal opened 12 months ago

wottpal commented 12 months ago

See: https://pagefind.app/

They just released v1 and it could give the Nextra search superpowers and removes complexity from its chore 🤔

dimaMachina commented 11 months ago

Looks awesome, also seems it can fix an issue of searching data from remote content and data fetched from getStaticProps since the content is indexed from the directory of static HTML files (already built and not from raw md/mdx)

Aruelius commented 9 months ago

Looks awesome, also seems it can fix an issue of searching data from remote content and data fetched from getStaticProps since the content is indexed from the directory of static HTML files (already built and not from raw md/mdx)

It seems not support Chinese or other specialized languages for now.

https://pagefind.app/docs/multilingual/

Currently when indexing, Pagefind does not support stemming for specialized languages, but does support segmentation for words not separated by whitespace.

Pagefind does not yet support segmentation of the search query, so searching in the browser requires that words in the search query are separated by whitespace.

In practice, this means that on a page tagged as a zh- language, 每个月都 will be indexed as the words 每个, , and .

When searching in the browser, searching for 每个, , or individually will work. Additionally, searching 每個 月 都 will return results containing each word in any order, and searching "每个 月 都" in quotes will match 每个月都 exactly.

Searching for 每个月都 will return zero results, as Pagefind is not able to segment it into words in the browser. Work to improve this is underway and will hopefully remove this limitation in the future.