update
This commit is contained in:
parent
91f695daf0
commit
2468337f69
43
_config.yml
43
_config.yml
|
@ -9,31 +9,30 @@ stellar:
|
||||||
|
|
||||||
|
|
||||||
######## head tags ########
|
######## head tags ########
|
||||||
head:
|
open_graph:
|
||||||
open_graph: true
|
enable: true
|
||||||
twitter: false
|
twitter_id: # for open_graph meta
|
||||||
|
|
||||||
|
|
||||||
######## Sidebar ########
|
######## Sidebar ########
|
||||||
sidebar:
|
sidebar:
|
||||||
logo:
|
logo:
|
||||||
avatar: # default is config.avatar
|
avatar:
|
||||||
title: # default is config.title
|
src: # default is config.avatar
|
||||||
logo_action:
|
href: # set your user center page like: '/about/'
|
||||||
avatar: /about/
|
title: # default is config.title, you can set html tag like: '<img no-lazy height="32px" src="xxx"/>'
|
||||||
title: /
|
|
||||||
menu:
|
menu:
|
||||||
- class: post # post, wiki, about
|
post:
|
||||||
name: btn.blog
|
title: btn.blog
|
||||||
url: /
|
url: /
|
||||||
- class: wiki
|
wiki:
|
||||||
name: btn.wiki
|
title: btn.wiki
|
||||||
url: /wiki/
|
url: /wiki/
|
||||||
- class: friends
|
friends:
|
||||||
name: 友链
|
title: 友链
|
||||||
url: /friends/
|
url: /friends/
|
||||||
- class: about
|
about:
|
||||||
name: 关于
|
title: 关于
|
||||||
url: /about/
|
url: /about/
|
||||||
# Sidebar widgets
|
# Sidebar widgets
|
||||||
widgets:
|
widgets:
|
||||||
|
@ -65,7 +64,7 @@ article:
|
||||||
# npm i hexo-related-popular-posts
|
# npm i hexo-related-popular-posts
|
||||||
related_posts:
|
related_posts:
|
||||||
enable: false
|
enable: false
|
||||||
title: 您可能感兴趣的文章
|
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
|
||||||
# 分享文章
|
# 分享文章
|
||||||
|
@ -104,10 +103,8 @@ footer:
|
||||||
url: https://music.163.com/#/user/home?id=63035382
|
url: https://music.163.com/#/user/home?id=63035382
|
||||||
- icon: '<img src="https://7.dusays.com/2021/02/14/942ebbf1a4b91.svg"/>'
|
- icon: '<img src="https://7.dusays.com/2021/02/14/942ebbf1a4b91.svg"/>'
|
||||||
url: /comments/
|
url: /comments/
|
||||||
license: 'CC BY SA 4.0'
|
license: '[CC BY-NC-SA 4.0](https://creativecommons.org/licenses/by-nc-sa/4.0/)'
|
||||||
source:
|
source: #'[GitHub](https://github.com/xaoxuu/hexo-theme-stellar)'
|
||||||
where: GitHub
|
|
||||||
url: https://github.com/xaoxuu/site-source
|
|
||||||
|
|
||||||
|
|
||||||
######## Tag Plugins ########
|
######## Tag Plugins ########
|
||||||
|
@ -141,8 +138,8 @@ plugins:
|
||||||
## optional plugins ##
|
## optional plugins ##
|
||||||
# preload
|
# preload
|
||||||
preload:
|
preload:
|
||||||
enable: #true
|
enable: true
|
||||||
service: instant_page # instant_page, flying_pages
|
service: flying_pages # instant_page, flying_pages
|
||||||
instant_page: https://cdn.jsdelivr.net/gh/volantis-x/cdn-volantis@4.1.2/js/instant_page.js
|
instant_page: https://cdn.jsdelivr.net/gh/volantis-x/cdn-volantis@4.1.2/js/instant_page.js
|
||||||
flying_pages: https://cdn.jsdelivr.net/gh/gijo-varghese/flying-pages@2.1.2/flying-pages.min.js
|
flying_pages: https://cdn.jsdelivr.net/gh/gijo-varghese/flying-pages@2.1.2/flying-pages.min.js
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,6 @@ btn:
|
||||||
tag: Tag
|
tag: Tag
|
||||||
tags: Tags
|
tags: Tags
|
||||||
archives: Archives
|
archives: Archives
|
||||||
learn_more: Learn more
|
|
||||||
getting_started: Getting Started
|
getting_started: Getting Started
|
||||||
|
|
||||||
meta:
|
meta:
|
||||||
|
@ -19,19 +18,20 @@ meta:
|
||||||
read_next: READ NEXT
|
read_next: READ NEXT
|
||||||
older: Older
|
older: Older
|
||||||
references: References
|
references: References
|
||||||
|
related_posts: Related Posts
|
||||||
comment_title: Join the discussion
|
comment_title: Join the discussion
|
||||||
back_to_top: Back to top
|
back_to_top: Back to top
|
||||||
more: 'More %s'
|
more: 'More %s'
|
||||||
|
|
||||||
footer:
|
footer:
|
||||||
license: 'Unless otherwise specified, this site adopts the CC BY SA 4.0 license agreement.'
|
license: 'All articles in this blog are licensed under %s unless stating additionally.'
|
||||||
info_not_open_source: 'This site was created by %s, using [Stellar](https://github.com/xaoxuu/hexo-theme-stellar) as the theme.'
|
info_not_open_source: 'This site was deployed by %s using %s.'
|
||||||
info_open_source: 'This site was created by %s, using [Stellar](https://github.com/xaoxuu/hexo-theme-stellar) as the theme. You can find the source code of this site in [%s](%s).'
|
info_open_source: 'This site was deployed by %s using %s. You can find the source code in %s.'
|
||||||
|
|
||||||
page:
|
page:
|
||||||
error:
|
error:
|
||||||
what: Page Not Found
|
what: Page Not Found
|
||||||
why: The address may be entered incorrectly or the address has been deleted
|
why: The address may be entered incorrectly or the address has been deleted.
|
||||||
action: Back to Home
|
action: Back to Home
|
||||||
categories: '%s Categories'
|
categories: '%s Categories'
|
||||||
tags: '%s Tags'
|
tags: '%s Tags'
|
||||||
|
|
|
@ -9,7 +9,6 @@ btn:
|
||||||
tag: 标签
|
tag: 标签
|
||||||
tags: 标签
|
tags: 标签
|
||||||
archives: 归档
|
archives: 归档
|
||||||
learn_more: 了解详情
|
|
||||||
getting_started: 开始使用
|
getting_started: 开始使用
|
||||||
|
|
||||||
meta:
|
meta:
|
||||||
|
@ -19,12 +18,13 @@ meta:
|
||||||
read_next: 接下来阅读
|
read_next: 接下来阅读
|
||||||
older: 更早一篇
|
older: 更早一篇
|
||||||
references: 参考资料
|
references: 参考资料
|
||||||
|
related_posts: 您可能感兴趣的文章
|
||||||
comment_title: 快来参与讨论吧
|
comment_title: 快来参与讨论吧
|
||||||
back_to_top: 回到顶部
|
back_to_top: 回到顶部
|
||||||
more: '更多%s'
|
more: '更多%s'
|
||||||
|
|
||||||
footer:
|
footer:
|
||||||
license: '除非特别说明,本站采用 CC BY SA 4.0 许可协议。'
|
license: '本博客所有文章除特别声明外,均采用 %s 许可协议。转载请注明出处!'
|
||||||
info_not_open_source: '本站由 %s 创建,使用 [Stellar](https://github.com/xaoxuu/hexo-theme-stellar) 作为主题。'
|
info_not_open_source: '本站由 %s 创建,使用 [Stellar](https://github.com/xaoxuu/hexo-theme-stellar) 作为主题。'
|
||||||
info_open_source: '本站由 %s 创建,使用 [Stellar](https://github.com/xaoxuu/hexo-theme-stellar) 作为主题,您可以在 [%s](%s) 找到本站源码。'
|
info_open_source: '本站由 %s 创建,使用 [Stellar](https://github.com/xaoxuu/hexo-theme-stellar) 作为主题,您可以在 [%s](%s) 找到本站源码。'
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,6 @@ btn:
|
||||||
tag: 標籤
|
tag: 標籤
|
||||||
tags: 標籤
|
tags: 標籤
|
||||||
archives: 歸檔
|
archives: 歸檔
|
||||||
learn_more: 了解詳情
|
|
||||||
getting_started: 開始使用
|
getting_started: 開始使用
|
||||||
|
|
||||||
meta:
|
meta:
|
||||||
|
@ -19,12 +18,13 @@ meta:
|
||||||
read_next: 接下來閱讀
|
read_next: 接下來閱讀
|
||||||
older: 更早一篇
|
older: 更早一篇
|
||||||
references: 參考資料
|
references: 參考資料
|
||||||
|
related_posts: 您可能感興趣的文章
|
||||||
comment_title: 快來參與討論吧
|
comment_title: 快來參與討論吧
|
||||||
back_to_top: 回到頂部
|
back_to_top: 回到頂部
|
||||||
more: '更多%s'
|
more: '更多%s'
|
||||||
|
|
||||||
footer:
|
footer:
|
||||||
license: '除非特別說明,本站採用 CC BY SA 4.0 許可協議。'
|
license: '本網誌所有文章除特別聲明外,均採用 %s 許可協議。轉載請註明出處!'
|
||||||
info_not_open_source: '本站由 %s 創建,使用 [Stellar](https://github.com/xaoxuu/hexo-theme-stellar) 作為主題。'
|
info_not_open_source: '本站由 %s 創建,使用 [Stellar](https://github.com/xaoxuu/hexo-theme-stellar) 作為主題。'
|
||||||
info_open_source: '本站由 %s 創建,使用 [Stellar](https://github.com/xaoxuu/hexo-theme-stellar) 作為主題,您可以在 [%s](%s) 找到本站源碼。'
|
info_open_source: '本站由 %s 創建,使用 [Stellar](https://github.com/xaoxuu/hexo-theme-stellar) 作為主題,您可以在 [%s](%s) 找到本站源碼。'
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<%
|
<%
|
||||||
page.class = '404';
|
page.menu_id = '404';
|
||||||
page.layout = '404';
|
page.layout = '404';
|
||||||
page.comment_title = '';
|
page.comment_title = '';
|
||||||
page.header = false;
|
page.header = false;
|
||||||
|
|
|
@ -1,18 +0,0 @@
|
||||||
<%
|
|
||||||
function layoutDiv() {
|
|
||||||
var wrapper = '';
|
|
||||||
wrapper += '<div><hr>';
|
|
||||||
if (theme.footer.license) {
|
|
||||||
wrapper += markdown(__('footer.license', theme.footer.license));
|
|
||||||
}
|
|
||||||
const author = '[' + config.author + '](' + config.url + config.root + ')';
|
|
||||||
if (theme.footer.source && theme.footer.source.where && theme.footer.source.url) {
|
|
||||||
wrapper += markdown(__('footer.info_open_source', author, theme.footer.source.where, theme.footer.source.url));
|
|
||||||
} else {
|
|
||||||
wrapper += markdown(__('footer.info_not_open_source', author));
|
|
||||||
}
|
|
||||||
wrapper += '</div>';
|
|
||||||
return wrapper;
|
|
||||||
}
|
|
||||||
%>
|
|
||||||
<%- layoutDiv() %>
|
|
|
@ -1,16 +1,4 @@
|
||||||
<%
|
<%
|
||||||
function genrateRobots() {
|
|
||||||
var el = '';
|
|
||||||
if (page.robots) {
|
|
||||||
el += '<meta name="robots" content="' + page.robots + '">';
|
|
||||||
} else if (is_home() == false) {
|
|
||||||
if (['post', 'wiki', 'index'].includes(page.layout) == false) {
|
|
||||||
el += '<meta name="robots" content="noindex,nofollow">';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return el;
|
|
||||||
}
|
|
||||||
|
|
||||||
function getTitle() {
|
function getTitle() {
|
||||||
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;
|
||||||
|
@ -23,78 +11,25 @@ function getTitle() {
|
||||||
}
|
}
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
function getKeywords() {
|
if (page.description == undefined) {
|
||||||
if (page.keywords) {
|
page.description = stellar_meta('description', page);
|
||||||
return page.keywords;
|
|
||||||
} else if (page.tags && page.tags.length > 0) {
|
|
||||||
return page.tags.map(function(t){return t.name}).join(',');
|
|
||||||
}
|
|
||||||
return '';
|
|
||||||
}
|
}
|
||||||
function getDescription() {
|
function og_args() {
|
||||||
if (page.description) {
|
var args = {};
|
||||||
return page.description;
|
if (theme.open_graph.twitter_id) {
|
||||||
} else {
|
args.twitter_id = theme.open_graph.twitter_id;
|
||||||
if (['post', 'wiki'].includes(page.layout)) {
|
|
||||||
if (page.excerpt && page.excerpt.length > 0) {
|
|
||||||
return strip_html(page.excerpt);
|
|
||||||
} else if (page.content && page.content.length > 0) {
|
|
||||||
return truncate(strip_html(page.content), {length: 160});
|
|
||||||
}
|
}
|
||||||
|
if (page.layout == 'post' && page.cover) {
|
||||||
|
args.twitter_card = 'summary_large_image';
|
||||||
}
|
}
|
||||||
}
|
return args;
|
||||||
return '';
|
|
||||||
}
|
|
||||||
function genrateKeywords() {
|
|
||||||
const keywords = getKeywords();
|
|
||||||
if (keywords && keywords.length > 0) {
|
|
||||||
return '<meta name="keywords" content="' + keywords + '">';
|
|
||||||
} else {
|
|
||||||
return '';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
function genrateDescription() {
|
|
||||||
const description = getDescription();
|
|
||||||
if (description && description.length > 0) {
|
|
||||||
return '<meta name="description" content="' + description + '">';
|
|
||||||
} else {
|
|
||||||
return '';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
function genrateOpenGraph() {
|
|
||||||
if (theme.head.open_graph == false) {
|
|
||||||
return '';
|
|
||||||
}
|
|
||||||
var el = '';
|
|
||||||
el += '<meta property="og:title" content="' + getTitle() + '">';
|
|
||||||
el += '<meta property="og:description" content="' + getDescription() + '">';
|
|
||||||
el += '<meta property="og:locale" content="' + page.lang.replace('-', '_') + '">';
|
|
||||||
el += '<meta property="og:url" content="' + page.permalink + '">';
|
|
||||||
el += '<meta property="og:type" content="website">';
|
|
||||||
el += '<meta property="og:site_name" content="' + config.title + '">';
|
|
||||||
if (page.layout == 'post' && page.cover && page.cover.length > 0) {
|
|
||||||
el += '<meta property="og:image" content="' + page.cover + '">';
|
|
||||||
}
|
|
||||||
return el;
|
|
||||||
}
|
|
||||||
function genrateTwitter() {
|
|
||||||
if (theme.head.twitter == undefined || theme.head.twitter.length == 0 || theme.head.twitter == false) {
|
|
||||||
return '';
|
|
||||||
}
|
|
||||||
var el = '';
|
|
||||||
if (theme.head.twitter != 'true') {
|
|
||||||
el += '<meta property="twitter:site" content="@' + theme.head.twitter + '">';
|
|
||||||
}
|
|
||||||
if (page.layout == 'post' && page.cover && page.cover.length > 0) {
|
|
||||||
el += '<meta name="twitter:image" content="' + page.cover + '">';
|
|
||||||
el += '<meta name="twitter:card" content="summary_large_image">';
|
|
||||||
}
|
|
||||||
return el;
|
|
||||||
}
|
}
|
||||||
%>
|
%>
|
||||||
<head hexo-theme='https://github.com/xaoxuu/hexo-theme-stellar/tree/<%- theme.stellar.version %>'>
|
<head hexo-theme='<%- stellar_info("tree") %>'>
|
||||||
|
<%- meta_generator() %>
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<%- genrateRobots() %>
|
<meta name='robots' content='<%- stellar_meta("robots", page) %>'>
|
||||||
|
|
||||||
<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'>
|
||||||
<link rel="preconnect" href="https://cdn.jsdelivr.net" crossorigin>
|
<link rel="preconnect" href="https://cdn.jsdelivr.net" crossorigin>
|
||||||
|
@ -107,11 +42,10 @@ function genrateTwitter() {
|
||||||
<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><%- getTitle() %></title>
|
||||||
<%- genrateKeywords() %>
|
|
||||||
<%- genrateDescription() %>
|
|
||||||
<%- genrateOpenGraph() %>
|
|
||||||
<%- genrateTwitter() %>
|
|
||||||
|
|
||||||
|
<% if (theme.open_graph && theme.open_graph.enable) { %>
|
||||||
|
<%- open_graph(og_args()) %>
|
||||||
|
<% } %>
|
||||||
|
|
||||||
<!-- feed -->
|
<!-- feed -->
|
||||||
<% if (config.feed && config.feed.path) { %>
|
<% if (config.feed && config.feed.path) { %>
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
<% let post = page; %>
|
<% let post = page; %>
|
||||||
<div class='related-posts-wrap'><%-
|
<div class='related-posts-wrap'><%-
|
||||||
popular_posts_wrapper(
|
popular_posts_wrapper({
|
||||||
popular_posts_json({ maxCount: 5 , ulClass: 'related-posts' , PPMixingRate: 0.2 , isImage: true , isExcerpt: true} , post )
|
title: __('meta.related_posts'),
|
||||||
) %></div>
|
json: popular_posts_json({ maxCount: 5 , ulClass: 'related-posts' , PPMixingRate: 0.2 , isImage: true , isExcerpt: true} , post )
|
||||||
|
}) %></div>
|
||||||
|
|
|
@ -0,0 +1,20 @@
|
||||||
|
<%
|
||||||
|
const author = '[' + config.author + '](' + config.url + config.root + ')';
|
||||||
|
const using = '[' + stellar_info('name') + '](' + stellar_info('tree') + ')';
|
||||||
|
const source = theme.footer.source;
|
||||||
|
function layoutDiv() {
|
||||||
|
var wrapper = '';
|
||||||
|
wrapper += '<div><hr>';
|
||||||
|
if (theme.footer.license) {
|
||||||
|
wrapper += markdown(__('footer.license', theme.footer.license));
|
||||||
|
}
|
||||||
|
if (source) {
|
||||||
|
wrapper += markdown(__('footer.info_open_source', author, using, source));
|
||||||
|
} else {
|
||||||
|
wrapper += markdown(__('footer.info_not_open_source', author, using));
|
||||||
|
}
|
||||||
|
wrapper += '</div>';
|
||||||
|
return wrapper;
|
||||||
|
}
|
||||||
|
%>
|
||||||
|
<%- layoutDiv() %>
|
|
@ -30,7 +30,7 @@
|
||||||
<a class='cap breadcrumb' href='<%- url_for(p.path) %>'><%- p.title %></a>
|
<a class='cap breadcrumb' href='<%- url_for(p.path) %>'><%- p.title %></a>
|
||||||
<% }); %>
|
<% }); %>
|
||||||
<% site.pages.filter(function (p) { %>
|
<% site.pages.filter(function (p) { %>
|
||||||
<% return p.layout == 'wiki' && p.wiki == page.wiki && !p.order %>
|
<% return p.layout == 'wiki' && p.wiki == page.wiki && p.description %>
|
||||||
<% }).limit(1).each(function(p) { %>
|
<% }).limit(1).each(function(p) { %>
|
||||||
<span class="sep"></span>
|
<span class="sep"></span>
|
||||||
<a class='cap breadcrumb' href='<%- url_for(p.path) %>'><%- page.wiki %></a>
|
<a class='cap breadcrumb' href='<%- url_for(p.path) %>'><%- page.wiki %></a>
|
||||||
|
|
|
@ -35,7 +35,4 @@
|
||||||
<% } else if (post.excerpt) { %>
|
<% } else if (post.excerpt) { %>
|
||||||
<%- strip_html(post.excerpt) %>
|
<%- strip_html(post.excerpt) %>
|
||||||
<% } %>
|
<% } %>
|
||||||
<div class='readmore cap'>
|
|
||||||
了解详情
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -1,16 +1,22 @@
|
||||||
|
<%
|
||||||
|
function layoutMainMenu() {
|
||||||
|
var el = '';
|
||||||
|
el += '<nav class="menu">'
|
||||||
|
for (let id of Object.keys(theme.sidebar.menu)) {
|
||||||
|
let item = theme.sidebar.menu[id];
|
||||||
|
el += '<a class="nav-item';
|
||||||
|
if (id == page.menu_id) {
|
||||||
|
el += ' active';
|
||||||
|
}
|
||||||
|
el += '" href="' + url_for(item.url) + '">';
|
||||||
|
el += '<span>' + __(item.title) + '</span>';
|
||||||
|
el += '</a>';
|
||||||
|
}
|
||||||
|
el += '</nav>';
|
||||||
|
return el;
|
||||||
|
}
|
||||||
|
%>
|
||||||
<header class='header'>
|
<header class='header'>
|
||||||
<%- partial('logo') %>
|
<%- partial('logo') %>
|
||||||
<nav class='menu'>
|
<%- layoutMainMenu() %>
|
||||||
<% theme.sidebar.menu.forEach((item, i) => { %>
|
|
||||||
<% if (item.class == page.class) { %>
|
|
||||||
<a class='nav-item active' href='<%- url_for(item.url) %>'>
|
|
||||||
<span><%- __(item.name) %></span>
|
|
||||||
</a>
|
|
||||||
<% } else { %>
|
|
||||||
<a class='nav-item' href='<%- url_for(item.url) %>'>
|
|
||||||
<span><%- __(item.name) %></span>
|
|
||||||
</a>
|
|
||||||
<% } %>
|
|
||||||
<% }); %>
|
|
||||||
</nav>
|
|
||||||
</header>
|
</header>
|
|
@ -1,8 +1,6 @@
|
||||||
<div class='logo-wrap'>
|
<div class='logo-wrap'>
|
||||||
<a href='/'>
|
<% if (theme.sidebar.logo.avatar.src || config.avatar) { %>
|
||||||
<% if (theme.sidebar.logo.avatar != false) { %>
|
<a class='img' href='<%- theme.sidebar.logo.avatar.href || "/" %>'><img no-lazy src='<%- theme.sidebar.logo.avatar.src || config.avatar %>'/></a>
|
||||||
<div class='img'><img no-lazy src='<%- theme.sidebar.logo.avatar || config.avatar %>'/></div>
|
|
||||||
<% } %>
|
<% } %>
|
||||||
<span class='title'><%- theme.sidebar.logo.title || config.title %></span>
|
<a class='title' href='/'><%- theme.sidebar.logo.title || config.title %></a>
|
||||||
</a>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
</div>
|
</div>
|
||||||
<div class='widget-body'>
|
<div class='widget-body'>
|
||||||
<%
|
<%
|
||||||
var arr = page.class == 'wiki' ? site.pages.filter(function(p){
|
var arr = page.menu_id == 'wiki' ? site.pages.filter(function(p){
|
||||||
return p.layout == 'wiki' && p.title && p.title.length > 0;
|
return p.layout == 'wiki' && p.title && p.title.length > 0;
|
||||||
}) : site.posts.filter(function(p){
|
}) : site.posts.filter(function(p){
|
||||||
return p.title && p.title.length > 0;
|
return p.title && p.title.length > 0;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<%
|
<%
|
||||||
if (page.class == undefined) {
|
if (page.menu_id == undefined) {
|
||||||
page.class = 'post';
|
page.menu_id = 'post';
|
||||||
}
|
}
|
||||||
%>
|
%>
|
||||||
<% if (page.posts && (is_category() || is_tag())) { %>
|
<% if (page.posts && (is_category() || is_tag())) { %>
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<%
|
<%
|
||||||
if (page.class == undefined) {
|
if (page.menu_id == undefined) {
|
||||||
page.class = 'post';
|
page.menu_id = 'post';
|
||||||
}
|
}
|
||||||
%>
|
%>
|
||||||
<% if (site.categories.length) { %>
|
<% if (site.categories.length) { %>
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
<%
|
<%
|
||||||
if (page.class == undefined) {
|
if (page.menu_id == undefined) {
|
||||||
if (page.layout == 'index' && page.title && page.wiki) {
|
if (page.layout == 'index' && page.title && page.wiki) {
|
||||||
page.class = 'wiki';
|
page.menu_id = 'wiki';
|
||||||
} else {
|
} else {
|
||||||
page.class = 'post';
|
page.menu_id = 'post';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
%>
|
%>
|
||||||
<% if (page.class == 'post') { %>
|
<% if (page.menu_id == 'post') { %>
|
||||||
<%- partial('_partial/main/navbar/list_post') %>
|
<%- partial('_partial/main/navbar/list_post') %>
|
||||||
<% if (page.posts) { %>
|
<% if (page.posts) { %>
|
||||||
<div class='post-list post'>
|
<div class='post-list post'>
|
||||||
|
@ -21,7 +21,7 @@ if (page.class == undefined) {
|
||||||
<%- partial('_partial/main/post_list/paginator') %>
|
<%- partial('_partial/main/post_list/paginator') %>
|
||||||
</div>
|
</div>
|
||||||
<% } %>
|
<% } %>
|
||||||
<% } else if (page.class == 'wiki') { %>
|
<% } else if (page.menu_id == 'wiki') { %>
|
||||||
<% function outputExcerpt(post) { %>
|
<% function outputExcerpt(post) { %>
|
||||||
<a class='post-card wiki reveal' href='<%- url_for(post.link || post.path) %>'>
|
<a class='post-card wiki reveal' href='<%- url_for(post.link || post.path) %>'>
|
||||||
<article class='excerpt md'>
|
<article class='excerpt md'>
|
||||||
|
|
|
@ -11,11 +11,13 @@
|
||||||
<%- partial('_partial/main/header/index') %>
|
<%- partial('_partial/main/header/index') %>
|
||||||
<%- body %>
|
<%- body %>
|
||||||
<footer class='page-footer'>
|
<footer class='page-footer'>
|
||||||
<%- partial('_partial/footer') %>
|
<%- partial('_partial/main/footer') %>
|
||||||
</footer>
|
</footer>
|
||||||
<%- partial('_partial/menubtn') %>
|
<%- partial('_partial/menubtn') %>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class='scripts'>
|
||||||
<%- partial('_partial/scripts/index') %>
|
<%- partial('_partial/scripts/index') %>
|
||||||
|
</div>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<%
|
<%
|
||||||
if (page.class == undefined) {
|
if (page.menu_id == undefined) {
|
||||||
page.class = 'post';
|
page.menu_id = 'post';
|
||||||
}
|
}
|
||||||
if (page.header == undefined) {
|
if (page.header == undefined) {
|
||||||
page.header = false;
|
page.header = false;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<%
|
<%
|
||||||
if (page.class == undefined) {
|
if (page.menu_id == undefined) {
|
||||||
page.class = 'post';
|
page.menu_id = 'post';
|
||||||
}
|
}
|
||||||
%>
|
%>
|
||||||
<% if (site.tags.length) { %>
|
<% if (site.tags.length) { %>
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<%
|
<%
|
||||||
if (page.class == undefined) {
|
if (page.menu_id == undefined) {
|
||||||
page.class = 'wiki';
|
page.menu_id = 'wiki';
|
||||||
}
|
}
|
||||||
if (page.layout == undefined) {
|
if (page.layout == undefined) {
|
||||||
page.layout = 'index';
|
page.layout = 'index';
|
||||||
|
|
|
@ -10,9 +10,9 @@ hexo.on('generateBefore', () => {
|
||||||
hexo.on('ready', () => {
|
hexo.on('ready', () => {
|
||||||
const { version } = require('../../package.json');
|
const { version } = require('../../package.json');
|
||||||
hexo.log.info(`
|
hexo.log.info(`
|
||||||
===================================================
|
=======================================================
|
||||||
Stellar ${version}
|
Stellar ${version}
|
||||||
Docs: https://xaoxuu.com/wiki/stellar/
|
Docs: https://xaoxuu.com/wiki/stellar/
|
||||||
Repo: https://github.com/xaoxuu/hexo-theme-stellar/
|
Repo: https://github.com/xaoxuu/hexo-theme-stellar/
|
||||||
===================================================`);
|
=======================================================`);
|
||||||
});
|
});
|
|
@ -3,18 +3,23 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var util = require('hexo-util');
|
var util = require('hexo-util');
|
||||||
|
|
||||||
// Examples of helper
|
|
||||||
hexo.extend.helper.register('popular_posts_wrapper', function(args){
|
hexo.extend.helper.register('popular_posts_wrapper', function(args){
|
||||||
if (!args || !args.json || args.json.length == 0) return "";
|
const title = args.title;
|
||||||
|
const json = args.json.json;
|
||||||
|
const cls = args.json.class;
|
||||||
|
if (json == undefined || json.length == 0) {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
const cfg = hexo.theme.config.article.related_posts;
|
const cfg = hexo.theme.config.article.related_posts;
|
||||||
if (cfg.enable != true) return;
|
if (cfg.enable != true) return;
|
||||||
var returnHTML = "";
|
var returnHTML = "";
|
||||||
var div = `
|
var div = `
|
||||||
<div class="related_posts">
|
<div class="related_posts">
|
||||||
<section class='header'>
|
<section class='header'>
|
||||||
<div class='title cap cyan'>${cfg.title}</div>
|
<div class='title cap cyan'>${title}</div>
|
||||||
</section>
|
</section>
|
||||||
<section class='body'>
|
<section class='body'>
|
||||||
`;
|
`;
|
||||||
|
@ -36,18 +41,18 @@ hexo.extend.helper.register('popular_posts_wrapper', function(args){
|
||||||
el += '<span class="title">' + list.title + '</span>';
|
el += '<span class="title">' + list.title + '</span>';
|
||||||
|
|
||||||
if (list.excerpt && list.excerpt.length > 0) {
|
if (list.excerpt && list.excerpt.length > 0) {
|
||||||
el += '<span class="excerpt">' + util.truncate(util.stripHTML(list.excerpt), {length: 64}) + '</span>';
|
el += '<span class="excerpt">' + util.truncate(util.stripHTML(list.excerpt), {length: 120}) + '</span>';
|
||||||
}
|
}
|
||||||
|
|
||||||
el += '</a>';
|
el += '</a>';
|
||||||
return el;
|
return el;
|
||||||
}
|
}
|
||||||
|
|
||||||
for(var i = 0; i < args.json.length; i++) {
|
for(var i = 0; i < json.length; i++) {
|
||||||
returnHTML += generateHTML(args.json[i]);
|
returnHTML += generateHTML(json[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (returnHTML != "") returnHTML = "<div class=\"" + args.class + "\">" + returnHTML + "</div>";
|
if (returnHTML != "") returnHTML = "<div class=\"" + cls + "\">" + returnHTML + "</div>";
|
||||||
div += returnHTML;
|
div += returnHTML;
|
||||||
div += '</section></div>';
|
div += '</section></div>';
|
||||||
return div;
|
return div;
|
||||||
|
|
|
@ -0,0 +1,21 @@
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
hexo.extend.helper.register('stellar_info', function(args){
|
||||||
|
const repo = 'https://github.com/xaoxuu/hexo-theme-stellar';
|
||||||
|
const wiki = 'https://xaoxuu.com/wiki/stellar/';
|
||||||
|
const issues = repo + '/issues/';
|
||||||
|
const { version } = require('../../package.json');
|
||||||
|
const cfg = hexo.theme.config.stellar;
|
||||||
|
if (!args) {
|
||||||
|
return repo;
|
||||||
|
} else if (args == 'name') {
|
||||||
|
return 'Stellar';
|
||||||
|
} else if (args == 'version') {
|
||||||
|
return version;
|
||||||
|
} else if (args == 'issues') {
|
||||||
|
return repo + '/issues/'
|
||||||
|
} else if (args == 'tree') {
|
||||||
|
return repo + '/tree/' + version;
|
||||||
|
}
|
||||||
|
return '';
|
||||||
|
});
|
|
@ -0,0 +1,44 @@
|
||||||
|
'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 '';
|
||||||
|
});
|
|
@ -1,4 +1,4 @@
|
||||||
.posts .paginator-wrap
|
.post-list .paginator-wrap
|
||||||
display: flex
|
display: flex
|
||||||
justify-content: space-between
|
justify-content: space-between
|
||||||
align-items: center
|
align-items: center
|
||||||
|
|
Loading…
Reference in New Issue