This commit is contained in:
xaoxuu 2021-02-23 21:09:49 +08:00
parent 8155658bd6
commit 3bf7f894d3
16 changed files with 150 additions and 35 deletions

View File

@ -59,6 +59,9 @@ sidebar:
article: article:
# 如果没有指定 excerpt 和 description将自动取多长的内容作为文章摘要 # 如果没有指定 excerpt 和 description将自动取多长的内容作为文章摘要
auto_excerpt: 200 auto_excerpt: 200
# 分类颜色
category_color:
'新闻稿': '#DA0F47'
# 相关文章,需要安装插件 (for layout: post) # 相关文章,需要安装插件 (for layout: post)
# npm i hexo-related-popular-posts # npm i hexo-related-popular-posts
related_posts: related_posts:

View File

@ -1,14 +1,20 @@
<% if (page.breadcrumb != false) { %> <% if (page.breadcrumb != false) { %>
<div class='breadcrumb-navigation'> <div class='breadcrumb-navigation'>
<% if (page.layout == 'post') { %> <% if (page.layout == 'post') { %>
<div id='breadcrumb'> <%
var firstCat = '';
if (page.categories && page.categories.length > 0) {
firstCat = page.categories.data[0].name;
}
%>
<div id='breadcrumb'<%- category_color(firstCat) %>>
<a class='cap breadcrumb' href='/'><%- __('btn.home') %></a> <a class='cap breadcrumb' href='/'><%- __('btn.home') %></a>
<span class="sep"></span> <span class="sep"></span>
<a class='cap breadcrumb' href='/'><%- __('btn.blog') %></a> <a class='cap breadcrumb' href='/'><%- __('btn.blog') %></a>
<% if (page.layout == 'post' && page.categories && page.categories.length > 0) { %> <% if (page.layout == 'post' && page.categories && page.categories.length > 0) { %>
<span class="sep"></span> <span class="sep"></span>
<%- list_categories(page.categories, { <%- list_categories(page.categories, {
class: 'cap breadcrumb cat', class: 'cap breadcrumb',
show_count: false, show_count: false,
separator: ' <span class="sep"></span> ', separator: ' <span class="sep"></span> ',
style: 'none' style: 'none'
@ -19,7 +25,15 @@
<%- __('meta.created') %>&nbsp;<time datetime='<%- date_xml(page.date) %>'><%- date(page.date, config.date_format) %></time> <%- __('meta.created') %>&nbsp;<time datetime='<%- date_xml(page.date) %>'><%- date(page.date, config.date_format) %></time>
</div> </div>
<% } else if (page.layout == 'wiki') { %> <% } else if (page.layout == 'wiki') { %>
<div id='breadcrumb'> <%
var catPage = '';
site.pages.filter(function (p) {
return p.layout == 'index' && p.title && p.wiki && p.wiki.includes(page.wiki)
}).limit(1).each(function(p) {
catPage = p;
});
%>
<div id='breadcrumb'<%- category_color(catPage.title) %>>
<a class='cap breadcrumb' href='/'><%- __('btn.home') %></a> <a class='cap breadcrumb' href='/'><%- __('btn.home') %></a>
<span class="sep"></span> <span class="sep"></span>
<% if (page.menu_id && theme.sidebar.menu[page.menu_id] && theme.sidebar.menu[page.menu_id].url) { %> <% if (page.menu_id && theme.sidebar.menu[page.menu_id] && theme.sidebar.menu[page.menu_id].url) { %>
@ -27,12 +41,10 @@
<% } else { %> <% } else { %>
<a class='cap breadcrumb' href='<%- url_for(config.wiki_dir || "/wiki/") %>'><%- __('btn.wiki') %></a> <a class='cap breadcrumb' href='<%- url_for(config.wiki_dir || "/wiki/") %>'><%- __('btn.wiki') %></a>
<% } %> <% } %>
<% site.pages.filter(function (p) { %> <% if (catPage && catPage.title && catPage.path) { %>
<% return p.layout == 'index' && p.title && p.wiki && p.wiki.includes(page.wiki) %>
<% }).limit(1).each(function(p) { %>
<span class="sep"></span> <span class="sep"></span>
<a class='cap breadcrumb' href='<%- url_for(p.path) %>'><%- p.title %></a> <a class='cap breadcrumb' href='<%- url_for(catPage.path) %>'><%- catPage.title %></a>
<% }); %> <% } %>
<% site.pages.filter(function (p) { %> <% site.pages.filter(function (p) { %>
<% return p.layout == 'wiki' && p.wiki == page.wiki && p.description %> <% return p.layout == 'wiki' && p.wiki == page.wiki && p.description %>
<% }).limit(1).each(function(p) { %> <% }).limit(1).each(function(p) { %>

View File

@ -1,5 +1,5 @@
<div class='nav-wrap'> <div class='nav-wrap'>
<nav class='sub post cap green'> <nav class='sub post cap'>
<% if (is_home()) { %> <% if (is_home()) { %>
<a class='active' href='/'><%- __('btn.recent_publish') %></a> <a class='active' href='/'><%- __('btn.recent_publish') %></a>
<% } else { %> <% } else { %>

View File

@ -1,5 +1,5 @@
<div class='nav-wrap'> <div class='nav-wrap'>
<nav class='sub wiki cap green'> <nav class='sub wiki cap'>
<% if (page.layout == 'index' && page.title && page.wiki) { %> <% if (page.layout == 'index' && page.title && page.wiki) { %>
<a href='<%- url_for(config.wiki_dir || "/wiki/") %>'><%- __('btn.all_wiki') %></a> <a href='<%- url_for(config.wiki_dir || "/wiki/") %>'><%- __('btn.all_wiki') %></a>
<% } else { %> <% } else { %>

View File

@ -44,10 +44,11 @@ if (post.categories && post.categories.length > 0) {
} }
function layoutCats() { function layoutCats() {
if (cats.length > 0) { if (cats.length > 0) {
var ret = '<span class="cap breadcrumb">'; let cat = cats.shift();
ret += cats.shift() var el = '<span class="cap breadcrumb"' + category_color(cat) + '>';
ret += '</span>'; el += cat;
return ret; el += '</span>';
return el;
} else { } else {
return ''; return '';
} }

View File

@ -22,13 +22,19 @@
</div> </div>
<% } %> <% } %>
<div class='excerpt'> <div class='excerpt'>
<div class='cap breadcrumb'> <%
<% site.pages.filter(function (p) { %> var cat = '';
<% return p.layout == 'index' && p.title && p.wiki && p.wiki.includes(post.wiki) %> site.pages.filter(function (p) {
<% }).limit(1).each(function(p) { %> return p.layout == 'index' && p.title && p.wiki && p.wiki.includes(post.wiki)
<span><%- p.title %></span> }).limit(1).each(function(p) {
<% }); %> cat = p.title;
</div> });
%>
<% if (cat) { %>
<div class='cap breadcrumb'<%- category_color(cat) %>>
<span><%- cat %></span>
</div>
<% } %>
<h2 class='post-title'><%- post.wiki || post.title %></h2> <h2 class='post-title'><%- post.wiki || post.title %></h2>
<% if (post.description) { %> <% if (post.description) { %>
<p><%- post.description %></p> <p><%- post.description %></p>

View File

@ -23,4 +23,7 @@ function layoutDiv() {
return el; return el;
} }
%> %>
<svg class="loading" style="vertical-align: middle;fill: currentColor;overflow: hidden;" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="2709"><path d="M832 512c0-176-144-320-320-320V128c211.2 0 384 172.8 384 384h-64zM192 512c0 176 144 320 320 320v64C300.8 896 128 723.2 128 512h64z" p-id="2710"></path></svg>
<%- layoutDiv() %> <%- layoutDiv() %>

View File

@ -0,0 +1,9 @@
'use strict';
hexo.extend.helper.register('category_color', function(cat){
const cfg = hexo.theme.config;
if (cfg.article.category_color && cfg.article.category_color[cat]) {
return ' style="color:' + cfg.article.category_color[cat] + '"';
}
return '';
});

View File

@ -0,0 +1,51 @@
/**
* doc_tree(page, {toc: false})
*/
'use strict';
var util = require('hexo-util');
hexo.extend.helper.register('doc_tree', function(page, args){
if (page.layout != 'wiki') {
return '';
}
const pages = hexo.locals.get('pages').filter(function (p) {
if (p.layout == 'wiki' && p.wiki && p.wiki == page.wiki && (p.title || p.seo_title)) {
if (p.order == undefined) {
p.order = 0;
}
return true;
} else {
return false;
}
}).sort('order');
if (pages.length == 0) {
return '';
}
var el = '';
el += '<div class="doc-tree">';
function doc_node(p) {
if ((p.title || p.seo_title) && p.permalink) {
var node = '<div class="doc-node">';
node += '<a class="doc-tree-link';
if (p.permalink == page.permalink) {
node += ' active';
}
node += '" href="' + p.permalink + '">';
node += '<span class="toc-text">';
node += p.title || p.seo_title;
node += '</span>';
node += '</a>';
node += '</div>';
return node;
} else {
return '';
}
}
pages.forEach((p, i) => {
el += doc_node(p);
});
el += '</div>';
return el;
});

View File

@ -49,14 +49,10 @@ a.button
font-weight: 600 font-weight: 600
font-size: $fs12 font-size: $fs12
color: var(--text-p3) color: var(--text-p3)
&.breadcrumb
color: $color-cat
&.blue &.blue
color: darken($color-md-blue, 6) color: darken($color-md-blue, 6)
&.cyan &.cyan
color: darken($color-mac-cyan, 6) color: darken($color-mac-cyan, 6)
&.green
color: darken($color-mac-green, 4)
span.dot,span.sep span.dot,span.sep

View File

@ -15,7 +15,9 @@
.title .title
font-size: 1.5rem font-size: 1.5rem
nav.menu nav.menu
margin: -2px margin: -3px
a.nav-item
margin: 2px
// pc // pc
@media screen and (min-width: $device-tablet) @media screen and (min-width: $device-tablet)

View File

@ -19,12 +19,11 @@ nav.cap
font-weight: 600 font-weight: 600
white-space: nowrap white-space: nowrap
trans1 background trans1 background
&:hover &.active,&:hover
background: var(--hover-block) background: var(--hover-block)
color: var(--text-p1) color: var(--text-p1)
&.active a+a
font-weight: 700 margin-left: 4px
color: inherit
.md .tag-plugin.navbar .md .tag-plugin.navbar
nav.cap nav.cap
@ -51,8 +50,15 @@ nav.cap
display: flex display: flex
align-items: center align-items: center
flex-direction: row flex-direction: row
a.cap:hover &:not([style]) a
color: $color-cat-hover color: var(--text-p1)
&[style] a
color: inherit
span.sep
color: var(--text-p3)
// a.cap:hover
// color: $color-cat-hover
// text-decoration: underline
div#post-meta div#post-meta
margin-top: 2px margin-top: 2px

View File

@ -1,8 +1,10 @@
.comments-wrap .comments-wrap
padding: $gap * 2 $gap padding: $gap * 2 $gap
div.cmt-body.utterances div.cmt-body
margin: 0 -4px min-height: 150px
position: relative
svg.loading
top: 60px
a.avatar a.avatar
border-radius: 120px !important border-radius: 120px !important
overflow: hidden !important overflow: hidden !important

View File

@ -0,0 +1,3 @@
.cmt-body.utterances
margin: 0 -4px

View File

@ -0,0 +1,14 @@
svg.loading
display: block
position: absolute
z-index: -1
width: 100%
height: 2rem
margin: auto
animation: spin infinite 2s
animation-timing-function: linear
@keyframes spin
from
transform:rotate(0deg)
to
transform:rotate(360deg)

View File

@ -1,5 +1,12 @@
//
@import "common/*"
// //
if hexo-config('plugins.swiper.enable') if hexo-config('plugins.swiper.enable')
@import 'swiper' @import 'swiper'
if hexo-config('plugins.scrollreveal.enable') if hexo-config('plugins.scrollreveal.enable')
@import 'scrollreveal' @import 'scrollreveal'
//
if hexo-config('comments.service') == 'utterances'
@import 'comments/utterances'