Basic duckduckgo search

This commit is contained in:
Simon-Martens
2023-12-12 13:52:26 +01:00
parent 76eaaed321
commit 3010e265a7
17 changed files with 119 additions and 49 deletions

View File

@@ -0,0 +1,14 @@
---
permalink: /index.json
---
[
{% for character in collections.characters %}
{
"title":"{{ character.data.title }}",
"url":"{{ character.url }}",
"content":"{% excerpt character %}"
}
{% if forloop.last == false %},{% endif %}
{% endfor %}
]

View File

@@ -1,8 +1,11 @@
<div class="hidden desktop:block">
<div class="bg-slate-50 border-t border-lenz-11-blue py-5 px-4">
<form class="flex flex-row w-full">
<input class="px-1.5 italic border border-gray-500 grow" type="text" placeholder="Suchbegriff..." disabled/>
<button class="inline-block ml-2 px-2 border border-gray-500 text-gray-500 italic " disabled>Suche</button>
<form action="https://duckduckgo.com/" method="get" id="global-search-form" class="flex flex-row w-full">
<div class="flex flex-row w-full">
<input class="px-1.5 italic border border-gray-500 grow" type="text" name="q" placeholder="Suchbegriff..." required/>
<button id="global-search-button" class="inline-block ml-2 px-2 border border-gray-500 text-gray-500 italic" type="submit" >Suche</button>
</div>
<input class="grow-0 shrink" type="hidden" name="sites" value="{{ config.url }}">
</form>
</div>
</div>

10
src/static/js/search.js Normal file
View File

@@ -0,0 +1,10 @@
// attach a click handler to the search link
var btn = document.querySelector('#global-search-form');
btn.addEventListener('submit', function(event) {
// don't navigate to that page. Stay put.
event.preventDefault();
// make search magic happen instead...
}, false);