Skip to content

Commit

Permalink
Switch to Typesense and integrate typesense-minibar
Browse files Browse the repository at this point in the history
  • Loading branch information
Krinkle committed May 8, 2023
1 parent 52730b1 commit 4388ff3
Show file tree
Hide file tree
Showing 14 changed files with 461 additions and 511 deletions.
37 changes: 0 additions & 37 deletions .github/workflows/doc-search.yaml

This file was deleted.

20 changes: 0 additions & 20 deletions .meilisearch.json

This file was deleted.

2 changes: 0 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,3 @@ source "https://rubygems.org"
ruby RUBY_VERSION

gemspec

gem "jekyll-algolia", "~> 1.7.0", group: :jekyll_plugins
21 changes: 5 additions & 16 deletions _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,11 @@ amethyst:
release_base: https://github.com/qunitjs/qunit/releases/tag/
github: qunitjs
gitter: qunitjs/qunit
# https://github.com/qunitjs/jekyll-theme-amethyst/blob/main/docs/getting-started.md#enable-algolia-search
algolia:
search_only_api_key: f93ac48385f4f5866ffe9227829b329e
# https://github.com/qunitjs/jekyll-theme-amethyst/blob/main/docs/getting-started.md#enable-typesense
typesense:
origin: https://typesense.jquery.com
collection: amethyst_demo
search_only_api_key: Zh8mMgohXECel9wjPwqT7lekLSG3OCgz


# Conversion settings
Expand All @@ -67,19 +69,6 @@ sass:
sourcemap: never


# Backend search settings
#
# Docs: https://github.com/algolia/jekyll-algolia
algolia:
application_id: 2Q66ROFTLQ
index_name: amethyst-demo
# By default only HTML paragraphs are indexed (and headings, albeit through a different mechanism).
# * Include list items (similar to paragraphs).
# * Include tables (index per row for better excerpts).
# * Include <pre> (typically code examples, omit if it "poisons" results too much).
nodes_to_index: "p,li,tr,pre"


# Blog archives
#
# Docs: https://github.com/jekyll/jekyll-archives/
Expand Down
113 changes: 0 additions & 113 deletions _includes/search-js.html

This file was deleted.

14 changes: 3 additions & 11 deletions _includes/search.html
Original file line number Diff line number Diff line change
@@ -1,14 +1,6 @@
<form class="site-search" id="site-search-form" action="https://duckduckgo.com">
<label class="screen-reader-text" for="aa-search-input">Search</label>
<input type="search" name="q" id="aa-search-input" class="aa-input-search" placeholder="Search..." autocomplete="off">
<input type="hidden" name="sites" value="{{ site.url | remove_first: 'http://' | remove_first: 'https://' }}">
<svg class="aa-input-icon" viewBox="654 -372 1664 1664" height="20">
<path d="M1806,332c0-123.3-43.8-228.8-131.5-316.5C1586.8-72.2,1481.3-116,1358-116s-228.8,43.8-316.5,131.5 C953.8,103.2,910,208.7,910,332s43.8,228.8,131.5,316.5C1129.2,736.2,1234.7,780,1358,780s228.8-43.8,316.5-131.5 C1762.2,560.8,1806,455.3,1806,332z M2318,1164c0,34.7-12.7,64.7-38,90s-55.3,38-90,38c-36,0-66-12.7-90-38l-343-342 c-119.3,82.7-252.3,124-399,124c-95.3,0-186.5-18.5-273.5-55.5s-162-87-225-150s-113-138-150-225S654,427.3,654,332 s18.5-186.5,55.5-273.5s87-162,150-225s138-113,225-150S1262.7-372,1358-372s186.5,18.5,273.5,55.5s162,87,225,150s113,138,150,225 S2062,236.7,2062,332c0,146.7-41.3,279.7-124,399l343,343C2305.7,1098.7,2318,1128.7,2318,1164z"/>
</svg>
<form role="search" class="tsmb-form"{%- if site.amethyst.typesense.search_only_api_key -%} data-origin="{{ site.amethyst.typesense.origin | escape }}" data-collection="{{ site.amethyst.typesense.collection | escape }}" data-key="{{ site.amethyst.typesense.search_only_api_key | escape }}" data-foot="true"{%- endif -%} action="https://duckduckgo.com">
<input type="search" name="q" aria-label="Search" placeholder="Search..." autocomplete="off">
<input type="hidden" name="sites" value="{{ site.url | remove_first: 'http://' | remove_first: 'https://' }}">
</form>

{%- comment -%}

See also search-js.html

{%- endcomment -%}
36 changes: 22 additions & 14 deletions _layouts/wrapper.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@
{{ site.title | escape }}
{%- endif -%}
</a>
{%- if site.amethyst.algolia.search_only_api_key -%}
{%- include search.html -%}
{%- endif -%}
{%- include search.html -%}
<nav class="site-nav"><ul class="site-nav-list">
{%- for item in site.data.sitenav -%}
<li class="site-nav-item{%- if item.sub %} has-sub-list{% endif %}">
Expand All @@ -35,25 +33,25 @@
{%- endfor -%}
</ul></nav>
<div class="site-toggles">
{%- if site.amethyst.algolia.search_only_api_key %}
<button class="search-toggle toggle" data-opens=".site-search" aria-expanded="false">
<button class="search-toggle toggle" aria-expanded="false">
<span class="screen-reader-text">Search</span>
<svg class="icon aa-input-icon" aria-hidden="true" viewBox="654 -372 1664 1664" height="20">
<path d="M1806,332c0-123.3-43.8-228.8-131.5-316.5C1586.8-72.2,1481.3-116,1358-116s-228.8,43.8-316.5,131.5 C953.8,103.2,910,208.7,910,332s43.8,228.8,131.5,316.5C1129.2,736.2,1234.7,780,1358,780s228.8-43.8,316.5-131.5 C1762.2,560.8,1806,455.3,1806,332z M2318,1164c0,34.7-12.7,64.7-38,90s-55.3,38-90,38c-36,0-66-12.7-90-38l-343-342 c-119.3,82.7-252.3,124-399,124c-95.3,0-186.5-18.5-273.5-55.5s-162-87-225-150s-113-138-150-225S654,427.3,654,332 s18.5-186.5,55.5-273.5s87-162,150-225s138-113,225-150S1262.7-372,1358-372s186.5,18.5,273.5,55.5s162,87,225,150s113,138,150,225 S2062,236.7,2062,332c0,146.7-41.3,279.7-124,399l343,343C2305.7,1098.7,2318,1128.7,2318,1164z"/>
</svg>
</button>
<script type="module">
const searchToggle = document.querySelector('.search-toggle');
const searchToggleOpens = document.querySelector(searchToggle.dataset.opens);
const searchForm = document.querySelector('form[role=search]');
const searchInput = searchForm.querySelector('input[type=search]');
searchToggle.addEventListener('click', () => {
const state = searchToggle.classList.contains('opened');
searchToggle.classList.toggle('opened', !state);
searchToggle.setAttribute('aria-expanded', !state);
searchToggleOpens.classList.toggle('opened', !state);
searchToggleOpens.setAttribute('aria-expanded', !state);
const newState = searchToggle.getAttribute('aria-expanded') !== 'true';
searchToggle.setAttribute('aria-expanded', String(newState));
searchForm.style.display = newState ? 'block' : '';
if (newState) {
searchInput.focus();
}
});
</script>
{%- endif %}
<button class="nav-toggle toggle" data-opens=".site-nav" aria-expanded="false">
<span class="screen-reader-text">Menu</span>
<svg class="icon icon-nav-toggle" aria-hidden="true" viewBox="0 0 100 100" height="20">
Expand Down Expand Up @@ -103,8 +101,18 @@
</p>
</div>
</footer>
{%- if site.amethyst.algolia.search_only_api_key -%}
{%- include search-js.html -%}
{%- comment -%}

We use type="module" as a natural way to cut the mustard,
executing the script only on modern browsers with ES6 support,
and causing no errors on older browsers.

<https://responsivenews.tumblr.com/post/18948466399/cutting-the-mustard>
<http://web.archive.org/web/20150305005331/http://responsivenews.co.uk/post/18948466399/cutting-the-mustard>

{%- endcomment -%}
{%- if site.amethyst.typesense.search_only_api_key -%}
<script defer type="module" src="{{ '/assets/typesense-minibar.js' | file_version_query | relative_url }}"></script>
{%- endif -%}
</body>
</html>
Loading

0 comments on commit 4388ff3

Please sign in to comment.