mirror of
https://github.com/flysnow-org/maupassant-hugo.git
synced 2026-08-24 07:18:55 +00:00
fix local search bugs
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
<form id="search" action="{{if .Site.Params.localSearch }}/search/{{else}}//www.google.com/search{{end}}" method="get" accept-charset="utf-8" target="_blank" _lpchecked="1">
|
||||
<form id="search" action='{{if .Site.Params.localSearch }}{{ "search"| absURL}}{{else}}//www.google.com/search{{end}}' method="get" accept-charset="utf-8" target="_blank" _lpchecked="1">
|
||||
{{/** the keywords **/}}
|
||||
<input type="text" name="q" maxlength="20" placeholder="Search">
|
||||
<input type="hidden" name="sitesearch" value="{{ .Site.BaseURL }}">
|
||||
|
||||
@@ -61,13 +61,13 @@ var getUrlParameter = function getUrlParameter(sParam) {
|
||||
$("span.keyword").text(q);
|
||||
$("article.post").remove();
|
||||
$.ajax({
|
||||
url: "/index.xml",
|
||||
url: '{{"index.xml"|absURL}}',
|
||||
dataType: "xml",
|
||||
success: function(data) {
|
||||
$(data).find("item").each(function () {
|
||||
var item=$(this);
|
||||
var title=item.find("title").text();
|
||||
if (title.indexOf(q) > 0){
|
||||
if (title.toLowerCase().indexOf(q.toLowerCase()) > 0){
|
||||
var url = item.find("link").text();
|
||||
var searchItem=`<article class="post"><header><h1 class="post-title"><a href="`+url+`">`+title+`</a></h1></header>`;
|
||||
var pubDate = new Date(item.find("pubDate").text())
|
||||
|
||||
Reference in New Issue
Block a user