Currently, I am in search of a suitable lunr search implementation for my MD (Markdown) documents spread throughout my React/NextJS website. Our website contains a plethora of Markdown docs within both blog and regular "docs" sections, necessitating a robust search functionality for users to easily navigate through topics. Although our MDs are dynamically rendered via NextJS, we require a server-side search capability to enhance security measures by restricting user access solely to result retrieval, rather than enabling direct client/browser side page searches.
- To accommodate this requirement, our plan involves building the lunr search index during site construction (which should be relatively straightforward given the static nature of our content).
- We intend to utilize API endpoint routing for executing server-side searches on the created search index.
- For user interaction, we will leverage nextJS clientside capabilities to interface with the API endpoint for initiating searches and returning results.
While I possess a decent understanding of lunr operations, including index construction, API router setup, and final result rendering, my primary challenge lies in integrating the index creation process with the actual searchable text derived from MD documents. This raises concerns about omitting non-searchable meta information present in MD files or any irrelevant HTML tags within the corresponding rendered HTML versions. Consequently, I'm on the lookout for an existing NPM package that addresses these specific complexities.
Furthermore, I'm interested in exploring methods to refine the search index structure to generate visually appealing search results featuring brief previews displaying relevant sentences alongside each match, instead of just listing page titles.