Update 3 files

- /js/main.js
- /_layouts/post.html
- /search.json
This commit is contained in:
mayx 2024-09-30 13:51:26 +00:00
parent 550321e80a
commit 07a3d18350
3 changed files with 56 additions and 48 deletions

View File

@ -80,7 +80,7 @@ layout: default
{% if page.tags %} {% if page.tags %}
<small>tags: <em>{{ page.tags | join: "</em> - <em>" }}</em></small> <small>tags: <em>{{ page.tags | join: "</em> - <em>" }}</em></small>
{% endif %} {% endif %}
<p id="suggest-container"><button onclick="getSuggestBlog('{{ page.url }}')">查看推荐文章</button></p>
<div class="pagination"> <div class="pagination">
{% if page.previous.url %} {% if page.previous.url %}
<span class="prev"> <span class="prev">

View File

@ -1,45 +1,64 @@
(function() { (function () {
var $backToTopTxt = "返回顶部", $backToTopEle = $('<div class="backToTop"></div>').appendTo($("body")) var $backToTopTxt = "返回顶部", $backToTopEle = $('<div class="backToTop"></div>').appendTo($("body"))
.text($backToTopTxt).attr("title", $backToTopTxt).click(function() { .text($backToTopTxt).attr("title", $backToTopTxt).click(function () {
$("html, body").animate({ scrollTop: 0 }, 120); $("html, body").animate({ scrollTop: 0 }, 120);
}), $backToTopFun = function() { }), $backToTopFun = function () {
var st = $(document).scrollTop(), winh = $(window).height(); var st = $(document).scrollTop(), winh = $(window).height();
(st > 0)? $backToTopEle.show(): $backToTopEle.hide(); (st > 0) ? $backToTopEle.show() : $backToTopEle.hide();
}; };
$(window).bind("scroll", $backToTopFun); $(window).bind("scroll", $backToTopFun);
$(function() { $backToTopFun(); }); $(function () { $backToTopFun(); });
})(); })();
$(function(){ $(function () {
$("div#landlord").mouseenter(function(){ $("div#landlord").mouseenter(function () {
$("div.live_ico_box").fadeIn(); $("div.live_ico_box").fadeIn();
}); });
$("div#landlord").mouseleave(function(){ $("div#landlord").mouseleave(function () {
$("div.live_ico_box").fadeOut(); $("div.live_ico_box").fadeOut();
}); });
function showHitS(hits){ var BlogAPI = "https://summary.mayx.eu.org";
$.get("https://summary.mayx.eu.org/count_click?id="+hits.id,function(data){ function showHitS(hits) {
hits.innerHTML=Number(data); $.get(BlogAPI + "/count_click?id=" + hits.id, function (data) {
hits.innerHTML = Number(data);
}); });
}
function showHitCount() {
var visitors=$(".visitors-index");
for(var i = 0; i < visitors.length; i++){
showHitS(visitors[i]);
} }
function showHitCount() {
var visitors = $(".visitors-index");
for (var i = 0; i < visitors.length; i++) {
showHitS(visitors[i]);
}
} }
function addCount() { function addCount() {
var visitors=$(".visitors"); var visitors = $(".visitors");
$.get("https://summary.mayx.eu.org/count_click_add?id="+visitors[0].id,function(data){ $.get(BlogAPI + "/count_click_add?id=" + visitors[0].id, function (data) {
visitors[0].innerHTML=Number(data); visitors[0].innerHTML = Number(data);
});
}
if ($('.visitors').length == 1) {
addCount();
} else if ($('.visitors-index').length > 0) {
showHitCount();
}
});
function getSuggestBlog(blogurl) {
var suggest = $("#suggest-container")[0];
suggest.innerHTML = "Loading...";
$.get(BlogAPI + "/suggest?id=" + blogurl, function (data) {
getSearchJSON(function (search) {
suggest.innerHTML = "";
const searchMap = new Map(search.map(item => [item.url, item]));
const merged = data.map(suggestObj => {
const searchObj = searchMap.get(suggestObj.id);
return searchObj ? { ...searchObj } : suggestObj;
});
merged.forEach(element => {
suggest.innerHTML += "<a href=" + element.url + ">" + element.title + "</a> - " + element.date + "<br />";
});
});
}); });
} }
if ($('.visitors').length == 1) {
addCount();
} else if ($('.visitors-index').length > 0){
showHitCount();
}
});
today = new Date(); today = new Date();
timeold = (today.getTime() - lastUpdated.getTime()); timeold = (today.getTime() - lastUpdated.getTime());
@ -53,4 +72,4 @@ if (daysold > 90) {
} }
var message_Path = '/Live2dHistoire/live2d/'; var message_Path = '/Live2dHistoire/live2d/';
var talkAPI = "https://summary.mayx.workers.dev/ai_chat"; var talkAPI = BlogAPI + "/ai_chat";

View File

@ -1,14 +1,3 @@
--- ---
--- ---
[ [{% for post in site.posts %}{% unless post.layout == "encrypt" %}{ "title": "{{ post.title | escape }}", "category": "{{ post.category }}", "tags": "{{ post.tags | join: ', ' }}", "url": "{{ site.baseurl }}{{ post.url }}", "date": "{{ post.date | date: "%Y/%m/%d" }}", "content": {{ post.content | strip_html | strip_newlines | jsonify }} }{% unless forloop.last %},{% endunless %}{% endunless %}{% endfor %}]
{% for post in site.posts %}{% unless post.layout == "encrypt" %}
{
"title" : "{{ post.title | escape }}",
"category" : "{{ post.category }}",
"tags" : "{{ post.tags | join: ', ' }}",
"url" : "{{ site.baseurl }}{{ post.url }}",
"date" : "{{ post.date | date: "%Y/%m/%d" }}",
"content": {{ post.content | strip_html | strip_newlines | jsonify }}
}{% unless forloop.last %},{% endunless %}{% endunless %}
{% endfor %}
]