Search code examples
vue.jsnuxt.jscontent-management-systemnuxt-content

How to add a search feature to a static site using Nuxt.js and Nuxt Content headless CMS


I built a blog website using Nuxt.js static site generation and the Nuxt Content headless CMS module. I'm now trying to build a search page where the user can input various queries for filtering articles, e.g. title, fulltext, author, date published etc.

Is that possible on a static site? Or do I have to host the CMS separately and make dynamic requests in order for this to work?


Solution

  • A static site is "static" because of the files that you do have at the end. It's not static in the meaning that you cannot use JS.

    You can totally use a .filter method if you have your data locally somewhere in your data or alike, otherwise you could probably reach out for the .search method of the module.