fix: search shortcut based on user platform (#101)

* fix: search shortcut based on user platform

* chore: make it work with iPad and iPhone as well
This commit is contained in:
Xin
2023-09-27 19:47:20 +01:00
committed by GitHub
parent 46dea718e6
commit ec02eb34fe
2 changed files with 12 additions and 1 deletions

View File

@ -1,5 +1,16 @@
// Search functionality using FlexSearch.
// Change shortcut key to cmd+k on Mac, iPad or iPhone.
document.addEventListener("DOMContentLoaded", function () {
if (/iPad|iPhone|Macintosh/.test(navigator.userAgent)) {
// select the kbd element under the .search-wrapper class
const keys = document.querySelectorAll(".search-wrapper kbd");
keys.forEach(key => {
key.innerHTML = '<span class="text-xs">⌘</span>K';
});
}
});
// Render the search data as JSON.
// {{ $searchDataFile := printf "%s.search-data.json" .Language.Lang }}
// {{ $searchData := resources.Get "json/search-data.json" | resources.ExecuteAsTemplate $searchDataFile . }}