jekyll-theme-amethyst 0.4.2 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/typesense.yaml +29 -0
- data/Gemfile +0 -2
- data/README.md +21 -0
- data/_config.yml +5 -16
- data/_data/sidebar_api.yml +8 -4
- data/_includes/search.html +3 -11
- data/_includes/version.html +2 -2
- data/_layouts/page-api.html +26 -17
- data/_layouts/post.html +3 -3
- data/_layouts/wrapper.html +22 -14
- data/_sass/amethyst.scss +36 -218
- data/amethyst.gemspec +1 -1
- data/assets/styles.scss +2 -0
- data/assets/typesense-minibar.css +223 -0
- data/assets/typesense-minibar.js +163 -0
- data/docs/config.md +6 -55
- data/docs/getting-started.md +9 -25
- data/docsearch.config.json +60 -0
- metadata +6 -6
- data/.github/workflows/doc-search.yaml +0 -37
- data/.meilisearch.json +0 -20
- data/_includes/search-js.html +0 -113
- data/assets/logo-algolia.svg +0 -1
@@ -0,0 +1,223 @@
|
|
1
|
+
/*! https://github.com/jquery/typesense-minibar 1.0.1 */
|
2
|
+
.tsmb-form {
|
3
|
+
--tsmb-size-edge: 1px;
|
4
|
+
--tsmb-size-radius: 3px;
|
5
|
+
--tsmb-size-highlight: 2px;
|
6
|
+
--tsmb-size-base: 1rem;
|
7
|
+
--tsmb-size-sm: 0.8rem;
|
8
|
+
--tsmb-size-half: calc( var(--tsmb-size-sm) * 0.5 );
|
9
|
+
--tsmb-size-input: calc( var(--tsmb-size-base) * 1.2 );
|
10
|
+
|
11
|
+
--tsmb-color-base-background: #fff;
|
12
|
+
--tsmb-color-base30: #333;
|
13
|
+
--tsmb-color-base50: #63676d;
|
14
|
+
--tsmb-color-base90: #cdcdcd;
|
15
|
+
--tsmb-color-focus-background: #fff;
|
16
|
+
--tsmb-color-focus30: #333;
|
17
|
+
--tsmb-color-focus50: #63676d;
|
18
|
+
--tsmb-color-focus90: #cdcdcd;
|
19
|
+
|
20
|
+
--tsmb-color-primary30: #390f39;
|
21
|
+
--tsmb-color-primary50: #9c3493;
|
22
|
+
--tsmb-color-primary90: #fbdbfb;
|
23
|
+
|
24
|
+
position: relative;
|
25
|
+
width: 20rem;
|
26
|
+
max-width: 100%;
|
27
|
+
color: var(--tsmb-color-base30);
|
28
|
+
}
|
29
|
+
|
30
|
+
.tsmb-form input[type=search] {
|
31
|
+
-webkit-appearance: none;
|
32
|
+
-moz-appearance: none;
|
33
|
+
appearance: none;
|
34
|
+
color: inherit;
|
35
|
+
background: var(--tsmb-color-base-background);
|
36
|
+
padding: var(--tsmb-size-sm) var(--tsmb-size-sm) var(--tsmb-size-sm) calc(var(--tsmb-size-base) + var(--tsmb-size-sm) + var(--tsmb-size-sm));
|
37
|
+
border: var(--tsmb-size-edge) solid var(--tsmb-color-base90);
|
38
|
+
border-radius: var(--tsmb-size-radius);
|
39
|
+
font-size: var(--tsmb-size-base);
|
40
|
+
width: 100%;
|
41
|
+
line-height: var(--tsmb-size-input);
|
42
|
+
}
|
43
|
+
|
44
|
+
.tsmb-form input[type=search]::placeholder {
|
45
|
+
color: var(--tsmb-color-base50);
|
46
|
+
opacity: 1;
|
47
|
+
}
|
48
|
+
|
49
|
+
.tsmb-form:focus-within {
|
50
|
+
color: var(--tsmb-color-focus30);
|
51
|
+
}
|
52
|
+
.tsmb-form:focus-within input[type=search] {
|
53
|
+
background: var(--tsmb-color-focus-background);
|
54
|
+
}
|
55
|
+
.tsmb-form:focus-within input[type=search]::placeholder {
|
56
|
+
color: var(--tsmb-color-focus50);
|
57
|
+
}
|
58
|
+
|
59
|
+
.tsmb-form input[type=search]::-webkit-search-decoration,
|
60
|
+
.tsmb-form input[type=search]::-webkit-search-cancel-button,
|
61
|
+
.tsmb-form input[type=search]::-webkit-search-results-button,
|
62
|
+
.tsmb-form input[type=search]::-webkit-search-results-decoration {
|
63
|
+
display: none;
|
64
|
+
}
|
65
|
+
|
66
|
+
/* input icon */
|
67
|
+
.tsmb-form::before {
|
68
|
+
content: '';
|
69
|
+
background: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='654 -372 1664 1664' width='20' 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>") 0 50% / contain no-repeat;
|
70
|
+
position: absolute;
|
71
|
+
top: calc(var(--tsmb-size-sm) + var(--tsmb-size-edge));
|
72
|
+
left: var(--tsmb-size-base);
|
73
|
+
width: var(--tsmb-size-base);
|
74
|
+
height: var(--tsmb-size-input);
|
75
|
+
opacity: 0.5;
|
76
|
+
}
|
77
|
+
|
78
|
+
.tsmb-icon-close {
|
79
|
+
position: absolute;
|
80
|
+
top: calc(var(--tsmb-size-sm) + var(--tsmb-size-edge));
|
81
|
+
right: var(--tsmb-size-base);
|
82
|
+
width: var(--tsmb-size-base);
|
83
|
+
height: var(--tsmb-size-base);
|
84
|
+
|
85
|
+
stroke: currentColor;
|
86
|
+
border: 1px solid currentColor;
|
87
|
+
border-radius: 50%;
|
88
|
+
cursor: pointer;
|
89
|
+
}
|
90
|
+
|
91
|
+
.tsmb-form--open .tsmb-icon-close {
|
92
|
+
display: block !important;
|
93
|
+
}
|
94
|
+
|
95
|
+
.tsmb-form--slash:not(.tsmb-form--open):not(:focus-within)::after {
|
96
|
+
content: '/';
|
97
|
+
display: inline-block;
|
98
|
+
position: absolute;
|
99
|
+
top: calc(var(--tsmb-size-sm) + var(--tsmb-size-edge) + (var(--tsmb-size-input) / 2) - 1em - var(--tsmb-size-edge));
|
100
|
+
right: var(--tsmb-size-base);
|
101
|
+
width: 2em;
|
102
|
+
height: 2em;
|
103
|
+
|
104
|
+
font-size: var(--tsmb-size-sm);
|
105
|
+
line-height: 2;
|
106
|
+
text-align: center;
|
107
|
+
|
108
|
+
border: var(--tsmb-size-edge) solid var(--tsmb-color-base90);
|
109
|
+
border-radius: var(--tsmb-size-radius);
|
110
|
+
color: var(--tsmb-color-base90);
|
111
|
+
}
|
112
|
+
|
113
|
+
.tsmb-form [role=listbox] {
|
114
|
+
position: absolute;
|
115
|
+
z-index: 10;
|
116
|
+
|
117
|
+
background: var(--tsmb-color-focus-background);
|
118
|
+
color: var(--tsmb-color-focus30);
|
119
|
+
width: 100%;
|
120
|
+
max-height: 70vh;
|
121
|
+
overflow: auto;
|
122
|
+
border: var(--tsmb-size-edge) solid var(--tsmb-color-focus90);
|
123
|
+
box-shadow: 0 var(--tsmb-size-sm) 20px rgba(0,0,0,0.12);
|
124
|
+
}
|
125
|
+
|
126
|
+
.tsmb-suggestion_group {
|
127
|
+
margin: var(--tsmb-size-sm) var(--tsmb-size-base) 0 var(--tsmb-size-base);
|
128
|
+
border-bottom: var(--tsmb-size-edge) solid var(--tsmb-color-focus90);
|
129
|
+
}
|
130
|
+
|
131
|
+
.tsmb-form [role=option] a {
|
132
|
+
display: block;
|
133
|
+
padding: var(--tsmb-size-base);
|
134
|
+
text-decoration: none;
|
135
|
+
border-left: var(--tsmb-size-highlight) solid transparent;
|
136
|
+
}
|
137
|
+
.tsmb-form:not([data-group=true]) [role=option]:not(:first-child) a {
|
138
|
+
border-top: var(--tsmb-size-edge) solid var(--tsmb-color-focus90);
|
139
|
+
}
|
140
|
+
.tsmb-form[data-group=true] [role=option] a {
|
141
|
+
margin: 0 var(--tsmb-size-base);
|
142
|
+
padding: var(--tsmb-size-sm);
|
143
|
+
}
|
144
|
+
|
145
|
+
.tsmb-form [role=option] a:hover,
|
146
|
+
.tsmb-form [role=option][aria-selected=true] a {
|
147
|
+
background: var(--tsmb-color-primary90);
|
148
|
+
border-left-color: var(--tsmb-color-primary50);
|
149
|
+
}
|
150
|
+
|
151
|
+
.tsmb-form [role=option] mark {
|
152
|
+
background: none;
|
153
|
+
color: inherit;
|
154
|
+
font-style: normal;
|
155
|
+
font-weight: bold;
|
156
|
+
}
|
157
|
+
|
158
|
+
.tsmb-suggestion_group,
|
159
|
+
.tsmb-suggestion_title,
|
160
|
+
.tsmb-suggestion_content {
|
161
|
+
white-space: nowrap;
|
162
|
+
overflow: hidden;
|
163
|
+
text-overflow: ellipsis;
|
164
|
+
}
|
165
|
+
|
166
|
+
.tsmb-suggestion_title {
|
167
|
+
color: var(--tsmb-color-primary30);
|
168
|
+
}
|
169
|
+
.tsmb-form[data-group=true] .tsmb-suggestion_title {
|
170
|
+
font-weight: bold;
|
171
|
+
font-size: var(--tsmb-size-sm);
|
172
|
+
}
|
173
|
+
|
174
|
+
.tsmb-suggestion_content {
|
175
|
+
font-size: var(--tsmb-size-sm);
|
176
|
+
color: var(--tsmb-color-focus50);
|
177
|
+
}
|
178
|
+
|
179
|
+
.tsmb-empty {
|
180
|
+
padding: var(--tsmb-size-base);
|
181
|
+
}
|
182
|
+
|
183
|
+
.tsmb-foot {
|
184
|
+
display: block;
|
185
|
+
text-align: right;
|
186
|
+
font-size: var(--tsmb-size-sm);
|
187
|
+
line-height: 18px;
|
188
|
+
padding: var(--tsmb-size-half) var(--tsmb-size-sm);
|
189
|
+
box-shadow: 0 0 10px rgba(0,0,0,0.12);
|
190
|
+
}
|
191
|
+
.tsmb-foot:hover {
|
192
|
+
text-decoration: none;
|
193
|
+
}
|
194
|
+
.tsmb-foot::before {
|
195
|
+
content: 'Search by';
|
196
|
+
color: var(--tsmb-color-focus50);
|
197
|
+
}
|
198
|
+
.tsmb-foot::after {
|
199
|
+
content: ' Typesense';
|
200
|
+
color: #0300b0;
|
201
|
+
}
|
202
|
+
|
203
|
+
@media (max-width: 480px) {
|
204
|
+
.tsmb-form {
|
205
|
+
width: 100%;
|
206
|
+
}
|
207
|
+
|
208
|
+
.tsmb-form input[type=search] {
|
209
|
+
border-radius: 0;
|
210
|
+
}
|
211
|
+
}
|
212
|
+
|
213
|
+
@media (min-width: 768px) {
|
214
|
+
.tsmb-form [role=listbox] {
|
215
|
+
border-radius: var(--tsmb-size-radius);
|
216
|
+
min-width: 500px;
|
217
|
+
margin-top: var(--tsmb-size-half);
|
218
|
+
}
|
219
|
+
|
220
|
+
.tsmb-form--slash::after {
|
221
|
+
display: none;
|
222
|
+
}
|
223
|
+
}
|
@@ -0,0 +1,163 @@
|
|
1
|
+
/*! https://github.com/jquery/typesense-minibar 1.0.1 */
|
2
|
+
globalThis.tsminibar = function tsminibar (form) {
|
3
|
+
const { origin, key, collection } = form.dataset;
|
4
|
+
const group = !!form.dataset.group;
|
5
|
+
const cache = new Map();
|
6
|
+
const state = { query: '', hits: [], cursor: -1, open: false };
|
7
|
+
|
8
|
+
const input = form.querySelector('input[type=search]');
|
9
|
+
const listbox = document.createElement('div');
|
10
|
+
listbox.setAttribute('role', 'listbox');
|
11
|
+
listbox.hidden = true;
|
12
|
+
input.after(listbox);
|
13
|
+
|
14
|
+
let preconnect = null;
|
15
|
+
input.addEventListener('focus', () => {
|
16
|
+
if (!preconnect) {
|
17
|
+
preconnect = document.createElement('link');
|
18
|
+
preconnect.rel = 'preconnect';
|
19
|
+
preconnect.crossOrigin = 'anonymous'; // for fetch mode:cors,credentials:omit
|
20
|
+
preconnect.href = origin;
|
21
|
+
document.head.append(preconnect);
|
22
|
+
}
|
23
|
+
if (!state.open && state.hits.length) {
|
24
|
+
state.open = true;
|
25
|
+
render();
|
26
|
+
}
|
27
|
+
});
|
28
|
+
input.addEventListener('click', () => {
|
29
|
+
if (!state.open && state.hits.length) {
|
30
|
+
state.open = true;
|
31
|
+
render();
|
32
|
+
}
|
33
|
+
});
|
34
|
+
input.addEventListener('input', async () => {
|
35
|
+
const query = state.query = input.value;
|
36
|
+
if (!query) {
|
37
|
+
state.hits = []; // don't leak old hits on focus
|
38
|
+
state.cursor = -1;
|
39
|
+
close();
|
40
|
+
return;
|
41
|
+
}
|
42
|
+
const hits = await search(query);
|
43
|
+
if (state.query === query) { // ignore non-current query
|
44
|
+
state.hits = hits;
|
45
|
+
state.cursor = -1;
|
46
|
+
state.open = true;
|
47
|
+
render();
|
48
|
+
}
|
49
|
+
});
|
50
|
+
input.addEventListener('keydown', (e) => {
|
51
|
+
if (!(e.altKey || e.ctrlKey || e.metaKey || e.shiftKey)) {
|
52
|
+
if (e.code === 'ArrowDown') moveCursor(1);
|
53
|
+
if (e.code === 'ArrowUp') moveCursor(-1);
|
54
|
+
if (e.code === 'Escape') close();
|
55
|
+
if (e.code === 'Enter') {
|
56
|
+
const url = state.hits[state.cursor]?.url;
|
57
|
+
if (url) location.href = url;
|
58
|
+
}
|
59
|
+
}
|
60
|
+
});
|
61
|
+
form.addEventListener('submit', (e) => {
|
62
|
+
e.preventDefault(); // disable fallback
|
63
|
+
});
|
64
|
+
form.insertAdjacentHTML('beforeend', '<svg viewBox="0 0 12 12" width="20" height="20" aria-hidden="true" class="tsmb-icon-close" style="display: none;"><path d="M9 3L3 9M3 3L9 9"/></svg>');
|
65
|
+
form.querySelector('.tsmb-icon-close').addEventListener('click', close);
|
66
|
+
connect();
|
67
|
+
|
68
|
+
function close () {
|
69
|
+
if (state.open) {
|
70
|
+
state.cursor = -1;
|
71
|
+
state.open = false;
|
72
|
+
render();
|
73
|
+
}
|
74
|
+
}
|
75
|
+
|
76
|
+
function connect () {
|
77
|
+
document.addEventListener('click', onDocClick);
|
78
|
+
if (form.dataset.slash !== 'false') {
|
79
|
+
document.addEventListener('keydown', onDocSlash);
|
80
|
+
form.classList.add('tsmb-form--slash');
|
81
|
+
}
|
82
|
+
}
|
83
|
+
|
84
|
+
function disconnect () {
|
85
|
+
document.removeEventListener('click', onDocClick);
|
86
|
+
document.removeEventListener('keydown', onDocSlash);
|
87
|
+
}
|
88
|
+
|
89
|
+
function onDocClick (e) {
|
90
|
+
if (!form.contains(e.target)) close();
|
91
|
+
}
|
92
|
+
|
93
|
+
function onDocSlash (e) {
|
94
|
+
if (e.key === '/' && !/^(INPUT|TEXTAREA)$/.test(document.activeElement?.tagName)) {
|
95
|
+
input.focus();
|
96
|
+
e.preventDefault();
|
97
|
+
}
|
98
|
+
}
|
99
|
+
|
100
|
+
async function search (query) {
|
101
|
+
let hits = cache.get(query);
|
102
|
+
if (hits) {
|
103
|
+
cache.delete(query);
|
104
|
+
cache.set(query, hits); // LRU
|
105
|
+
return hits;
|
106
|
+
}
|
107
|
+
const resp = await fetch(
|
108
|
+
`${origin}/collections/${collection}/documents/search?` + new URLSearchParams({
|
109
|
+
q: query,
|
110
|
+
per_page: '5',
|
111
|
+
query_by: 'hierarchy.lvl0,hierarchy.lvl1,hierarchy.lvl2,hierarchy.lvl3,hierarchy.lvl4,hierarchy.lvl5,content',
|
112
|
+
include_fields: 'hierarchy.lvl0,hierarchy.lvl1,hierarchy.lvl2,hierarchy.lvl3,hierarchy.lvl4,hierarchy.lvl5,content,url_without_anchor,url,id',
|
113
|
+
highlight_full_fields: 'hierarchy.lvl0,hierarchy.lvl1,hierarchy.lvl2,hierarchy.lvl3,hierarchy.lvl4,hierarchy.lvl5,content',
|
114
|
+
group_by: 'url_without_anchor',
|
115
|
+
group_limit: '1',
|
116
|
+
sort_by: 'item_priority:desc',
|
117
|
+
snippet_threshold: '8',
|
118
|
+
highlight_affix_num_tokens: '12',
|
119
|
+
'x-typesense-api-key': key,
|
120
|
+
}),
|
121
|
+
{ mode: 'cors', credentials: 'omit', method: 'GET' }
|
122
|
+
);
|
123
|
+
const data = await resp.json();
|
124
|
+
let lvl0;
|
125
|
+
hits = data?.grouped_hits?.map(ghit => {
|
126
|
+
const hit = ghit.hits[0];
|
127
|
+
return {
|
128
|
+
lvl0: group && lvl0 !== hit.document.hierarchy.lvl0 && (lvl0 = hit.document.hierarchy.lvl0),
|
129
|
+
title: [!group && hit.document.hierarchy.lvl0, hit.document.hierarchy.lvl1, hit.document.hierarchy.lvl2, hit.document.hierarchy.lvl3, hit.document.hierarchy.lvl4, hit.document.hierarchy.lvl5].filter(lvl => !!lvl).join(' › ') || hit.document.hierarchy.lvl0,
|
130
|
+
url: hit.document.url,
|
131
|
+
content: hit.highlights[0]?.snippet || hit.document.content || ''
|
132
|
+
};
|
133
|
+
}) || [];
|
134
|
+
cache.set(query, hits);
|
135
|
+
if (cache.size > 100) {
|
136
|
+
cache.delete(cache.keys().next().value);
|
137
|
+
}
|
138
|
+
return hits;
|
139
|
+
}
|
140
|
+
|
141
|
+
function escape (s) {
|
142
|
+
return s.replace(/['"<>&]/g, c => ({ "'": ''', '"': '"', '<': '<', '>': '>', '&': '&' }[c]));
|
143
|
+
}
|
144
|
+
|
145
|
+
function render () {
|
146
|
+
listbox.hidden = !state.open;
|
147
|
+
form.classList.toggle('tsmb-form--open', state.open);
|
148
|
+
if (state.open) {
|
149
|
+
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">No results for '${escape(state.query)}'.</div>`) + (form.dataset.foot ? '<a href="https://typesense.org" class="tsmb-foot" title="Search by Typesense"></a>' : '');
|
150
|
+
}
|
151
|
+
}
|
152
|
+
|
153
|
+
function moveCursor (offset) {
|
154
|
+
state.cursor += offset;
|
155
|
+
// -1 refers to input field
|
156
|
+
if (state.cursor >= state.hits.length) state.cursor = -1;
|
157
|
+
if (state.cursor < -1) state.cursor = state.hits.length - 1;
|
158
|
+
render();
|
159
|
+
}
|
160
|
+
|
161
|
+
return { form, connect, disconnect };
|
162
|
+
};
|
163
|
+
document.querySelectorAll('.tsmb-form[data-origin]').forEach(form => tsminibar(form));
|
data/docs/config.md
CHANGED
@@ -52,63 +52,14 @@ amethyst:
|
|
52
52
|
github:
|
53
53
|
# Gitter.im room (e.g. "qunitjs/qunit")
|
54
54
|
gitter:
|
55
|
-
#
|
56
|
-
|
57
|
-
|
55
|
+
# Search powered by Typesense
|
56
|
+
#
|
57
|
+
# https://github.com/qunitjs/jekyll-theme-amethyst/blob/main/docs/getting-started.md#enable-typesense
|
58
|
+
typesense:
|
59
|
+
origin:
|
60
|
+
collection:
|
58
61
|
search_only_api_key:
|
59
62
|
|
60
|
-
# Defaults to `algolia.application_id` (see below)
|
61
|
-
application_id:
|
62
|
-
|
63
|
-
# Which indexes to use as autocomplete source
|
64
|
-
#
|
65
|
-
# Defaults to a single source based on `algolia.index_name`,
|
66
|
-
# which means the current site only.
|
67
|
-
#
|
68
|
-
# If there are multiple relates sites that you want to give
|
69
|
-
# a unified search experience (e.g. qunitjs.com and api.qunitjs.com)
|
70
|
-
# then use this option to explicitly specify the sources.
|
71
|
-
# In that case, be sure to set `base` for the "other" sites
|
72
|
-
# as the indexes not aware of their full url (indexing happens
|
73
|
-
# at built time in CI). Include the "current" site index name as
|
74
|
-
# well, but without any `base` so that its results are linked
|
75
|
-
# relative, and thus work as expected when testing the site
|
76
|
-
# locally, for example.
|
77
|
-
#
|
78
|
-
# Example: Multiple sources
|
79
|
-
#
|
80
|
-
# ```
|
81
|
-
# sources:
|
82
|
-
# - index: qunitjs-api
|
83
|
-
# base: https://api.qunitjs.com
|
84
|
-
# - index: qunitjs
|
85
|
-
# ```
|
86
|
-
sources:
|
87
|
-
|
88
|
-
|
89
|
-
# Backend search settings
|
90
|
-
#
|
91
|
-
# This applies to the 'jekyll algolia' command, which is typically
|
92
|
-
# run from an after a commit is merged. The settings are documented at:
|
93
|
-
# https://github.com/algolia/jekyll-algolia
|
94
|
-
#
|
95
|
-
# To learn how to set this up, refer to:
|
96
|
-
# https://github.com/qunitjs/jekyll-theme-amethyst/blob/main/docs/getting-started.md#enable-algolia-search
|
97
|
-
#
|
98
|
-
algolia:
|
99
|
-
application_id:
|
100
|
-
# Which index_name the 'jekyll algolia' command will create or update.
|
101
|
-
index_name:
|
102
|
-
# By default only HTML paragraphs are indexed (and headings, albeit through a different mechanism).
|
103
|
-
# * Include list items (similar to paragraphs).
|
104
|
-
# * Include tables (index per row for better excerpts).
|
105
|
-
# * Include <pre> (typically code examples, omit if it "poisons" results too much).
|
106
|
-
nodes_to_index: 'p,li,tr,pre'
|
107
|
-
# Pages not to suggest in search, e.g. if they are overviews
|
108
|
-
# that only point to other pages and have no original content.
|
109
|
-
files_to_exclude:
|
110
|
-
# - something-overview.md
|
111
|
-
|
112
63
|
|
113
64
|
# Blog archives
|
114
65
|
#
|
data/docs/getting-started.md
CHANGED
@@ -47,31 +47,15 @@ Change the top navigation links, or create sub menus, via [sitenav.yml](https://
|
|
47
47
|
|
48
48
|
See [Manage a custom domain with GitHub Pages](https://docs.github.com/en/free-pro-team@latest/github/working-with-github-pages/managing-a-custom-domain-for-your-github-pages-site).
|
49
49
|
|
50
|
-
### Enable
|
50
|
+
### Enable Typesense
|
51
51
|
|
52
|
-
|
53
|
-
2. Go to "API Keys", and take note of the "Search-Only API Key" and "Admin API Key".
|
54
|
-
3. Set the following in your `_config.yml` file:
|
55
|
-
- `algolia.application_id`: Application ID.
|
56
|
-
- `amethyst.algolia.search_only_api_key`: Search-Only API Key.
|
57
|
-
- `algolia.index_name`: Unique lowercase name for the current site (e.g. example-com or example-com-foo).
|
58
|
-
This index will be automatically created by GitHub Actions after the next commit.
|
59
|
-
4. Create a repository secret on GitHub, named `ALGOLIA_API_KEY`, with the "Admin API Key".
|
52
|
+
Optional autocompletion with search suggestions.
|
60
53
|
|
61
|
-
|
54
|
+
1. Follow [Create scraper](https://github.com/jquery/infrastructure-puppet/blob/staging/doc/search.md). Feel free to ask the jQuery Infrastructure Team for help.
|
55
|
+
2. Set the following in your `_config.yml` file:
|
56
|
+
- `amethyst.typesense.origin`: <https://typesense.jquery.com>
|
57
|
+
- `amethyst.typesense.collection`: Unique lowercase name for the current site (e.g. example_com or example_foo).
|
58
|
+
This should match the index name used by your scraper.
|
59
|
+
- `amethyst.typesense.search_only_api_key`: Search-only key (copy from another repo, or consult the jQuery Infrastucture credentials vault.)
|
62
60
|
|
63
|
-
Done! The presence of these settings will automatically enable
|
64
|
-
|
65
|
-
Terminology:
|
66
|
-
|
67
|
-
* **application**:
|
68
|
-
A group of one or more search indexes with an associated "team" of users that can administer those indexes. The application is generally named after a top-level project (e.g. "QUnit") with one or more indexes for its sites (e.g. qunitjs-com and qunitjs-com-api).
|
69
|
-
|
70
|
-
Applications need to be created from the Algolia control panel. The Application IDs are considered public information, and look like `ABCDEF0124`.
|
71
|
-
|
72
|
-
* **index**:
|
73
|
-
An index holds the crawled content. These do not need to be created ahead of time. The CI builds will create these as-needed.
|
74
|
-
|
75
|
-
As example, qunitjs.com content may be un a `qunit-com` index, and api.qunitjs.com content under `api-qunitjs-com`. Whenever a site is deployed, the index is replaced with the new content. This is why different subdomains or subprojects that have their own repository should have their own index as otherwise content of the "other" sites would be lost.
|
76
|
-
|
77
|
-
Search suggestions may come from multiple indexes at once. See [Amethyst config](./config.md#readme) for how.
|
61
|
+
Done! The presence of these settings will automatically enable autocompletion on the search field.
|
@@ -0,0 +1,60 @@
|
|
1
|
+
{
|
2
|
+
"index_name": "amethyst_demo",
|
3
|
+
"start_urls": [
|
4
|
+
{ "url": "https://qunitjs.github.io/jekyll-theme-amethyst/api/", "selectors_key": "api", "page_rank": 20 },
|
5
|
+
{ "url": "https://qunitjs.github.io/jekyll-theme-amethyst/\\d{4}/", "selectors_key": "blog", "page_rank": 1 },
|
6
|
+
{ "url": "https://qunitjs.github.io/jekyll-theme-amethyst/", "page_rank": 10 }
|
7
|
+
],
|
8
|
+
"stop_content": [
|
9
|
+
"<meta name=\"docsearch:amethyst_pagetype_navigation\""
|
10
|
+
],
|
11
|
+
"selectors": {
|
12
|
+
"default": {
|
13
|
+
"lvl0": "h1",
|
14
|
+
"lvl1": "h2",
|
15
|
+
"lvl2": "h3",
|
16
|
+
"lvl3": "h4",
|
17
|
+
"lvl4": "h5",
|
18
|
+
"lvl5": "h6",
|
19
|
+
"text": ".content p, .content li"
|
20
|
+
},
|
21
|
+
"api": {
|
22
|
+
"lvl0": {
|
23
|
+
"// selector": "This is like qSA('p.post-meta .category')[0], match the first category only",
|
24
|
+
"selector": "//article//p[contains(@class,'post-meta')]//*[contains(@class,'category')][1]",
|
25
|
+
"type": "xpath",
|
26
|
+
"global": true,
|
27
|
+
"default_value": "Documentation"
|
28
|
+
},
|
29
|
+
"lvl1": "h1",
|
30
|
+
"lvl2": "h2:not(.screen-reader-text)",
|
31
|
+
"lvl3": "h3:not(.screen-reader-text)",
|
32
|
+
"lvl4": "h4:not(.screen-reader-text)",
|
33
|
+
"lvl5": "h5:not(.screen-reader-text)",
|
34
|
+
"text": ".content p, .content li, .content tr, .content pre"
|
35
|
+
},
|
36
|
+
"blog": {
|
37
|
+
"lvl0": {
|
38
|
+
"selector": "",
|
39
|
+
"global": true,
|
40
|
+
"default_value": "Blog"
|
41
|
+
},
|
42
|
+
"lvl1": "h1",
|
43
|
+
"lvl2": "h2",
|
44
|
+
"lvl3": "h3",
|
45
|
+
"lvl4": "h4",
|
46
|
+
"lvl5": "h5",
|
47
|
+
"text": ".content p, .content li"
|
48
|
+
}
|
49
|
+
},
|
50
|
+
"custom_settings": {
|
51
|
+
"token_separators": ["_", "-", "."]
|
52
|
+
},
|
53
|
+
"selectors_exclude": [
|
54
|
+
"aside.sidebar",
|
55
|
+
".toc-wrapper"
|
56
|
+
],
|
57
|
+
"min_indexed_level": 1,
|
58
|
+
"scrape_start_urls": false
|
59
|
+
}
|
60
|
+
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jekyll-theme-amethyst
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Timo Tijhof
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2023-
|
12
|
+
date: 2023-05-10 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: jekyll
|
@@ -121,12 +121,11 @@ executables: []
|
|
121
121
|
extensions: []
|
122
122
|
extra_rdoc_files: []
|
123
123
|
files:
|
124
|
-
- ".github/workflows/doc-search.yaml"
|
125
124
|
- ".github/workflows/gem.yaml"
|
126
125
|
- ".github/workflows/github-pages.yaml"
|
127
126
|
- ".github/workflows/spider-check.yaml"
|
127
|
+
- ".github/workflows/typesense.yaml"
|
128
128
|
- ".gitignore"
|
129
|
-
- ".meilisearch.json"
|
130
129
|
- 404.md
|
131
130
|
- Gemfile
|
132
131
|
- LICENSE.txt
|
@@ -136,7 +135,6 @@ files:
|
|
136
135
|
- _data/sidebar_blog.yml
|
137
136
|
- _data/sitenav.yml
|
138
137
|
- _includes/opengraph.html
|
139
|
-
- _includes/search-js.html
|
140
138
|
- _includes/search.html
|
141
139
|
- _includes/sidebar.html
|
142
140
|
- _includes/toc.html
|
@@ -184,12 +182,14 @@ files:
|
|
184
182
|
- api/lorem/index.md
|
185
183
|
- api/lorem/sit.md
|
186
184
|
- api/removed.md
|
187
|
-
- assets/logo-algolia.svg
|
188
185
|
- assets/styles.scss
|
186
|
+
- assets/typesense-minibar.css
|
187
|
+
- assets/typesense-minibar.js
|
189
188
|
- blog-archive.md
|
190
189
|
- blog.md
|
191
190
|
- docs/config.md
|
192
191
|
- docs/getting-started.md
|
192
|
+
- docsearch.config.json
|
193
193
|
- favicon.svg
|
194
194
|
- index.md
|
195
195
|
- intro.md
|
@@ -1,37 +0,0 @@
|
|
1
|
-
name: Update search index
|
2
|
-
on:
|
3
|
-
# For Algolia, we can update search right away in parallel
|
4
|
-
# with the github-pages build, since it pushes content
|
5
|
-
# into the index from the local working directory.
|
6
|
-
push:
|
7
|
-
branches:
|
8
|
-
- main
|
9
|
-
# For MeiliSearch, we crawl the site after it has been
|
10
|
-
# built and published by the github-pages workflow
|
11
|
-
workflow_run:
|
12
|
-
workflows:
|
13
|
-
- github-pages
|
14
|
-
types:
|
15
|
-
- completed
|
16
|
-
# Or manually
|
17
|
-
workflow_dispatch:
|
18
|
-
|
19
|
-
jobs:
|
20
|
-
run:
|
21
|
-
name: Algolia
|
22
|
-
runs-on: ubuntu-20.04
|
23
|
-
steps:
|
24
|
-
- uses: actions/checkout@v2
|
25
|
-
|
26
|
-
- uses: ruby/setup-ruby@v1
|
27
|
-
# If your site is in a subdirectory
|
28
|
-
# working-directory: ./
|
29
|
-
with:
|
30
|
-
ruby-version: 2.7
|
31
|
-
bundler-cache: true
|
32
|
-
|
33
|
-
- run: bundle exec jekyll algolia
|
34
|
-
# If your site is in a subdirectory
|
35
|
-
# working-directory: ./
|
36
|
-
env:
|
37
|
-
ALGOLIA_API_KEY: "${{ secrets.ALGOLIA_API_KEY }}"
|
data/.meilisearch.json
DELETED
@@ -1,20 +0,0 @@
|
|
1
|
-
{
|
2
|
-
"index_uid": "jekyll-theme-amethyst",
|
3
|
-
"start_urls": ["https://qunitjs.github.io/jekyll-theme-amethyst/"],
|
4
|
-
"stop_urls": [],
|
5
|
-
"selectors": {
|
6
|
-
"default": {
|
7
|
-
"lvl0": {
|
8
|
-
"selector": ".sidebar-title-open",
|
9
|
-
"global": true,
|
10
|
-
"default_value": "Documentation"
|
11
|
-
},
|
12
|
-
"lvl1": "h1",
|
13
|
-
"lvl2": "h2",
|
14
|
-
"lvl3": "h3",
|
15
|
-
"lvl4": "h4",
|
16
|
-
"lvl5": "h5",
|
17
|
-
"content": "p,li,tr,pre"
|
18
|
-
}
|
19
|
-
}
|
20
|
-
}
|