support stork search

- add search css
- include js and wasm from cdn or locally
- initialize js
This commit is contained in:
Elias Kirchgässner 2022-03-07 13:55:35 +01:00
parent 53fc53b8b9
commit 4e99152aff
3 changed files with 237 additions and 2 deletions

View file

@ -73,7 +73,15 @@
{% if USE_GOOGLE_FONTS != False %}
<link href="https://fonts.googleapis.com/css?family=Merriweather:300,400|Open+Sans" rel="stylesheet">
{% endif %}
<link rel="stylesheet" href="{{ SITEURL }}/{{ THEME_STATIC_DIR }}/tipuesearch/tipuesearch.min.css" />
<link rel="stylesheet"
href="{{ SITEURL }}/{{ THEME_STATIC_DIR }}/tipuesearch/tipuesearch.min.css" />
{% endif %}
{% if PLUGINS and 'pelican.plugins.search' in PLUGINS %}
{% if THEME_COLOR_AUTO_DETECT_BROWSER_PREFERENCE or not THEME_COLOR or THEME_COLOR == "light" %}
<link rel="stylesheet" type="text/css" href="{{ SITEURL }}/{{ THEME_STATIC_DIR }}/stork/stork-dark.css" />
{% endif %}
{% endif %}
<link rel="stylesheet" type="text/css" href="{{ SITEURL }}/{{ THEME_STATIC_DIR }}/font-awesome/css/fontawesome.css">
@ -182,7 +190,12 @@
<input type="text" name="q" id="tipue_search_input" placeholder="{{ _('Search...') }}">
</form>
{% endif %}
{% if PLUGINS and 'pelican.plugins.search' in PLUGINS %}
<div class="stork-wrapper-dark">
<input class="stork-input" type="text" name="q" data-stork="sitesearch" placeholder="{{ _('Search...') }}"/>
<div class="stork-output" data-stork="sitesearch-output"></div>
</div>
{% endif %}
{% if (pages and DISPLAY_PAGES_ON_MENU) or LINKS %}
<nav>
<ul class="list">
@ -302,5 +315,18 @@
{% endif %}
{% block additional_js %}{% endblock %}
{% if PLUGINS and 'pelican.plugins.search' in PLUGINS %}
{% if STORK_VERSION %}
<script src="https://files.stork-search.net/releases/v{{ STORK_VERSION }}/stork.js"></script>
<script>
{% else %}
<script src="{{ SITEURL }}/static/stork.js"></script>
<script>
stork.initialize("{{ SITEURL }}/static/stork.wasm")
{% endif %}
stork.register("sitesearch", "{{ SITEURL }}/search-index.st", {showProgress: false})
</script>
{% endif %}
</body>
</html>