Commit 9bdb8b04 by sbiego

custom duckduckgo search

parent 42965a15
{{ if isset .Site.Params.widgets "search" }}
{{ if .Site.Params.widgets.search }}
<div class="panel panel-default sidebar-menu">
<div class="panel-heading">
<h3 class="panel-title">{{ i18n "searchTitle" }}</h3>
</div>
<div class="panel-body">
<!-- USING https://blog.vrobot.uk/post/add-duckduckgo-search-to-a-hugo-generated-blog/ -->
<form onsubmit="myFunction(searchboxid); return false;" >
<input type="search" id="searchboxid" placeholder="Search" />
<button type="submit" >Search</button>
</form>
<script language="javascript">
function myFunction(searchboxid) {
if (window.location.hostname == "localhost") {
console.log( "Running on localhost not a proper domain so cannot search via duckduckgo.com" );
return;
}
var q = document.getElementById('searchboxid').value;
q = encodeURIComponent( q );
// var site = "rv1.tech";
var site = "{{ .Site.BaseURL }}" ;
var url = "https://duckduckgo.com?q=" + q + "+site:" + site;
console.log( url );
window.open(url, "_self");
}
</script>
<!-- <form action="//google.com/search" method="get" accept-charset="UTF-8" role="search">
<div class="input-group">
<input type="search" name="q" results="0" class="form-control" placeholder="{{ i18n "searchTitle" }}">
<input type="hidden" name="q" value="site:{{ .Site.BaseURL }}">
<span class="input-group-btn">
<button type="submit" class="btn btn-template-main"><i class="fa fa-search"></i></button>
</span>
</div>
</form> -->
</div>
</div>
{{ end }}
{{ end }}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment