jekyll-theme-amethyst 1.2.0 → 1.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/_includes/search.html +2 -2
- data/_sass/typesense-minibar.css +5 -4
- data/assets/typesense-minibar.js +12 -14
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dd713f104c3f11d0bbf936b256059ac16abed6d63e3bfe4d3641cf1d7bd0cf9d
|
4
|
+
data.tar.gz: 9eb9b32ecd778b4a10ffa708c3ef3176bc574b4a540dd90682a404aec69aaa9f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 88ea9945ef9a71a0f3bdb14cfdf932c90a5a6c7209e687fcd19377be5b3099eb74fcea5d066cf23b20964bdee42b683a3e06ba332cd92f9b9523aa1a064b7241
|
7
|
+
data.tar.gz: ca19314005d3446128363a3c5b24475a1cbf1f8443f6c98dd5928ebc10d25b54a584dce38e4e2fa8318b76438057a945e0f9f94fa68bfdabcf7e46116da49ad7
|
data/_includes/search.html
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
<typesense-minibar>
|
2
|
-
<form role="search"
|
1
|
+
<typesense-minibar{% 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 %}>
|
2
|
+
<form role="search" action="https://duckduckgo.com">
|
3
3
|
<input type="search" name="q" aria-label="Search" placeholder="Search..." autocomplete="off">
|
4
4
|
<input type="hidden" name="sites" value="{{ site.url | remove_first: 'http://' | remove_first: 'https://' }}">
|
5
5
|
</form>
|
data/_sass/typesense-minibar.css
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
/*! https://github.com/jquery/typesense-minibar 1.3.
|
1
|
+
/*! https://github.com/jquery/typesense-minibar 1.3.2 */
|
2
2
|
.tsmb-form,
|
3
3
|
typesense-minibar {
|
4
4
|
--tsmb-size-edge: 1px;
|
@@ -173,12 +173,12 @@ typesense-minibar [role=option] a {
|
|
173
173
|
}
|
174
174
|
|
175
175
|
.tsmb-form:not([data-group=true]) [role=option]:not(:first-child) a,
|
176
|
-
typesense-minibar
|
176
|
+
typesense-minibar:not([data-group=true]) [role=option]:not(:first-child) a {
|
177
177
|
border-top: var(--tsmb-size-edge) solid var(--tsmb-color-focus90);
|
178
178
|
}
|
179
179
|
|
180
180
|
.tsmb-form[data-group=true] [role=option] a,
|
181
|
-
typesense-minibar
|
181
|
+
typesense-minibar[data-group=true] [role=option] a {
|
182
182
|
margin: 0 var(--tsmb-size-base);
|
183
183
|
padding: var(--tsmb-size-sm);
|
184
184
|
}
|
@@ -210,7 +210,8 @@ typesense-minibar [role=option] mark {
|
|
210
210
|
.tsmb-suggestion_title {
|
211
211
|
color: var(--tsmb-color-primary30);
|
212
212
|
}
|
213
|
-
.tsmb-form[data-group=true] .tsmb-suggestion_title
|
213
|
+
.tsmb-form[data-group=true] .tsmb-suggestion_title,
|
214
|
+
typesense-minibar[data-group=true] .tsmb-suggestion_title {
|
214
215
|
font-weight: bold;
|
215
216
|
font-size: var(--tsmb-size-sm);
|
216
217
|
}
|
data/assets/typesense-minibar.js
CHANGED
@@ -1,7 +1,5 @@
|
|
1
|
-
/*! https://github.com/jquery/typesense-minibar 1.3.
|
2
|
-
globalThis.tsminibar = function tsminibar (form) {
|
3
|
-
const { origin, collection } = form.dataset;
|
4
|
-
const group = !!form.dataset.group;
|
1
|
+
/*! https://github.com/jquery/typesense-minibar 1.3.2 */
|
2
|
+
globalThis.tsminibar = function tsminibar (form, dataset = form.dataset) {
|
5
3
|
const cache = new Map();
|
6
4
|
const state = { query: '', cursor: -1, open: false, hits: [] };
|
7
5
|
const searchParams = new URLSearchParams({
|
@@ -14,10 +12,10 @@ globalThis.tsminibar = function tsminibar (form) {
|
|
14
12
|
sort_by: 'item_priority:desc',
|
15
13
|
snippet_threshold: '8',
|
16
14
|
highlight_affix_num_tokens: '12',
|
17
|
-
'x-typesense-api-key':
|
18
|
-
...Object.fromEntries(new URLSearchParams(
|
15
|
+
'x-typesense-api-key': dataset.key,
|
16
|
+
...Object.fromEntries(new URLSearchParams(dataset.searchParams))
|
19
17
|
});
|
20
|
-
const noResults =
|
18
|
+
const noResults = dataset.noResults || "No results for '{}'.";
|
21
19
|
|
22
20
|
const input = form.querySelector('input[type=search]');
|
23
21
|
const listbox = document.createElement('div');
|
@@ -31,7 +29,7 @@ globalThis.tsminibar = function tsminibar (form) {
|
|
31
29
|
preconnect = document.createElement('link');
|
32
30
|
preconnect.rel = 'preconnect';
|
33
31
|
preconnect.crossOrigin = 'anonymous'; // match fetch cors,credentials:omit
|
34
|
-
preconnect.href = origin;
|
32
|
+
preconnect.href = dataset.origin;
|
35
33
|
document.head.append(preconnect);
|
36
34
|
}
|
37
35
|
if (!state.open && state.hits.length) {
|
@@ -92,7 +90,7 @@ globalThis.tsminibar = function tsminibar (form) {
|
|
92
90
|
|
93
91
|
function connect () {
|
94
92
|
document.addEventListener('click', onDocClick);
|
95
|
-
if (
|
93
|
+
if (dataset.slash !== 'false') {
|
96
94
|
document.addEventListener('keydown', onDocSlash);
|
97
95
|
form.classList.add('tsmb-form--slash');
|
98
96
|
}
|
@@ -124,9 +122,10 @@ globalThis.tsminibar = function tsminibar (form) {
|
|
124
122
|
}
|
125
123
|
searchParams.set('q', query);
|
126
124
|
const resp = await fetch(
|
127
|
-
`${origin}/collections/${collection}/documents/search?` + searchParams,
|
125
|
+
`${dataset.origin}/collections/${dataset.collection}/documents/search?` + searchParams,
|
128
126
|
{ mode: 'cors', credentials: 'omit', method: 'GET' }
|
129
127
|
);
|
128
|
+
const group = !!dataset.group;
|
130
129
|
const data = await resp.json();
|
131
130
|
hits = data?.grouped_hits?.map(ghit => {
|
132
131
|
const hit = ghit.hits[0];
|
@@ -151,12 +150,11 @@ globalThis.tsminibar = function tsminibar (form) {
|
|
151
150
|
function render () {
|
152
151
|
listbox.hidden = !state.open;
|
153
152
|
form.classList.toggle('tsmb-form--open', state.open);
|
154
|
-
listbox.innerHTML = (state.hits.map((hit, i) => `<div role="option"${i === state.cursor ? ' aria-selected="true"' : ''}>${hit.lvl0 ? `<div class="tsmb-suggestion_group">${hit.lvl0}</div>` : ''}<a href="${hit.url}" tabindex="-1"><div class="tsmb-suggestion_title">${hit.title}</div><div class="tsmb-suggestion_content">${hit.content}</div></a></div>`).join('') || `<div class="tsmb-empty">${noResults.replace('{}', escape(state.query))}</div>`) + (
|
153
|
+
listbox.innerHTML = (state.hits.map((hit, i) => `<div role="option"${i === state.cursor ? ' aria-selected="true"' : ''}>${hit.lvl0 ? `<div class="tsmb-suggestion_group">${hit.lvl0}</div>` : ''}<a href="${hit.url}" tabindex="-1"><div class="tsmb-suggestion_title">${hit.title}</div><div class="tsmb-suggestion_content">${hit.content}</div></a></div>`).join('') || `<div class="tsmb-empty">${noResults.replace('{}', escape(state.query))}</div>`) + (dataset.foot ? '<a href="https://typesense.org" class="tsmb-foot" title="Search by Typesense"></a>' : '');
|
155
154
|
}
|
156
155
|
|
157
156
|
function moveCursor (offset) {
|
158
157
|
state.cursor += offset;
|
159
|
-
// -1 refers to input field
|
160
158
|
if (state.cursor >= state.hits.length) state.cursor = -1;
|
161
159
|
if (state.cursor < -1) state.cursor = state.hits.length - 1;
|
162
160
|
render();
|
@@ -164,10 +162,10 @@ globalThis.tsminibar = function tsminibar (form) {
|
|
164
162
|
|
165
163
|
return { form, connect, disconnect };
|
166
164
|
};
|
167
|
-
document.querySelectorAll('.tsmb-form[data-origin]').forEach(tsminibar);
|
168
165
|
window.customElements.define('typesense-minibar', class extends HTMLElement {
|
169
166
|
connectedCallback () {
|
170
167
|
const form = this.querySelector('form');
|
171
|
-
if (form) tsminibar(form);
|
168
|
+
if (form && this.dataset.origin) tsminibar(form, this.dataset);
|
172
169
|
}
|
173
170
|
});
|
171
|
+
document.querySelectorAll('.tsmb-form[data-origin]').forEach(form => tsminibar(form));
|