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

@ -16,8 +16,9 @@ $(function(){
$("div#landlord").mouseleave(function () { $("div#landlord").mouseleave(function () {
$("div.live_ico_box").fadeOut(); $("div.live_ico_box").fadeOut();
}); });
var BlogAPI = "https://summary.mayx.eu.org";
function showHitS(hits) { function showHitS(hits) {
$.get("https://summary.mayx.eu.org/count_click?id="+hits.id,function(data){ $.get(BlogAPI + "/count_click?id=" + hits.id, function (data) {
hits.innerHTML = Number(data); hits.innerHTML = Number(data);
}); });
} }
@ -30,7 +31,7 @@ function showHitCount() {
} }
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);
}); });
} }
@ -41,6 +42,24 @@ if ($('.visitors').length == 1) {
} }
}); });
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 />";
});
});
});
}
today = new Date(); today = new Date();
timeold = (today.getTime() - lastUpdated.getTime()); timeold = (today.getTime() - lastUpdated.getTime());
secondsold = Math.floor(timeold / 1000); secondsold = Math.floor(timeold / 1000);
@ -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 %}
]