JuanPabloDiaz / freeForGeeks

Stop searching, start building. Free resources for developers.
http://freeforgeeks.com
MIT License
41 stars 6 forks source link

[Bug] Search bar does not work #4

Closed JuanPabloDiaz closed 8 months ago

JuanPabloDiaz commented 8 months ago

For some reason the search bar does not work on the production site but it does work on my localhost

any search throw error message: "No Results!"

I already modify several times the script in the index.html file. I tried:

Note: I do have the search script: <script src="//cdn.jsdelivr.net/npm/docsify/lib/plugins/search.min.js"></script> I am not using a _sidebar.md file Site deployed with github pages.

JuanPabloDiaz commented 8 months ago

Thanks to the Docsify community, I was able to resolve the issue.

I modify the script by:

Add a namespace if you have another Docsify site open online using the same domain. This could cause issues with namespace not being unique. The routermode seems to conflict with the search functionality when on GitHub Pages. Removing that seems to result in the Search working online.

In summary, my working script ends up been:

window.$docsify = {
        name: "DevKit",
        repo: "JuanPabloDiaz/devKit",
        search: {
          paths: "auto",
          namespace: "devKit", // To avoid search index collision between multiple websites under the same domain
          depth: 0, // index all headers and content - To enable full-text search
          // routerMode: "history", // use 'hash' instead to avoid `search error` on Github pages https://github.com/JuanPabloDiaz/devKit/issues/4
          placeholder: "Search Free Resources",
          noData:
            '<h3 style="text-align: center;"><i>No results! 🤔</i></h3> <br><h4 style="text-align: center; color: orange;"><a href="https://github.com/JuanPabloDiaz/devKit/pulls" target="_blank">Open a PR to add new resources</a></h4>',
        },
        darklightTheme: {
          siteFont: "Source Sans Pro, Helvetica Neue",
          defaultTheme: "light",
          codeFontFamily: "Roboto Mono, Monaco, courier, monospace",
          bodyFontSize: "15px",
        },
      };