瀏覽代碼

doc-search: add basic support of search via docsearch from Algolia

David Bernard 9 年之前
父節點
當前提交
d711cb2f90

+ 1 - 0
src/templates/slim/html5/_header.html.slim

@@ -1,5 +1,6 @@
 / AsciiDoc leaves an empty header div even if there's no doctitle
 #header
+  include _tools.html
   - if has_header?
     - unless notitle
       h1 = header.title

+ 0 - 1
src/templates/slim/html5/_toc.html.slim

@@ -1,5 +1,4 @@
 #toc class=(attr 'toc-class', 'toc')
-  include _tools.html
   #toctitle =(attr 'toc-title')
   / Renders block_outline.html.
   = converter.convert document, 'outline'

+ 2 - 0
src/templates/slim/html5/_tools.html.slim

@@ -3,3 +3,5 @@
     i class="fa fa-pencil-square" aria-hidden="true"
   a href=wiki_link_create()
     i class="fa fa-plus-square" aria-hidden="true"
+  / include _searchbox.html
+  <input dir="auto" style="position: relative; vertical-align: top;" spellcheck="false" autocomplete="off" class="searchbox__input aa-input" id="doc-search" name="search" placeholder="Search in the doc" required="required" type="search">

+ 9 - 0
src/templates/slim/html5/document.html.slim

@@ -13,6 +13,7 @@ html lang=(attr :lang, 'en' unless attr? :nolang)
     = html_meta_if 'keywords', (attr :keywords)
     title=((doctitle sanitize: true) || (attr 'untitled-label'))
     = styles_and_scripts
+    link rel="stylesheet" href="https://cdn.jsdelivr.net/docsearch.js/2/docsearch.min.css"
     - unless (docinfo_content = docinfo).empty?
       =docinfo_content
   body(
@@ -26,3 +27,11 @@ html lang=(attr :lang, 'en' unless attr? :nolang)
       include _footnotes.html
     - unless nofooter
       include _footer.html
+    script type="text/javascript" src="https://cdn.jsdelivr.net/docsearch.js/2/docsearch.min.js"
+    javascript:
+      docsearch({
+        apiKey: 'a736b6d93de805e26ec2f49b55013fbd',
+        indexName: 'jmonkeyengine',
+        inputSelector: '#doc-search',
+        debug: false // Set debug to true if you want to inspect the dropdown
+      });