update
This commit is contained in:
parent
2468337f69
commit
b0f60fb917
|
@ -64,7 +64,6 @@ article:
|
||||||
# npm i hexo-related-popular-posts
|
# npm i hexo-related-popular-posts
|
||||||
related_posts:
|
related_posts:
|
||||||
enable: false
|
enable: false
|
||||||
title: meta.related_posts
|
|
||||||
max_count: 5
|
max_count: 5
|
||||||
placeholder_img: https://7.dusays.com/2021/02/20/76b86c0226ffd.svg
|
placeholder_img: https://7.dusays.com/2021/02/20/76b86c0226ffd.svg
|
||||||
# 分享文章
|
# 分享文章
|
||||||
|
@ -134,6 +133,8 @@ plugins:
|
||||||
enable: true
|
enable: true
|
||||||
css: https://unpkg.com/swiper/swiper-bundle.min.css
|
css: https://unpkg.com/swiper/swiper-bundle.min.css
|
||||||
js: https://unpkg.com/swiper/swiper-bundle.min.js
|
js: https://unpkg.com/swiper/swiper-bundle.min.js
|
||||||
|
# issues api
|
||||||
|
issuesjs: /js/issues.js
|
||||||
|
|
||||||
## optional plugins ##
|
## optional plugins ##
|
||||||
# preload
|
# preload
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<%
|
<%
|
||||||
function getTitle() {
|
function generate_title() {
|
||||||
if (page.seo_title || page.title || page.wiki || page.layout) {
|
if (page.seo_title || page.title || page.wiki || page.layout) {
|
||||||
return (page.seo_title || page.title || page.wiki || page.layout) + ' - ' + config.title;
|
return (page.seo_title || page.title || page.wiki || page.layout) + ' - ' + config.title;
|
||||||
} else if (page.category) {
|
} else if (page.category) {
|
||||||
|
@ -11,8 +11,18 @@ function getTitle() {
|
||||||
}
|
}
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
if (page.description == undefined) {
|
function generate_robots() {
|
||||||
page.description = stellar_meta('description', page);
|
if (is_home() == true) {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
if (page.robots) {
|
||||||
|
return '<meta name="robots" content="' + page.robots + '">';
|
||||||
|
} else {
|
||||||
|
// default rule
|
||||||
|
if (['post', 'wiki', 'index'].includes(page.layout) == false) {
|
||||||
|
return '<meta name="robots" content="noindex,nofollow">';
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
function og_args() {
|
function og_args() {
|
||||||
var args = {};
|
var args = {};
|
||||||
|
@ -28,7 +38,7 @@ function og_args() {
|
||||||
<head hexo-theme='<%- stellar_info("tree") %>'>
|
<head hexo-theme='<%- stellar_info("tree") %>'>
|
||||||
<%- meta_generator() %>
|
<%- meta_generator() %>
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<meta name='robots' content='<%- stellar_meta("robots", page) %>'>
|
<%- generate_robots() %>
|
||||||
|
|
||||||
<meta http-equiv='x-dns-prefetch-control' content='on' />
|
<meta http-equiv='x-dns-prefetch-control' content='on' />
|
||||||
<link rel='dns-prefetch' href='https://cdn.jsdelivr.net'>
|
<link rel='dns-prefetch' href='https://cdn.jsdelivr.net'>
|
||||||
|
@ -41,7 +51,7 @@ function og_args() {
|
||||||
<meta name="apple-mobile-web-app-capable" content="yes">
|
<meta name="apple-mobile-web-app-capable" content="yes">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
|
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
|
||||||
|
|
||||||
<title><%- getTitle() %></title>
|
<title><%- generate_title() %></title>
|
||||||
|
|
||||||
<% if (theme.open_graph && theme.open_graph.enable) { %>
|
<% if (theme.open_graph && theme.open_graph.enable) { %>
|
||||||
<%- open_graph(og_args()) %>
|
<%- open_graph(og_args()) %>
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
<% let post = page; %>
|
|
||||||
<div class='related-posts-wrap'><%-
|
<div class='related-posts-wrap'><%-
|
||||||
popular_posts_wrapper({
|
popular_posts_wrapper({
|
||||||
title: __('meta.related_posts'),
|
title: __('meta.related_posts'),
|
||||||
json: popular_posts_json({ maxCount: 5 , ulClass: 'related-posts' , PPMixingRate: 0.2 , isImage: true , isExcerpt: true} , post )
|
json: popular_posts_json({ maxCount: 5 , ulClass: 'related-posts' , PPMixingRate: 0.2 , isImage: true , isExcerpt: true} , page )
|
||||||
}) %></div>
|
}) %></div>
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
function loadIssuesJS() {
|
function loadIssuesJS() {
|
||||||
const issues = document.getElementById('issues-api');
|
const issues = document.getElementById('issues-api');
|
||||||
if (issues != undefined) {
|
if (issues != undefined) {
|
||||||
loadScript('<%- url_for("/js/issues.js") %>');
|
loadScript('<%- url_for(theme.plugins.issuesjs || "/js/issues.js") %>');
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
$(function () {
|
$(function () {
|
||||||
|
|
|
@ -1,44 +0,0 @@
|
||||||
'use strict';
|
|
||||||
|
|
||||||
var util = require('hexo-util');
|
|
||||||
|
|
||||||
hexo.extend.helper.register('stellar_meta', function(args, page){
|
|
||||||
if (['robots', 'description'].includes(args) == false) {
|
|
||||||
return '';
|
|
||||||
}
|
|
||||||
function meta(str) {
|
|
||||||
if (str && str.length > 0) {
|
|
||||||
return str;
|
|
||||||
} else {
|
|
||||||
return '';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (args == 'robots') {
|
|
||||||
if (page.__index == true) {
|
|
||||||
return '';
|
|
||||||
}
|
|
||||||
if (page.robots) {
|
|
||||||
meta(page.robots);
|
|
||||||
} else {
|
|
||||||
// default rule
|
|
||||||
if (['post', 'wiki', 'index'].includes(page.layout) == false) {
|
|
||||||
meta('noindex,nofollow');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else if (args == 'description') {
|
|
||||||
if (page.__index == true) {
|
|
||||||
meta(hexo.config.description);
|
|
||||||
} else if (page.description) {
|
|
||||||
meta(util.stripHTML(page.description));
|
|
||||||
} else if (['post', 'wiki'].includes(page.layout)) {
|
|
||||||
var description = '';
|
|
||||||
if (page.excerpt && page.excerpt.length > 0) {
|
|
||||||
description = util.stripHTML(page.excerpt);
|
|
||||||
} else if (page.content && page.content.length > 0) {
|
|
||||||
description = util.truncate(util.stripHTML(page.content), {length: 160});
|
|
||||||
}
|
|
||||||
meta(description);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return '';
|
|
||||||
});
|
|
Loading…
Reference in New Issue