nuxt-themes / docus

Write beautiful documentations with Nuxt and Markdown.
https://docus.dev
MIT License
1.59k stars 156 forks source link

[Integrations] Internal Search #682

Open justindasilva opened 1 year ago

justindasilva commented 1 year ago

I think it would be a cool feature to support an internal search in Docus. One that didn't rely on Algolia.

Does Docus support module development?

I'm imagining being able to set search: true in the App Config for Docus and that would automatically throw a search box at the top of the site. Some process would be needed to index all the docs under /content and make it keyword searchable though.

codebykenny commented 1 year ago

https://github.com/cmfcmf/docusaurus-search-local

Here is a Docusaurus equivalent of a local search we might draw inspiration from

atinux commented 1 year ago

Indeed, as easy start we can have an endpoint that leverage both navigation + parsing all documents from it to get the titles.

Then we could also pre-render the endpoint and have a command palette to easily navigate in it (ex: https://github.com/xiaoluoboding/vue-command-palette)

Tahul commented 1 year ago

I suggest moving this issue to Elements, as these components could be used in any theme.

Tahul commented 1 year ago

WDYT @Atinux

atinux commented 1 year ago

I think we can first bootstrap in Docus before moving the search endpoint into Nuxt Content.

I believe this should be part of Nuxt Content, not elements in long term.

Elements are made for components in Markdown.

Hecatron commented 1 year ago

This is something I've been interested in myself for my own blog.
Since I prefer a static file over algolia for a small amount of content.

FuseJS seems to be the more popular one at the moment for local searches

I think what you'd need is a seperate nuxt module

For the search control, something similar to this but for use by fusejs but with a bit of theming for docus

I suspect the only part that would be docus specific would be a themed control, with the rest of it being a nuxt module for use with the content module.

Hecatron commented 1 year ago

Just to add for static sites (SSG) lyrasearch seems quite promising

The parsedoc-plugin might allow it to be used just by scanning the markdown

leeoniya commented 1 year ago

i've spent a lot of time comparing quite a few here, though it's skewed towards searching huge lists of phrases/terms/names rather than full document content (with stemming, stop words, word frequency, etc) like FlexSearch, Lyra, or Algolia.

https://github.com/leeoniya/uFuzzy#a-biased-appraisal-of-similar-work

jaonoctus commented 1 year ago

I'm offering a bounty of 4,000,000 sats (0.04 BTC) for this one 😄

atinux commented 1 year ago

We will add native search in Content very soon.

Tahul commented 1 year ago

Hey :) another bump there as we discussed this feature again recently;

As a reference, VitePress recently implemented local search using minisearch, and Volta docs are also using minisearch as the engine for local search in their docs!

I'm sure we could work on something that does the same for Docus, then maybe backport it as an extension for all themes/Nuxt Content projects!

Tahul commented 1 year ago

Linked to nuxt-themes/elements#158

Tahul commented 1 year ago

From @otabekoff in #771 :

Does an offline search input feature exist? Or should it be implemented? I've seen that many of SSGs or Static documentation generators have this function. One example is Vuepress. Let's say I'm making an app that works offline using PWA or real app with Docus. What the user does to search? Uses page by page manual checking? In my opinion it is the most hardest way to do it.
You can look up the Vuepress repo for the logic. Both Docus and Vuepress uses Vue(or Nuxt).
EDIT: What about using DocSearch? I already know I can use Algolia. But it needs internet.
Tahul commented 1 year ago

From @marvin-j97 in #771 :

I'm guessing this is a duplicate of #682 [Feature Request] Internal Search?
Nextra uses Flexsearch.
For Docusaurus, there are some plugins that use Lunr.
Edit: Vitepress now supports Offline Search using minisearch
Hecatron commented 1 year ago

I've been trying to write my own implementation using orama https://github.com/oramasearch/orama

so far I've managed to generate a database for it using the nuxt content query API I think in the case of the algolia (non local search) module, it scrapes the html of the page instead at build time. Although by using the nuxt content query api you can split the generated database based on headers. What I'm lacking at the moment is the frontend bit which I need to work on

What I'm aiming for ideally is something that looks like what you get with mkdocs material, where it lists the header then the content underneath image

Barbapapazes commented 1 year ago

nuxt-themes/elements#158

Hello @Atinux, have you an idea when this will landed? I've deep dive into the VitePress implementation and using a server route and the cache storage, we could build the index used by MiniSearch.

atinux commented 1 year ago

It's coming very soon via #930 , see a demo on: https://unstorage-q6va4ddjb-nuxt-js.vercel.app/ (see pr

Barbapapazes commented 1 year ago

that's niiiice