2

problem descritpion

i try to use the search function of docsifyk, but it seems not working.

steps to reproduce

so i do these steps: (following the official docsify documentation)

  1. i run 'docsify init' in a directory, so it generate a 'index.html' and a 'README.md'.
  2. i add the code into 'index.html‘.
<script src="//unpkg.com/docsify/lib/plugins/search.min.js"></script>

current behavior

the page shows the search button, but whatever i type, it returns 'no result'.

other information

i have tried it on different computers(mac/ubuntu 16), both not working

Did Anybody Ever Have The Same Question?

fish7
  • 21
  • 3
  • We're suddenly experiencing the same issue. Did not find a solution yet. Have you enabled the sidebar? From my understanding that's needed to actually index the pages. In addition, you can check your local storage in the browser console. You can see the content of Docsify's search index under the docsify.search.index key – Niklas Jan 21 '20 at 15:06
  • 1
    I just found the solution for my case. The parameter "paths" set to [] didn't create any entries inside the local-storage. I switched it to auto which solved it. – Niklas Jan 21 '20 at 15:31

2 Answers2

2

I encounter the same issue. I Found i was doing few things wrong Firstly This Link is Worth checking out

Make Sure You have a _sidebar.md File and or a file for side bar Adding a side bar after this just add this script tag

  <script>
    window.$docsify = {
      loadSidebar: true,
      subMaxLevel: 6,
      search: {
        maxAge: 86400000, // Expiration time, the default one day
        paths: 'auto',
        placeholder: 'Type to search',
        noData: 'No Results!',
        depth: 6,
        hideOtherSidebarContent: true, // whether or not to hide other sidebar content
     }
    }
  </script>
Sebastián Palma
  • 32,692
  • 6
  • 40
  • 59
0

this implementation works for me:

<script>
    window.$docsify = {
      loadSidebar: true,
      subMaxLevel: 3,
      name: '',
      repo: '',

      search: 'auto', // default

      // complete configuration parameters
      search: {
        maxAge: 86400000, // Expiration time, the default one day
        paths: 'auto',
        placeholder: 'Type to search',
        noData: 'No Results!',
        // Headline depth, 1 - 6
        depth: 6,
        hideOtherSidebarContent: false, // whether or not to hide other sidebar content
     }
    }
  </script>
  <script src="//unpkg.com/docsify/lib/docsify.min.js"></script>
  <script src="//unpkg.com/docsify/lib/plugins/search.min.js"></script>

check this plugin if you prefer algolia https://www.npmjs.com/package/docsify-algolia-search-plugin

Muhammed Moussa
  • 4,589
  • 33
  • 27