group -> tags
This commit is contained in:
parent
400254dcfa
commit
07ecb24ec2
|
@ -2,8 +2,8 @@
|
|||
function generate_title() {
|
||||
if (page.layout == 'wiki' && page.wiki && (page.title || page.seo_title)) {
|
||||
return page.wiki + __('symbol.colon') + (page.seo_title || page.title) + ' - ' + config.title;
|
||||
} else if (page.seo_title || page.title || page.wiki || page.layout) {
|
||||
return (page.seo_title || page.title || page.wiki || page.layout) + ' - ' + config.title;
|
||||
} else if (page.seo_title || page.title || page.wiki) {
|
||||
return (page.seo_title || page.title || page.wiki) + ' - ' + config.title;
|
||||
} else if (page.category) {
|
||||
return __('btn.category') + __('symbol.colon') + page.category + ' - ' + config.title;
|
||||
} else if (page.tag) {
|
||||
|
@ -80,7 +80,7 @@ function og_args() {
|
|||
<% if (config.favicon) { %>
|
||||
<%- favicon_tag(config.favicon) %>
|
||||
<% } %>
|
||||
|
||||
|
||||
<% if (config.inject && config.inject.head){ %>
|
||||
<% (config.inject.head||[]).forEach(function(item){ %>
|
||||
<%- item %>
|
||||
|
|
|
@ -10,30 +10,22 @@ function layoutDiv() {
|
|||
title_prev = __('meta.newer');
|
||||
title_next = __('meta.older');
|
||||
} else if (page.layout === 'wiki' && page.wiki && page.wiki.length > 0) {
|
||||
var wikis = [];
|
||||
wikis = site.pages.filter(function (p) {
|
||||
if (p.layout === 'wiki' && p.wiki && p.wiki === page.wiki) {
|
||||
if (p.order === undefined) {
|
||||
p.order = 0;
|
||||
let proj = theme.wiki.projects[page.wiki];
|
||||
if (proj) {
|
||||
proj.pages.forEach((p, i) => {
|
||||
if (p.order < page.order) {
|
||||
if (prev == undefined || p.order > prev.order) {
|
||||
prev = p;
|
||||
}
|
||||
} else if (p.order > page.order) {
|
||||
if (next == undefined || p.order < next.order) {
|
||||
next = p;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}).sort('order');
|
||||
page.order = page.order || 0;
|
||||
wikis.forEach((p, i) => {
|
||||
if (p.order < page.order) {
|
||||
if (prev === undefined || p.order > prev.order) {
|
||||
prev = p;
|
||||
}
|
||||
} else if (p.order > page.order) {
|
||||
if (next === undefined || p.order < next.order) {
|
||||
next = p;
|
||||
}
|
||||
}
|
||||
});
|
||||
if (next === undefined) {
|
||||
});
|
||||
}
|
||||
if (next == undefined) {
|
||||
// 项目的最后一篇文档
|
||||
return '<br>';
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,13 +5,13 @@ function layoutWikiCover() {
|
|||
return el;
|
||||
}
|
||||
let proj = theme.wiki.projects[page.wiki];
|
||||
if (proj === undefined) {
|
||||
if (proj == undefined) {
|
||||
return el;
|
||||
}
|
||||
if (proj.path !== page.path) {
|
||||
if (proj.homepage.path !== page.path) {
|
||||
return;
|
||||
}
|
||||
if (proj.cover === undefined || proj.cover === false || proj.cover === '[]') {
|
||||
if (proj.cover == undefined || proj.cover === false || proj.cover === '[]') {
|
||||
return el;
|
||||
}
|
||||
var cover = proj.cover;
|
||||
|
@ -42,7 +42,7 @@ function layoutWikiCover() {
|
|||
el += '<div class="description">' + desc + '</div>';
|
||||
}
|
||||
el += '<div class="start-wrap">';
|
||||
el += '<a class="button theme start" href="#start">' + __('btn.getting_started') + '</a>';
|
||||
el += '<a class="button theme start" href="#start">' + (proj.start || __('btn.getting_started')) + '</a>';
|
||||
el += '</div>';
|
||||
el += '</article>';
|
||||
el += '</div>';
|
||||
|
|
|
@ -4,13 +4,13 @@ function layoutDiv() {
|
|||
if (page.breadcrumb === false) {
|
||||
return el;
|
||||
}
|
||||
el += '<div class="bread-nav fs12">';
|
||||
if (page.layout === "post") {
|
||||
var firstCat = "";
|
||||
if (page.categories && page.categories.length > 0) {
|
||||
firstCat = page.categories.data[0].name;
|
||||
}
|
||||
el += '<div id="breadcrumb"' + category_color(firstCat) + '>';
|
||||
el += '<div class="bread-nav fs12">';
|
||||
el += '<div id="breadcrumb">';
|
||||
el += '<a class="cap breadcrumb" href="/">' + __("btn.home") + '</a>';
|
||||
el += '<span class="sep"></span>';
|
||||
el += '<a class="cap breadcrumb" href="/">' + __("btn.blog") + '</a>';
|
||||
|
@ -28,16 +28,10 @@ function layoutDiv() {
|
|||
el += '<div id="post-meta">';
|
||||
el += __("meta.created") + ' <time datetime="' + date_xml(page.date) + '">' + date(page.date, config.date_format) + '</time>';
|
||||
el += '</div>';
|
||||
el += '</div>';
|
||||
} else if (page.layout === "wiki" && page.wiki && page.wiki.length > 0) {
|
||||
var cat_name = '';
|
||||
let proj = theme.wiki.projects[page.wiki];
|
||||
if (proj.group && proj.group.length > 0) {
|
||||
let group = theme.wiki.groups[proj.group];
|
||||
if (group) {
|
||||
cat_name = group.title;
|
||||
}
|
||||
}
|
||||
el += '<div id="breadcrumb"' + category_color(cat_name) + '>';
|
||||
el += '<div class="bread-nav fs12">';
|
||||
el += '<div id="breadcrumb">';
|
||||
var nodes = [];
|
||||
// home
|
||||
el += '<a class="cap breadcrumb" id="home" href="/">' + __("btn.home") + '</a>';
|
||||
|
@ -53,17 +47,9 @@ function layoutDiv() {
|
|||
nodes.push(url);
|
||||
el += '<a class="cap breadcrumb" id="menu" href="' + url + '">' + __("btn.wiki") + '</a>';
|
||||
}
|
||||
// group
|
||||
if (proj.group && proj.group.length > 0) {
|
||||
let group = theme.wiki.groups[proj.group];
|
||||
let url = url_for(group.path);
|
||||
if (group !== undefined && nodes.includes(url) === false) {
|
||||
el += '<span class="sep"></span>';
|
||||
el += '<a class="cap breadcrumb" id="group" href="' + url + '">' + group.title + '</a>';
|
||||
}
|
||||
}
|
||||
// 项目名
|
||||
let url_proj = url_for(proj.path);
|
||||
let proj = theme.wiki.projects[page.wiki];
|
||||
let url_proj = url_for(proj.homepage.path);
|
||||
if (nodes.includes(url_proj) === false) {
|
||||
el += '<span class="sep"></span>';
|
||||
el += '<a class="cap breadcrumb" id="proj" href="' + url_proj + '">' + proj.title + '</a>';
|
||||
|
@ -73,14 +59,16 @@ function layoutDiv() {
|
|||
el += '<div id="post-meta">';
|
||||
el += __("meta.updated") + ' <time datetime="' + date_xml(page.updated) + '">' + date(page.updated, config.date_format) + '</time>';
|
||||
el += '</div>';
|
||||
} else {
|
||||
el += '</div>';
|
||||
} else if (page.title || page.seo_title) {
|
||||
el += '<div class="bread-nav fs12">';
|
||||
el += '<div id="breadcrumb">';
|
||||
el += '<a class="cap breadcrumb" href="/">' + __("btn.home") + '</a>';
|
||||
el += '<span class="sep"></span>';
|
||||
el += '<a class="cap breadcrumb" href="' + url_for(page.path) + '">' + (page.title || page.seo_title) + '</a>';
|
||||
el += '</div>';
|
||||
el += '</div>';
|
||||
}
|
||||
el += '</div>';
|
||||
return el;
|
||||
}
|
||||
%>
|
||||
|
|
|
@ -11,17 +11,17 @@ function layoutDiv() {
|
|||
el += ' href="' + url_for(config.wiki_dir || "/wiki/") + '">' + __("btn.all_wiki") + '</a>';
|
||||
el += '</a>';
|
||||
// 项目分类
|
||||
for (let group_name of Object.keys(theme.wiki.groups)) {
|
||||
let group = theme.wiki.groups[group_name];
|
||||
let projects = group.projects.filter(function(proj){
|
||||
return proj.index !== false;
|
||||
for (let id of Object.keys(theme.wiki.all_tags)) {
|
||||
let tag = theme.wiki.all_tags[id];
|
||||
let projects = tag.items.filter(function(item){
|
||||
return item.index !== false;
|
||||
})
|
||||
if (projects && projects.length > 0) {
|
||||
el += '<a';
|
||||
if (group.title && group.title.length > 0 && page.group === group.title) {
|
||||
if (tag.name && tag.name.length > 0 && page.tagName === tag.name) {
|
||||
el += ' class="active"';
|
||||
}
|
||||
el += ' href="' + url_for(group.path) + '">' + group.title + '</a>';
|
||||
el += ' href="' + url_for(tag.path) + '">' + tag.name + '</a>';
|
||||
el += '</a>';
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@ function layoutDiv() {
|
|||
// 封面
|
||||
if (post.cover || theme.article.auto_cover) {
|
||||
var cover_url;
|
||||
if (post.cover !== undefined) {
|
||||
if (post.cover != undefined) {
|
||||
if (post.cover.includes('/')) {
|
||||
cover_url = post.cover;
|
||||
} else {
|
||||
|
|
|
@ -11,9 +11,10 @@ function layoutDiv() {
|
|||
el += '</div>';
|
||||
}
|
||||
el += '<div class="excerpt">';
|
||||
if (proj.group) {
|
||||
el += '<div class="cap breadcrumb"' + category_color(proj.group) + '>';
|
||||
el += '<span>' + proj.group + '</span>';
|
||||
if (proj.tags && proj.tags.length > 0) {
|
||||
let tag = proj.tags[0];
|
||||
el += '<div>';
|
||||
el += '<span class="cap breadcrumb"' + category_color(tag) + '>' + tag + '</span>';
|
||||
el += '</div>';
|
||||
}
|
||||
el += '<h2 class="post-title">' + (proj.wiki || proj.title || proj.seo_title) + '</h2>';
|
||||
|
|
|
@ -5,7 +5,7 @@ function layoutDiv() {
|
|||
var config = Object.assign({}, theme.comments[cmt]);
|
||||
if (page.layout === 'wiki' && page.wiki) {
|
||||
let proj = theme.wiki.projects[page.wiki];
|
||||
if (proj[cmt] !== undefined) {
|
||||
if (proj[cmt] != undefined) {
|
||||
Object.assign(config, proj[cmt]);
|
||||
}
|
||||
}
|
||||
|
@ -14,11 +14,11 @@ function layoutDiv() {
|
|||
if (config['issue-number'] !== null) {
|
||||
config['issue-term'] = null;
|
||||
} else {
|
||||
if (page.comment_id !== undefined) {
|
||||
if (page.comment_id != undefined) {
|
||||
config['issue-term'] = page.comment_id;
|
||||
} else if (page.layout === 'wiki' && page.wiki) {
|
||||
let proj = theme.wiki.projects[page.wiki];
|
||||
if (proj.comment_id !== undefined) {
|
||||
if (proj.comment_id != undefined) {
|
||||
config['issue-term'] = proj.comment_id;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,9 +6,9 @@ if (theme.comments.service && theme.comments.service.length > 0) {
|
|||
}
|
||||
}
|
||||
// 合并项目评论
|
||||
if (loadComment && page.layout === 'wiki' && page.wiki) {
|
||||
if (loadComment && page.layout == 'wiki' && page.wiki) {
|
||||
let proj = theme.wiki.projects[page.wiki];
|
||||
if (proj.comment_title !== undefined && page.comment_title === undefined) {
|
||||
if (proj.comment_title != undefined && page.comment_title == undefined) {
|
||||
if (['utterances', 'beaudar'].includes(theme.comments.service)) {
|
||||
page.comment_title = proj.comment_title;
|
||||
}
|
||||
|
@ -18,7 +18,7 @@ if (loadComment && page.layout === 'wiki' && page.wiki) {
|
|||
<% if (loadComment) { %>
|
||||
<div class='related-wrap md reveal' id="comments">
|
||||
<div class='cmt-title cap theme'>
|
||||
<%- page.comment_title !== undefined ? markdown(page.comment_title) : __('meta.comment_title') %>
|
||||
<%- page.comment_title != undefined ? markdown(page.comment_title) : __('meta.comment_title') %>
|
||||
</div>
|
||||
<div class='cmt-body <%- theme.comments.service %>'>
|
||||
<%- partial(theme.comments.service + '/layout') %>
|
||||
|
|
|
@ -5,7 +5,7 @@ function layoutDiv() {
|
|||
var config = Object.assign({}, theme.comments[cmt]);
|
||||
if (page.layout === 'wiki' && page.wiki) {
|
||||
let proj = theme.wiki.projects[page.wiki];
|
||||
if (proj[cmt] !== undefined) {
|
||||
if (proj[cmt] != undefined) {
|
||||
Object.assign(config, proj[cmt]);
|
||||
}
|
||||
}
|
||||
|
@ -14,11 +14,11 @@ function layoutDiv() {
|
|||
if (config['issue-number'] !== null) {
|
||||
config['issue-term'] = null;
|
||||
} else {
|
||||
if (page.comment_id !== undefined) {
|
||||
if (page.comment_id != undefined) {
|
||||
config['issue-term'] = page.comment_id;
|
||||
} else if (page.layout === 'wiki' && page.wiki) {
|
||||
let proj = theme.wiki.projects[page.wiki];
|
||||
if (proj.comment_id !== undefined) {
|
||||
if (proj.comment_id != undefined) {
|
||||
config['issue-term'] = proj.comment_id;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,7 +29,7 @@ function layoutDiv() {
|
|||
el += __('btn.all_wiki');
|
||||
el += '</a>';
|
||||
// this product
|
||||
if (proj === undefined) {
|
||||
if (proj == undefined) {
|
||||
// 如果没有项目名,则使用menu中显示的名字
|
||||
if (page.menu_id && theme.sidebar.menu[page.menu_id] && md_link(theme.sidebar.menu[page.menu_id])) {
|
||||
proj = {
|
||||
|
@ -38,9 +38,9 @@ function layoutDiv() {
|
|||
};
|
||||
}
|
||||
}
|
||||
if (proj !== undefined) {
|
||||
if (proj != undefined) {
|
||||
let main = proj.title || proj.wiki || page.wiki || page.title;
|
||||
let url = proj.path;
|
||||
let url = proj.homepage.path;
|
||||
let sub = proj.subtitle;
|
||||
el += layoutTitle(main, url, sub);
|
||||
}
|
||||
|
|
|
@ -11,11 +11,20 @@ function layoutDiv() {
|
|||
}
|
||||
el += '</div>';
|
||||
// body
|
||||
var arr = page.menu_id == "wiki" ? site.pages.filter(function(p){
|
||||
return p.layout == "wiki" && p.title && p.title.length > 0;
|
||||
}) : site.posts.filter(function(p){
|
||||
return p.title && p.title.length > 0;
|
||||
});
|
||||
var arr = [];
|
||||
if (page.menu_id == 'wiki') {
|
||||
arr = theme.wiki.all_pages.filter(function(p){
|
||||
if (p.wiki) {
|
||||
let proj = theme.wiki.projects[p.wiki];
|
||||
return proj.index != false;
|
||||
}
|
||||
return false;
|
||||
});
|
||||
} else {
|
||||
arr = site.posts.filter(function(p){
|
||||
return p.title && p.title.length > 0;
|
||||
});
|
||||
}
|
||||
el += '<div class="widget-body fs14">';
|
||||
arr.sort("updated", -1).limit(item.limit).each(function(post) {
|
||||
el += '<div class="line"></div>'
|
||||
|
|
|
@ -7,7 +7,7 @@ function layoutDiv() {
|
|||
let proj = theme.wiki.projects[page.wiki];
|
||||
if (proj && proj.repo) {
|
||||
repo = proj.repo;
|
||||
if (proj.branch !== undefined) {
|
||||
if (proj.branch != undefined) {
|
||||
branch = proj.branch;
|
||||
}
|
||||
}
|
||||
|
@ -15,7 +15,7 @@ function layoutDiv() {
|
|||
// 其它的如果有设置 repo 也可以
|
||||
repo = page.repo;
|
||||
}
|
||||
if (repo === undefined) {
|
||||
if (repo == undefined) {
|
||||
return el;
|
||||
}
|
||||
// 布局
|
||||
|
@ -26,6 +26,7 @@ function layoutDiv() {
|
|||
el += '</div>';
|
||||
// body
|
||||
el += '<div class="widget-body fs14">';
|
||||
el += '<div class="items">';
|
||||
var items = [];
|
||||
// GitHub
|
||||
items.push({
|
||||
|
@ -64,6 +65,7 @@ function layoutDiv() {
|
|||
});
|
||||
el += '</div>';
|
||||
el += '</div>';
|
||||
el += '</div>';
|
||||
return el;
|
||||
}
|
||||
%>
|
||||
|
|
|
@ -63,11 +63,11 @@ function layoutDiv(fallback) {
|
|||
|
||||
var el = '';
|
||||
if (type.length > 0) {
|
||||
el += '<div class="widget-wrap" id="toc">';
|
||||
el += '<div class="widget-wrap ' + type + '" id="toc">';
|
||||
if (page.layout !== 'wiki') {
|
||||
// post 布局
|
||||
el += layoutTocHeader(page.toc_title || __("meta.toc"));
|
||||
el += '<div class="widget-body fs14 ' + type + '">';
|
||||
el += '<div class="widget-body fs14">';
|
||||
el += '<div class="doc-tree active">';
|
||||
el += layoutToc();
|
||||
el += '</div>';
|
||||
|
@ -78,13 +78,13 @@ function layoutDiv(fallback) {
|
|||
proj.sections.forEach((sec, i) => {
|
||||
// 多 section
|
||||
el += layoutTocHeader(sec.title);
|
||||
el += '<div class="widget-body fs14 ' + type + '">';
|
||||
el += '<div class="widget-body fs14">';
|
||||
el += layoutDocTree(sec.pages);
|
||||
el += '</div>';
|
||||
});
|
||||
} else {
|
||||
// 单 section
|
||||
el += '<div class="widget-body fs14 ' + type + '">';
|
||||
el += '<div class="widget-body fs14">';
|
||||
el += layoutDocTree(proj.pages);
|
||||
el += '</div>';
|
||||
}
|
||||
|
|
|
@ -3,34 +3,38 @@ function layoutDiv() {
|
|||
if (page.layout !== "wiki") {
|
||||
return '';
|
||||
}
|
||||
var el = '';
|
||||
var related = [];
|
||||
let proj = theme.wiki.projects[page.wiki];
|
||||
if (proj.group && proj.group.length > 0) {
|
||||
let group = theme.wiki.groups[proj.group];
|
||||
let projects = group.projects.filter(function(proj){
|
||||
return proj.index !== false;
|
||||
})
|
||||
if (projects && projects.length > 1) {
|
||||
var el = '';
|
||||
el += '<div class="widget-wrap" id="related">';
|
||||
el += '<div class="widget-header cap dis-select">';
|
||||
el += '<span class="name">更多' + group.title + '</span>';
|
||||
el += '</div>';
|
||||
el += '<div class="widget-body fs14">';
|
||||
projects.forEach((p, i) => {
|
||||
if (p.title !== proj.title) {
|
||||
// 同一个分组中的其它项目
|
||||
el += '<a class="more-item wiki" href="' + url_for(p.path) + '">';
|
||||
el += p.title;
|
||||
el += '<div class="excerpt">';
|
||||
el += p.description;
|
||||
el += '</div>';
|
||||
el += '</a>';
|
||||
}
|
||||
});
|
||||
el += '</div>';
|
||||
el += '</div>';
|
||||
if (proj.related && proj.related.length > 0) {
|
||||
proj.related.forEach((pid, i) => {
|
||||
let p = theme.wiki.projects[pid];
|
||||
if (p && p.title !== proj.title && p.index !== false) {
|
||||
related.push(p);
|
||||
}
|
||||
});
|
||||
}
|
||||
var el = '';
|
||||
if (related.length > 0) {
|
||||
el += '<div class="widget-wrap" id="related">';
|
||||
el += '<div class="widget-header cap dis-select">';
|
||||
var title = __('btn.wiki');
|
||||
if (proj.tags && proj.tags[0]) {
|
||||
title = proj.tags[0];
|
||||
}
|
||||
el += '<span class="name">' + __('meta.more', title) + '</span>';
|
||||
el += '</div>';
|
||||
el += '<div class="widget-body fs14">';
|
||||
related.forEach((p, i) => {
|
||||
// 同一个分组中的其它项目
|
||||
el += '<a class="more-item wiki" href="' + url_for(p.homepage.path) + '">';
|
||||
el += p.title;
|
||||
el += '<div class="excerpt">';
|
||||
el += p.description;
|
||||
el += '</div>';
|
||||
el += '</a>';
|
||||
});
|
||||
el += '</div>';
|
||||
el += '</div>';
|
||||
}
|
||||
return el;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<%
|
||||
if (page.menu_id === undefined) {
|
||||
if (page.menu_id == undefined) {
|
||||
if (page.layout === 'index' && page.wiki) {
|
||||
page.menu_id = 'wiki';
|
||||
} else {
|
||||
|
@ -34,7 +34,7 @@ function layout_posts(partial) {
|
|||
}
|
||||
// unpinned posts
|
||||
page.posts.each(function(post){
|
||||
if (post.pin === undefined) {
|
||||
if (post.pin == undefined) {
|
||||
el += layout_post_card('post', post, partial(post));
|
||||
}
|
||||
})
|
||||
|
@ -53,23 +53,19 @@ function layout_wikis(partial) {
|
|||
const projects = theme.wiki.projects;
|
||||
for (let proj_name of Object.keys(projects)) {
|
||||
let proj = projects[proj_name];
|
||||
if (proj.index === false || proj.pages === undefined || proj.pages.length === 0) {
|
||||
if (proj.index === false || proj.pages == undefined || proj.pages.length === 0) {
|
||||
continue;
|
||||
}
|
||||
if (page.filter === false) {
|
||||
// all wikis
|
||||
proj.pages.sort('order').limit(1).forEach((p0, i) => {
|
||||
el += '<div class="post-list wiki">';
|
||||
el += layout_post_card('wiki', p0, partial(proj));
|
||||
el += '</div>';
|
||||
});
|
||||
} else if (page.group === proj.group) {
|
||||
el += '<div class="post-list wiki">';
|
||||
el += layout_post_card('wiki', proj.homepage, partial(proj));
|
||||
el += '</div>';
|
||||
} else if (proj.tags && proj.tags.includes(page.tagName) === true) {
|
||||
// filtered wikis
|
||||
proj.pages.sort('order').limit(1).forEach((p0, i) => {
|
||||
el += '<div class="post-list wiki filter">';
|
||||
el += layout_post_card('wiki', p0, partial(proj));
|
||||
el += '</div>';
|
||||
});
|
||||
el += '<div class="post-list wiki filter">';
|
||||
el += layout_post_card('wiki', proj.homepage, partial(proj));
|
||||
el += '</div>';
|
||||
}
|
||||
}
|
||||
return el;
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
<%
|
||||
if (page.menu_id === undefined) {
|
||||
if (page.menu_id == undefined) {
|
||||
page.menu_id = 'wiki';
|
||||
}
|
||||
if (page.layout === undefined) {
|
||||
if (page.layout == undefined) {
|
||||
page.layout = 'index';
|
||||
}
|
||||
if (page.title === undefined) {
|
||||
if (page.group) {
|
||||
page.title = page.group;
|
||||
if (page.title == undefined) {
|
||||
if (page.tagName) {
|
||||
page.title = page.tagName;
|
||||
} else {
|
||||
page.title = __('btn.wiki');
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ function layoutTitle() {
|
|||
<%- partial('index') %>
|
||||
<% } else { %>
|
||||
<%
|
||||
if (page.header === undefined) {
|
||||
if (page.header == undefined) {
|
||||
page.header = false;
|
||||
}
|
||||
%>
|
||||
|
|
|
@ -32,14 +32,14 @@ module.exports = hexo => {
|
|||
}
|
||||
|
||||
// default menu
|
||||
if (hexo.theme.config.sidebar.menu === undefined) {
|
||||
if (hexo.theme.config.sidebar.menu == undefined) {
|
||||
hexo.theme.config.sidebar.menu = [];
|
||||
}
|
||||
// default widgets
|
||||
if (hexo.theme.config.sidebar.widgets.repo_info === undefined) {
|
||||
if (hexo.theme.config.sidebar.widgets.repo_info == undefined) {
|
||||
hexo.theme.config.sidebar.widgets.repo_info = {layout: 'repo_info'};
|
||||
}
|
||||
if (hexo.theme.config.sidebar.widgets.wiki_more === undefined) {
|
||||
if (hexo.theme.config.sidebar.widgets.wiki_more == undefined) {
|
||||
hexo.theme.config.sidebar.widgets.wiki_more = {layout: 'wiki_more'};
|
||||
}
|
||||
|
||||
|
|
|
@ -4,12 +4,20 @@
|
|||
|
||||
'use strict';
|
||||
|
||||
function page(page) {
|
||||
return {
|
||||
title: page.title,
|
||||
path: page.path,
|
||||
wiki: page.wiki
|
||||
};
|
||||
}
|
||||
|
||||
module.exports = hexo => {
|
||||
const data = hexo.locals.get('data');
|
||||
if (hexo.theme.config.wiki === undefined) {
|
||||
if (hexo.theme.config.wiki == undefined) {
|
||||
hexo.theme.config.wiki = {};
|
||||
}
|
||||
if (hexo.theme.config.wiki.projects === undefined) {
|
||||
if (hexo.theme.config.wiki.projects == undefined) {
|
||||
hexo.theme.config.wiki.projects = {};
|
||||
}
|
||||
if (data.projects) {
|
||||
|
@ -22,58 +30,77 @@ module.exports = hexo => {
|
|||
var wiki = hexo.theme.config.wiki;
|
||||
// wiki 所有页面
|
||||
const wiki_pages = hexo.locals.get('pages').filter(function (p) {
|
||||
return (p.layout === 'wiki') && (p.wiki !== undefined) && (p.wiki.length > 0);
|
||||
return (p.layout === 'wiki') && (p.wiki != undefined) && (p.wiki.length > 0);
|
||||
});
|
||||
|
||||
// 数据整合:项目组
|
||||
var cats = [];
|
||||
for (let proj_name of Object.keys(wiki.projects)) {
|
||||
let proj = wiki.projects[proj_name];
|
||||
if (proj.group !== undefined) {
|
||||
if (cats.includes(proj.group) === false) {
|
||||
cats.push(proj.group);
|
||||
// 数据整合:项目标签
|
||||
var tagNames = [];
|
||||
for (let id of Object.keys(wiki.projects)) {
|
||||
let proj = wiki.projects[id];
|
||||
let tags = proj.tags;
|
||||
if (tags) {
|
||||
if ((typeof tags == 'string') && tags.constructor == String) {
|
||||
if (tagNames.includes(tags) === false) {
|
||||
tagNames.push(tags);
|
||||
}
|
||||
// 类型转换
|
||||
tags = [tags];
|
||||
} else if ((typeof tags == 'object') && tags.constructor == Array) {
|
||||
tags.forEach((tag, i) => {
|
||||
if (tagNames.includes(tag) === false) {
|
||||
tagNames.push(tag);
|
||||
}
|
||||
});
|
||||
}
|
||||
wiki.projects[id].tags = tags;
|
||||
}
|
||||
}
|
||||
// 补充未分组的项目
|
||||
const projs = Object.keys(wiki.projects);
|
||||
wiki_pages.forEach((p, i) => {
|
||||
if (projs.includes(p.wiki) === false) {
|
||||
if (wiki.projects[p.wiki] === undefined) {
|
||||
if (projs.includes(p.wiki) == false) {
|
||||
if (wiki.projects[p.wiki] == undefined) {
|
||||
wiki.projects[p.wiki] = {};
|
||||
wiki.projects[p.wiki].pages = [];
|
||||
}
|
||||
var proj = wiki.projects[p.wiki];
|
||||
if (proj.description === undefined) {
|
||||
if (proj.description == undefined) {
|
||||
proj.description = p.description;
|
||||
}
|
||||
wiki.projects[p.wiki].pages.push(p);
|
||||
}
|
||||
});
|
||||
// 补充项目名称
|
||||
for (let proj_name of Object.keys(wiki.projects)) {
|
||||
let proj = wiki.projects[proj_name];
|
||||
if (proj.title === undefined || proj.title.length === 0) {
|
||||
proj.title = proj_name;
|
||||
// 补充项目名称和首页
|
||||
for (let id of Object.keys(wiki.projects)) {
|
||||
let proj = wiki.projects[id];
|
||||
proj.id = id;
|
||||
if (proj.title == undefined || proj.title.length === 0) {
|
||||
proj.title = id;
|
||||
}
|
||||
}
|
||||
// 补充 order
|
||||
wiki_pages.forEach((p, i) => {
|
||||
if (p.order == undefined) {
|
||||
p.order = 0;
|
||||
}
|
||||
});
|
||||
|
||||
// 数据整合:每个项目的子页面
|
||||
for (let proj_name of Object.keys(wiki.projects)) {
|
||||
let proj = wiki.projects[proj_name];
|
||||
for (let id of Object.keys(wiki.projects)) {
|
||||
let proj = wiki.projects[id];
|
||||
proj.pages = wiki_pages.filter(function (p) {
|
||||
return p.wiki === proj_name;
|
||||
return p.wiki === id;
|
||||
}).sort('order');
|
||||
proj.pages.limit(1).forEach((p, i) => {
|
||||
proj.path = p.path;
|
||||
proj.homepage = p;
|
||||
});
|
||||
// 内页按 section 分组
|
||||
var secs = [];
|
||||
var sectionConfigs = [];
|
||||
if (proj.sections) {
|
||||
for (let t of Object.keys(proj.sections)) {
|
||||
let range = proj.sections[t];
|
||||
if (range.length > 1) {
|
||||
secs.push({
|
||||
sectionConfigs.push({
|
||||
title: t,
|
||||
from: range[0],
|
||||
to: range[1]
|
||||
|
@ -81,37 +108,52 @@ module.exports = hexo => {
|
|||
}
|
||||
}
|
||||
}
|
||||
var newSections = [];
|
||||
secs.forEach((sec, i) => {
|
||||
var sections = [];
|
||||
sectionConfigs.forEach((sec, i) => {
|
||||
const pages = proj.pages.filter(function (p) {
|
||||
return p.order >= sec.from && p.order <= sec.to;
|
||||
});
|
||||
if (pages && pages.length > 0) {
|
||||
newSections.push({
|
||||
sections.push({
|
||||
title: sec.title,
|
||||
pages: pages
|
||||
});
|
||||
}
|
||||
});
|
||||
proj.sections = newSections;
|
||||
|
||||
proj.sections = sections;
|
||||
}
|
||||
|
||||
var groups = {};
|
||||
cats.forEach((group_name, i) => {
|
||||
// 全站所有的项目标签
|
||||
var all_tags = {};
|
||||
tagNames.forEach((tagName, i) => {
|
||||
var projs = [];
|
||||
for (let proj_name of Object.keys(wiki.projects)) {
|
||||
let proj = wiki.projects[proj_name];
|
||||
if (proj.group === group_name && projs.includes(group_name) === false) {
|
||||
projs.push(proj);
|
||||
for (let id of Object.keys(wiki.projects)) {
|
||||
let proj = wiki.projects[id];
|
||||
if (proj.tags && proj.tags.includes(tagName) === true && projs.includes(tagName) === false) {
|
||||
projs.push(proj.id);
|
||||
}
|
||||
}
|
||||
groups[group_name] = {
|
||||
title: group_name,
|
||||
path: (hexo.config.wiki_dir || 'wiki') + '/categories/' + group_name + '/index.html',
|
||||
projects: projs
|
||||
all_tags[tagName] = {
|
||||
name: tagName,
|
||||
path: (hexo.config.wiki_dir || 'wiki') + '/tags/' + tagName + '/index.html',
|
||||
items: projs
|
||||
};
|
||||
});
|
||||
wiki.groups = groups;
|
||||
|
||||
// 整合相似项目
|
||||
for (let id of Object.keys(wiki.projects)) {
|
||||
let proj = wiki.projects[id];
|
||||
if (proj.tags) {
|
||||
var related = [];
|
||||
proj.tags.forEach((tagName, i) => {
|
||||
let tagObj = all_tags[tagName];
|
||||
related = related.concat(tagObj.items);
|
||||
related = [...new Set(related)];
|
||||
});
|
||||
proj.related = related;
|
||||
}
|
||||
}
|
||||
|
||||
wiki.all_tags = all_tags;
|
||||
wiki.all_pages = wiki_pages;
|
||||
};
|
||||
|
|
|
@ -16,15 +16,14 @@ hexo.extend.generator.register('wiki', function (locals) {
|
|||
data: {'filter': false},
|
||||
layout: ['wiki']
|
||||
});
|
||||
if (hexo.theme.config.wiki && hexo.theme.config.wiki.groups) {
|
||||
for (let group_name of Object.keys(hexo.theme.config.wiki.groups)) {
|
||||
let group = hexo.theme.config.wiki.groups[group_name];
|
||||
if (hexo.theme.config.wiki && hexo.theme.config.wiki.all_tags) {
|
||||
for (let id of Object.keys(hexo.theme.config.wiki.all_tags)) {
|
||||
let tag = hexo.theme.config.wiki.all_tags[id];
|
||||
ret.push({
|
||||
path: group.path,
|
||||
path: tag.path,
|
||||
data: {
|
||||
'filter': true,
|
||||
'title': group.title,
|
||||
'group': group.title
|
||||
'tagName': tag.name
|
||||
},
|
||||
layout: ['wiki']
|
||||
});
|
||||
|
|
|
@ -11,10 +11,7 @@ hexo.extend.helper.register('doc_tree', function(page, args){
|
|||
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;
|
||||
}
|
||||
if (p.layout == 'wiki' && p.wiki && p.wiki == page.wiki) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
|
|
|
@ -22,7 +22,7 @@ module.exports = ctx => function(args, content) {
|
|||
});
|
||||
} else if (tabs.length > 0) {
|
||||
var tab = tabs[tabs.length-1];
|
||||
if (tab.body === undefined) {
|
||||
if (tab.body == undefined) {
|
||||
tab.body = item;
|
||||
} else {
|
||||
tab.body += '\n' + item;
|
||||
|
@ -52,7 +52,7 @@ module.exports = ctx => function(args, content) {
|
|||
tabContent = `<div class="tab-content">${tabContent}</div>`;
|
||||
|
||||
el += '<div class="tag-plugin tabs"';
|
||||
if (args.align !== undefined) {
|
||||
if (args.align != undefined) {
|
||||
el += ' align="' + args.align + '"';
|
||||
}
|
||||
el += 'id="' + tabName.toLowerCase().split(' ').join('-') + '"';
|
||||
|
|
|
@ -39,7 +39,7 @@ function outputNoteBlock(args, content) {
|
|||
|
||||
hexo.extend.tag.register('note', function(args) {
|
||||
args = hexo.args.map(args, ['color'], ['title', 'content']);
|
||||
if (args.content === undefined || args.content.length <= 0) {
|
||||
if (args.content == undefined || args.content.length <= 0) {
|
||||
args.content = args.title;
|
||||
args.title = '';
|
||||
}
|
||||
|
|
|
@ -51,7 +51,7 @@ function postTimeline(args, content) {
|
|||
});
|
||||
} else if (nodes.length > 0) {
|
||||
var node = nodes[nodes.length-1];
|
||||
if (node.body === undefined) {
|
||||
if (node.body == undefined) {
|
||||
node.body = item;
|
||||
} else {
|
||||
node.body += '\n' + item;
|
||||
|
|
|
@ -43,7 +43,7 @@ hexo.extend.tag.register('toc', function(args) {
|
|||
|
||||
if (args.wiki) {
|
||||
const proj = hexo.theme.config.wiki.projects[args.wiki];
|
||||
if (proj === undefined) {
|
||||
if (proj == undefined) {
|
||||
return '';
|
||||
}
|
||||
if (proj.sections && proj.sections.length > 1) {
|
||||
|
|
|
@ -53,12 +53,13 @@ $fs-h3 = 1.375rem // 22px
|
|||
$fs-h4 = 1.125rem // 18px
|
||||
$fs-h5 = $fs-15
|
||||
$fs-h6 = $fs-12
|
||||
$fs-p = $fs-15
|
||||
$fs-p = $fs-15
|
||||
$fs-code = $fs-13
|
||||
|
||||
$border-card = 12px
|
||||
$border-widget = 4px
|
||||
$border-block = 4px
|
||||
$border-block = 6px
|
||||
$border-image = 6px
|
||||
|
||||
// 可以动态变化的属性
|
||||
:root
|
||||
|
@ -66,11 +67,9 @@ $border-block = 4px
|
|||
--width-main: 680px
|
||||
--gap-l: 16px
|
||||
--gap-p: 1.25rem // gap for paragraph
|
||||
// desktop or larger
|
||||
@media screen and (min-width: $device-desktop)
|
||||
--gap-l: 32px
|
||||
// desktop 2k or larger
|
||||
@media screen and (min-width: $device-2k)
|
||||
--gap-l: 32px
|
||||
--width-left: 320px
|
||||
--width-main: 740px
|
||||
// desktop 4k or larger
|
||||
|
|
|
@ -29,15 +29,23 @@ article.md.content
|
|||
&:hover
|
||||
a.headerlink:before
|
||||
opacity: 1
|
||||
|
||||
.md
|
||||
ul,ol
|
||||
padding-bottom: .5rem
|
||||
margin: 0
|
||||
blockquote,ul,ol
|
||||
p,ul,ol
|
||||
font-size: $fs-14
|
||||
line-height: 1.5
|
||||
p,blockquote,.tag-plugin,ul,ol,.highlight,table
|
||||
margin-top: var(--gap-p)
|
||||
margin-bottom: var(--gap-p)
|
||||
*
|
||||
--gap-p: .5rem
|
||||
p,.tag-plugin
|
||||
margin-top: var(--gap-p)
|
||||
margin-bottom: var(--gap-p)
|
||||
.highlight,table
|
||||
--gap-p: 1rem
|
||||
|
||||
// titles
|
||||
article.md.content
|
||||
|
@ -105,7 +113,7 @@ article.md blockquote
|
|||
margin-right: 0
|
||||
padding: 1rem
|
||||
background: var(--card)
|
||||
border-left: 4px solid $color-theme
|
||||
border-left: 6px solid $color-theme
|
||||
border-radius: $border-block
|
||||
color: var(--text-p2)
|
||||
box-shadow: $boxshadow-card
|
||||
|
|
|
@ -33,7 +33,6 @@
|
|||
color: var(--text-p2)
|
||||
align-items: center
|
||||
justify-content: space-between
|
||||
border: 1px solid transparent
|
||||
.badge
|
||||
color: $color-theme
|
||||
font-weight: 700
|
||||
|
@ -42,7 +41,6 @@
|
|||
&:hover
|
||||
background: var(--block)
|
||||
color: var(--text-p0)
|
||||
border-color: var(--block-border)
|
||||
.badge
|
||||
opacity: 1
|
||||
|
||||
|
@ -54,20 +52,18 @@
|
|||
align-items: center
|
||||
position: relative
|
||||
color: var(--text-p2)
|
||||
padding: 8px
|
||||
border-radius: $border-block
|
||||
border: 1px solid transparent
|
||||
span
|
||||
margin: 0 0.25rem
|
||||
margin: 4px 8px
|
||||
padding: 4px 8px
|
||||
border-radius: 64px
|
||||
.badge
|
||||
color: $color-theme
|
||||
margin-left: 4px
|
||||
font-weight: 700
|
||||
font-family: $ff-code
|
||||
opacity: .5
|
||||
opacity: .75
|
||||
align-self: flex-start
|
||||
&:hover
|
||||
color: var(--text-p0)
|
||||
background: var(--block)
|
||||
border-color: var(--block-border)
|
||||
.badge
|
||||
opacity: 1
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
.widget-wrap#repo-info
|
||||
.widget-body
|
||||
border: 1px solid var(--block-border)
|
||||
border-radius: $border-block
|
||||
background: var(--block)
|
||||
overflow: hidden
|
||||
>.items
|
||||
margin: 4px 0
|
||||
border: 1px solid var(--block-border)
|
||||
border-radius: $border-block
|
||||
background: var(--block)
|
||||
overflow: hidden
|
||||
.line
|
||||
margin: 0
|
||||
height: 1px
|
||||
|
|
|
@ -158,8 +158,9 @@ nav.menu
|
|||
position: -webkit-sticky
|
||||
top: -2px
|
||||
background: var(--site-bg)
|
||||
padding: 2px 0
|
||||
padding-top: 2px
|
||||
z-index 1
|
||||
line-height: 2.4
|
||||
&:empty
|
||||
display: none
|
||||
.cap-action
|
||||
|
@ -182,6 +183,8 @@ nav.menu
|
|||
margin-bottom: 0.5em
|
||||
>a:hover
|
||||
text-decoration: underline
|
||||
.widget-header+.widget-body
|
||||
margin-top: 0
|
||||
.widget-wrap#recent .widget-body, .widget-wrap#related .widget-body
|
||||
>a
|
||||
padding 0.5rem
|
||||
|
@ -210,4 +213,4 @@ nav.menu
|
|||
display: -webkit-box
|
||||
-webkit-box-orient: vertical
|
||||
overflow: hidden
|
||||
-webkit-line-clamp: 3
|
||||
-webkit-line-clamp: 5
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
.widget-wrap#toc .doc-tree:only-child
|
||||
.widget-wrap.single#toc .doc-tree
|
||||
&.active>.toc
|
||||
border-left: 2px solid var(--block-hover)
|
||||
|
|
|
@ -1,10 +1,16 @@
|
|||
// toc padding
|
||||
.widget-wrap#toc .widget-header
|
||||
line-height: 2.4
|
||||
|
||||
#toc .widget-body
|
||||
line-height: 1.2
|
||||
margin-top: 0
|
||||
ul ul, ul ol
|
||||
padding-left: 0
|
||||
ol ul, ol ol
|
||||
padding-left: 0
|
||||
|
||||
.doc-tree
|
||||
margin: 4px 0
|
||||
.toc
|
||||
padding: 0
|
||||
margin: 0
|
||||
|
|
|
@ -2,16 +2,17 @@
|
|||
.widget-body+.widget-header
|
||||
margin-top: 1rem
|
||||
|
||||
.widget-wrap.multi#toc .widget-header
|
||||
color: var(--text-p1)
|
||||
font-size: $fs-14
|
||||
|
||||
|
||||
// 其它分页链接
|
||||
.widget-wrap#toc .multi .doc-tree
|
||||
border-radius: 4px
|
||||
margin: 4px 0
|
||||
.widget-wrap.multi#toc .doc-tree
|
||||
border-radius: $border-block
|
||||
background: var(--block)
|
||||
overflow: hidden
|
||||
border: 1px solid var(--block-border)
|
||||
&:first-child
|
||||
margin-top: 0
|
||||
a.doc-tree-link
|
||||
color: var(--text-p2)
|
||||
padding: 0.5rem
|
||||
|
@ -33,7 +34,7 @@
|
|||
|
||||
|
||||
// 当前分页链接
|
||||
.widget-wrap#toc .multi .doc-tree.active
|
||||
.widget-wrap.multi#toc .doc-tree.active
|
||||
a.doc-tree-link
|
||||
background: var(--block)
|
||||
font-weight: 700
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
.tag-plugin.about
|
||||
background: var(--block)
|
||||
border-radius: 6px
|
||||
border-radius: $border-block
|
||||
padding: 2rem
|
||||
.about-header
|
||||
display flex
|
||||
|
|
|
@ -15,17 +15,20 @@
|
|||
|
||||
input.copy-area
|
||||
display: inline-block
|
||||
padding: 1em
|
||||
padding: 0
|
||||
width: 100%
|
||||
color: var(--text-p2)
|
||||
line-height: 3
|
||||
text-indent: 1rem
|
||||
button.copy-btn
|
||||
margin: 0
|
||||
line-height: 3
|
||||
border-left: 1px solid var(--block-border)
|
||||
display: inline-block
|
||||
background: var(--block-hover)
|
||||
line-height: 0
|
||||
font-size: 1rem
|
||||
padding: 0.5rem 1rem
|
||||
padding: 0 .75rem
|
||||
color: var(--text-p2)
|
||||
&:hover
|
||||
background: var(--card)
|
||||
|
|
|
@ -8,7 +8,7 @@ details.folding
|
|||
border: 1px solid var(--theme)
|
||||
summary
|
||||
cursor: pointer
|
||||
padding: 1rem
|
||||
padding: .75rem 1rem
|
||||
margin: 0 - 1rem
|
||||
border-radius: $border-block
|
||||
color: var(--text-p2)
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
.image-bg
|
||||
line-height: 0
|
||||
text-align: center
|
||||
border-radius: 4px
|
||||
border-radius: $border-image
|
||||
position: relative
|
||||
overflow: hidden
|
||||
&:hover
|
||||
|
@ -12,7 +12,7 @@
|
|||
opacity: 1 !important
|
||||
img
|
||||
display: inline-block
|
||||
object-fit: contain
|
||||
object-fit: cover
|
||||
.image-download
|
||||
position: absolute
|
||||
bottom: 8px
|
||||
|
@ -37,7 +37,3 @@
|
|||
color: var(--text-p3)
|
||||
&:empty
|
||||
display: none
|
||||
// &.left
|
||||
// text-align: left
|
||||
// &.center
|
||||
// text-align: center
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
@media screen and (max-width: $device-mobile-375)
|
||||
width: 100%
|
||||
box-shadow: $boxshadow-card
|
||||
border-radius: $border-widget
|
||||
border-radius: $border-block
|
||||
trans2: box-shadow transform
|
||||
&:hover
|
||||
box-shadow: $boxshadow-card-float
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
.md .tag-plugin.note
|
||||
$border-block = 4px
|
||||
position: relative
|
||||
margin-top: 1rem
|
||||
margin-bottom: 1rem
|
||||
|
@ -41,3 +40,6 @@
|
|||
margin: 0
|
||||
>.tabs
|
||||
margin-top: .5rem
|
||||
|
||||
.md .tag-plugin .tag-plugin.note
|
||||
--gap-p: 1rem
|
||||
|
|
|
@ -73,6 +73,7 @@
|
|||
.tab-content
|
||||
max-width: 100%
|
||||
text-align: justify
|
||||
margin-top: .5rem
|
||||
.tab-pane
|
||||
&:not(.active)
|
||||
display: none
|
||||
|
|
Loading…
Reference in New Issue