forked from flysnow-org/maupassant-hugo
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
support local search,close flysnow-org#55
- Loading branch information
1 parent
64423e0
commit 00004c9
Showing
5 changed files
with
143 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
{{ partial "head" . }} | ||
|
||
<body> | ||
{{ partial "header" . }} | ||
|
||
<div id="body"> | ||
<div class="container"> | ||
<div class="col-group"> | ||
|
||
<div class="col-8" id="main"> | ||
<div class="res-cons"> | ||
<h3 class="archive-title"> | ||
搜索 | ||
<span class="keyword">哈哈</span> | ||
的结果 | ||
</h3> | ||
|
||
<article class="post"> | ||
<header> | ||
<h1 class="post-title"> | ||
<a href="链接">标题</a> | ||
</h1> | ||
</header> | ||
<date class="post-meta meta-date"> | ||
2019年12月01日 | ||
</date> | ||
<div class="post-content"> | ||
概要…… | ||
<p class="readmore"><a href="链接">阅读全文</a></p> | ||
</div> | ||
</article> | ||
|
||
</div> | ||
</div> | ||
|
||
{{ partial "sidebar" . }} | ||
</div> | ||
</div> | ||
</div> | ||
{{ partial "footer" . }} | ||
|
||
<script type="text/javascript"> | ||
|
||
var getUrlParameter = function getUrlParameter(sParam) { | ||
var sPageURL = window.location.search.substring(1), | ||
sURLVariables = sPageURL.split('&'), | ||
sParameterName, | ||
i; | ||
|
||
for (i = 0; i < sURLVariables.length; i++) { | ||
sParameterName = sURLVariables[i].split('='); | ||
|
||
if (sParameterName[0] === sParam) { | ||
return sParameterName[1] === undefined ? true : decodeURIComponent(sParameterName[1]); | ||
} | ||
} | ||
}; | ||
|
||
$(document).ready(function() { | ||
var q = getUrlParameter("q"); | ||
$("span.keyword").text(q); | ||
$("article.post").remove(); | ||
$.ajax({ | ||
url: "/index.xml", | ||
dataType: "xml", | ||
success: function(data) { | ||
$(data).find("item").each(function () { | ||
var item=$(this); | ||
var title=item.find("title").text(); | ||
if (title.indexOf(q) > 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()) | ||
searchItem+=`<date class="post-meta meta-date">`+pubDate.getFullYear()+`年`+(pubDate.getMonth()+1)+`月`+pubDate.getDate()+`日</date>`; | ||
searchItem+=`<div class="post-content">`+item.find("description").text()+`……<p class="readmore"><a href="`+url+`">阅读全文</a></p></div></article>`; | ||
|
||
$("div.res-cons").append(searchItem); | ||
} | ||
}); | ||
} | ||
}); | ||
}); | ||
</script> | ||
</body> | ||
</html> |