new_site/_includes/scripts/search.liquid

25 lines
893 B
Plaintext

{% if site.search_enabled %}
<script type="module" src="{{ '/assets/js/search/ninja-keys.min.js' | relative_url | bust_file_cache }}"></script>
<ninja-keys hideBreadcrumbs noAutoLoadMdIcons placeholder="Type to start searching"></ninja-keys>
<script src="{{ '/assets/js/search-data.js' | relative_url | bust_file_cache }}"></script>
<script>
let theme = determineComputedTheme();
const ninjaKeys = document.querySelector('ninja-keys');
if (theme === 'dark') {
ninjaKeys.classList.add('dark');
} else {
ninjaKeys.classList.remove('dark');
}
const openSearchModal = () => {
// collapse navbarNav if expanded on mobile
const navbarNav = document.querySelector('.navbar-collapse');
if (navbarNav.classList.contains('show')) {
navbarNav.classList.remove('show');
}
ninjaKeys.open();
};
</script>
{% endif %}