docpad

Adding a search form to Docpad site


Is there a way to have a native search form that indexes search results in Docpad. The dynamic search page example doesn't work and looking at the code wasn't any help to me. I think a search form example and a basic contact form example would be good for noobs like myself looking to adopt Docpad and it to their workflow.

Thanks in advance for any help!


Solution

  • Depends what you mean by not working. Were you able to get the Kitchin Sink skeleton to install? The search page in this skeleton reads the query term from the URL and searches all documents in the website with the word "coffee" in the title

    @getCollection('documents').findAll({title:$like:query})
    

    You should just get a list of links to documents with "coffee" in their title - not that exciting on its own.

    If you mean you are trying to implement this search page within your own project there seems to be a bit of a 'gotcha' in that you have to make sure the docpad plugin clean urls is installed in your project.