Skip to content

Commit ce1ec82

Browse files
author
Christian Fei
committed
init example
1 parent f8e6e29 commit ce1ec82

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

README.md

+23
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ First of all include the script
2525

2626
This will create a global object called `JekyllSearch`, on which you can invoke the `init()` function.
2727

28+
#Customize the plugin
29+
2830
If you want, you can customize several options of this plugin:
2931

3032
- `searchInput` (Element) the input field to listen on
@@ -36,6 +38,27 @@ If you want, you can customize several options of this plugin:
3638
- `fuzzy` (Boolean) Turn on/off <a href="#fuzzysearch">fuzzy search</a>
3739
- `noResults` (String) Text to display if nothing matched the search criteria
3840

41+
---
42+
43+
You can pass the customized properties into an object when you invoke the init function, like this:
44+
45+
Let's say I want to apply JekyllSearch to a non-default input field (`.search`), e.g. `#search-this-page`.
46+
47+
I also changed the location of the JSON file, which is now `site-search.json` and I have a different <a href="#template">template</a>.
48+
49+
Plus I want to turn on <a href="#fuzzysearch">fuzzy search</a>:
50+
51+
52+
```javascript
53+
JekyllSearch.init({
54+
searchInput: document.getElementById("search-this-page"),
55+
jsonFile: "site-search.json",
56+
template: "<a href='{url}' title='{title}'>{title} <span class='tooltip'>{description}</span></a>",
57+
fuzzy: true
58+
});
59+
```
60+
61+
3962
<h2 id="template">Template</h2>
4063
<h2 id="fuzzysearch">Fuzzy search</h2>
4164

0 commit comments

Comments
 (0)