Skip to content

Commit 8483025

Browse files
committed
feat: Make search usable via keyboard (CTRL + K)
1 parent fb6f86d commit 8483025

File tree

3 files changed

+19
-5
lines changed

3 files changed

+19
-5
lines changed

i18n/de.yaml

+1-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@ country:
33
one: Land
44
many: Länder
55
other: Länder
6-
search-placeholder: Gib ein Land oder Bahnunternehmen ein
7-
search-button: Suchen
6+
search-placeholder: Suche
87
footer-love:
98
text: Made with ♥️ in Frankfurt & Köln
109
aria-label: Made with love in Frankfurt & Köln

i18n/en.yaml

+1-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@ country:
33
one: country
44
many: countries
55
other: countries
6-
search-placeholder: Type in a country or train operator
7-
search-button: Search
6+
search-placeholder: Search
87
footer-love:
98
text: Made with ♥️ in Frankfurt & Cologne
109
aria-label: Made with love in Frankfurt & Cologne

layouts/partials/stage.html

+17-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,22 @@
11
<script>
22
window.addEventListener('DOMContentLoaded', (event) => {
3-
new PagefindUI({ element: "#search", highlightParam: "highlight", showSubResults: true });
3+
new PagefindUI({
4+
element: "#search",
5+
highlightParam: "highlight",
6+
showSubResults: true,
7+
translations: {
8+
placeholder: '{{ print (T "search-placeholder") " (CTRL + K)" }}'
9+
}
10+
});
11+
});
12+
document.addEventListener('keydown', (e) => {
13+
if (e.ctrlKey && e.key === 'k') {
14+
e.preventDefault();
15+
const searchElement = document.querySelector('#search input');
16+
if (searchElement) {
17+
searchElement.focus();
18+
}
19+
}
420
});
521
</script>
622

0 commit comments

Comments
 (0)