[opt] tag -> hashtag
This commit is contained in:
parent
761e9e6882
commit
38bfa89c09
|
@ -38,7 +38,7 @@ sidebar:
|
||||||
# 文章内页
|
# 文章内页
|
||||||
post: search_blog, toc, ghrepo, ghissues # for pages using 'layout:post'
|
post: search_blog, toc, ghrepo, ghissues # for pages using 'layout:post'
|
||||||
# 文档内页
|
# 文档内页
|
||||||
wiki: search, ghrepo, toc, ghissues, related # for pages using 'layout:wiki'
|
wiki: search, toc, ghissues, related # for pages using 'layout:wiki'
|
||||||
# 其它 layout:page 的页面
|
# 其它 layout:page 的页面
|
||||||
page: toc, search # for custom pages using 'layout:page'
|
page: toc, search # for custom pages using 'layout:page'
|
||||||
|
|
||||||
|
@ -248,9 +248,9 @@ tag_plugins:
|
||||||
# {% mark %}
|
# {% mark %}
|
||||||
mark:
|
mark:
|
||||||
default_color: dark # light, dark, red, orange, yellow, green, cyan, blue, purple, warning, error
|
default_color: dark # light, dark, red, orange, yellow, green, cyan, blue, purple, warning, error
|
||||||
# {% tag %}
|
# {% hashtag %}
|
||||||
tag:
|
hashtag:
|
||||||
default_color: yellow # red, orange, yellow, green, cyan, blue, purple
|
default_color: # red, orange, yellow, green, cyan, blue, purple
|
||||||
|
|
||||||
|
|
||||||
######## JS Plugins ########
|
######## JS Plugins ########
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
<% if (page.layout === 'post' || (page.layout === 'wiki' && page.wiki && page.wiki.length > 0)) { %>
|
<% if (page.layout === 'post' || (page.layout === 'wiki' && page.wiki && page.wiki.length > 0)) { %>
|
||||||
<script>
|
<script>
|
||||||
let tianliGPT_postSelector = '.md-text.content.<%= page.layout === 'post' ? 'post' : 'wiki' %>';
|
let tianliGPT_postSelector = '.md-text.content.<%= page.layout === "post" ? "post" : "wiki" %>';
|
||||||
let tianliGPT_key = '<%= theme.plugins.tianli_gpt.api %>';
|
let tianliGPT_key = '<%= theme.plugins.tianli_gpt.api %>';
|
||||||
let tianliGPT_typingAnimate = <%= theme.plugins.tianli_gpt.typingAnimate %>;
|
let tianliGPT_typingAnimate = '<%= theme.plugins.tianli_gpt.typingAnimate %>';
|
||||||
</script>
|
</script>
|
||||||
<script defer src="https://cdn1.tianli0.top/gh/zhheo/Post-Abstract-AI@0.13/tianli_gpt.js"></script>
|
<script defer src="https://cdn1.tianli0.top/gh/zhheo/Post-Abstract-AI@0.13/tianli_gpt.js"></script>
|
||||||
<% } %>
|
<% } %>
|
||||||
|
|
|
@ -12,18 +12,23 @@ function layoutDiv() {
|
||||||
} else if (page.layout === 'wiki' && page.wiki && page.wiki.length > 0) {
|
} else if (page.layout === 'wiki' && page.wiki && page.wiki.length > 0) {
|
||||||
let proj = theme.wiki.tree[page.wiki];
|
let proj = theme.wiki.tree[page.wiki];
|
||||||
if (proj) {
|
if (proj) {
|
||||||
const current = page.order || 0;
|
let ps = proj.pages.filter(p => p.path == page.path)
|
||||||
proj.pages.forEach((p, i) => {
|
if (ps.length > 0) {
|
||||||
if (p.order < current) {
|
const current_page_number = ps[0].page_number || 0;
|
||||||
if (prev == undefined || p.order > prev.order) {
|
proj.pages.forEach((p, i) => {
|
||||||
prev = p;
|
if (p.page_number < current_page_number) {
|
||||||
|
if (prev == undefined || p.page_number > prev.page_number) {
|
||||||
|
prev = p;
|
||||||
|
}
|
||||||
|
} else if (p.page_number > current_page_number) {
|
||||||
|
if (next == undefined || p.page_number < next.page_number) {
|
||||||
|
next = p;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else if (p.order > current) {
|
});
|
||||||
if (next == undefined || p.order < next.order) {
|
} else {
|
||||||
next = p;
|
console.error('未找到当前页');
|
||||||
}
|
}
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
let el = '';
|
let el = '';
|
||||||
|
|
|
@ -20,6 +20,7 @@ function layoutDiv() {
|
||||||
firstCat = page.categories.data[0].name;
|
firstCat = page.categories.data[0].name;
|
||||||
}
|
}
|
||||||
el += '<div class="bread-nav fs12">';
|
el += '<div class="bread-nav fs12">';
|
||||||
|
el += '<div class="left">';
|
||||||
el += '<div id="breadcrumb">';
|
el += '<div id="breadcrumb">';
|
||||||
el += '<a class="cap breadcrumb" href="' + config.root + '">' + home_title + '</a>';
|
el += '<a class="cap breadcrumb" href="' + config.root + '">' + home_title + '</a>';
|
||||||
el += '<span class="sep"></span>';
|
el += '<span class="sep"></span>';
|
||||||
|
@ -39,8 +40,10 @@ function layoutDiv() {
|
||||||
el += __("meta.created") + ' <time datetime="' + date_xml(page.date) + '">' + date(page.date, config.date_format) + '</time>';
|
el += __("meta.created") + ' <time datetime="' + date_xml(page.date) + '">' + date(page.date, config.date_format) + '</time>';
|
||||||
el += '</div>';
|
el += '</div>';
|
||||||
el += '</div>';
|
el += '</div>';
|
||||||
|
el += '</div>';
|
||||||
} else if (page.layout === "wiki" && page.wiki && page.wiki.length > 0) {
|
} else if (page.layout === "wiki" && page.wiki && page.wiki.length > 0) {
|
||||||
el += '<div class="bread-nav fs12">';
|
el += '<div class="bread-nav fs12">';
|
||||||
|
el += '<div class="left">';
|
||||||
el += '<div id="breadcrumb">';
|
el += '<div id="breadcrumb">';
|
||||||
var nodes = [];
|
var nodes = [];
|
||||||
// home
|
// home
|
||||||
|
@ -60,7 +63,7 @@ function layoutDiv() {
|
||||||
// 项目名
|
// 项目名
|
||||||
let proj = theme.wiki.tree[page.wiki];
|
let proj = theme.wiki.tree[page.wiki];
|
||||||
if (proj != null) {
|
if (proj != null) {
|
||||||
let url_proj = url_for(proj.homepage.path);
|
let url_proj = url_for(proj.homepage?.path);
|
||||||
if (nodes.includes(url_proj) === false) {
|
if (nodes.includes(url_proj) === false) {
|
||||||
el += '<span class="sep"></span>';
|
el += '<span class="sep"></span>';
|
||||||
el += '<a class="cap breadcrumb" id="proj" href="' + url_proj + '">' + (proj.name || proj.title) + '</a>';
|
el += '<a class="cap breadcrumb" id="proj" href="' + url_proj + '">' + (proj.name || proj.title) + '</a>';
|
||||||
|
@ -72,14 +75,39 @@ function layoutDiv() {
|
||||||
el += __("meta.updated") + ' <time datetime="' + date_xml(page.updated) + '">' + date(page.updated, config.date_format) + '</time>';
|
el += __("meta.updated") + ' <time datetime="' + date_xml(page.updated) + '">' + date(page.updated, config.date_format) + '</time>';
|
||||||
el += '</div>';
|
el += '</div>';
|
||||||
el += '</div>';
|
el += '</div>';
|
||||||
|
|
||||||
|
let repo = page.repo || proj.repo
|
||||||
|
if (repo) {
|
||||||
|
el += `
|
||||||
|
<div class="right ghrepo stellar-ghinfo-api" api="${theme.api_host.ghapi}/repos/${repo}">
|
||||||
|
<a class="repo-link bold" href="https://github.com/${repo}">
|
||||||
|
<svg aria-hidden="true" role="img" class="color-icon-primary" viewBox="0 0 16 16" width="1em" height="1em" fill="currentColor" style="user-select:none;overflow:visible"><path fill-rule="evenodd" d="M2 2.5A2.5 2.5 0 014.5 0h8.75a.75.75 0 01.75.75v12.5a.75.75 0 01-.75.75h-2.5a.75.75 0 110-1.5h1.75v-2h-8a1 1 0 00-.714 1.7.75.75 0 01-1.072 1.05A2.495 2.495 0 012 11.5v-9zm10.5-1V9h-8c-.356 0-.694.074-1 .208V2.5a1 1 0 011-1h8zM5 12.25v3.25a.25.25 0 00.4.2l1.45-1.087a.25.25 0 01.3 0L8.6 15.7a.25.25 0 00.4-.2v-3.25a.25.25 0 00-.25-.25h-3.5a.25.25 0 00-.25.25z"></path></svg>
|
||||||
|
<span type="text">${repo}</span>
|
||||||
|
</a>
|
||||||
|
<a class="repo-link" href="https://github.com/${repo}/stargazers">
|
||||||
|
<svg aria-hidden="true" role="img" class="color-icon-primary" viewBox="0 0 16 16" width="1em" height="1em" fill="currentColor" style="user-select:none;overflow:visible"><path fill-rule="evenodd" d="M8 .25a.75.75 0 01.673.418l1.882 3.815 4.21.612a.75.75 0 01.416 1.279l-3.046 2.97.719 4.192a.75.75 0 01-1.088.791L8 12.347l-3.766 1.98a.75.75 0 01-1.088-.79l.72-4.194L.818 6.374a.75.75 0 01.416-1.28l4.21-.611L7.327.668A.75.75 0 018 .25zm0 2.445L6.615 5.5a.75.75 0 01-.564.41l-3.097.45 2.24 2.184a.75.75 0 01.216.664l-.528 3.084 2.769-1.456a.75.75 0 01.698 0l2.77 1.456-.53-3.084a.75.75 0 01.216-.664l2.24-2.183-3.096-.45a.75.75 0 01-.564-.41L8 2.694v.001z"></path></svg>
|
||||||
|
<span type="text" id="stargazers_count">0</span><span>stars</span>
|
||||||
|
</a>
|
||||||
|
<a class="repo-link" href="https://github.com/${repo}/forks">
|
||||||
|
<svg aria-hidden="true" role="img" class="color-icon-primary" viewBox="0 0 16 16" width="1em" height="1em" fill="currentColor" style="user-select:none;overflow:visible"><path fill-rule="evenodd" d="M5 3.25a.75.75 0 11-1.5 0 .75.75 0 011.5 0zm0 2.122a2.25 2.25 0 10-1.5 0v.878A2.25 2.25 0 005.75 8.5h1.5v2.128a2.251 2.251 0 101.5 0V8.5h1.5a2.25 2.25 0 002.25-2.25v-.878a2.25 2.25 0 10-1.5 0v.878a.75.75 0 01-.75.75h-4.5A.75.75 0 015 6.25v-.878zm3.75 7.378a.75.75 0 11-1.5 0 .75.75 0 011.5 0zm3-8.75a.75.75 0 100-1.5.75.75 0 000 1.5z"></path></svg>
|
||||||
|
<span type="text" id="forks_count">0</span><span>forks</span>
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
`;
|
||||||
|
}
|
||||||
|
el += '</div>';
|
||||||
} else if (page.title || page.seo_title) {
|
} else if (page.title || page.seo_title) {
|
||||||
el += '<div class="bread-nav fs12">';
|
el += `
|
||||||
el += '<div id="breadcrumb">';
|
<div class="bread-nav fs12">
|
||||||
el += '<a class="cap breadcrumb" href="' + config.root + '">' + home_title + '</a>';
|
<div class="left">
|
||||||
el += '<span class="sep"></span>';
|
<div id="breadcrumb">
|
||||||
el += '<a class="cap breadcrumb" href="' + url_for(page.path) + '">' + (page.title || page.seo_title) + '</a>';
|
<a class="cap breadcrumb" href="${config.root}">${home_title}</a>
|
||||||
el += '</div>';
|
<span class="sep"></span>
|
||||||
el += '</div>';
|
<a class="cap breadcrumb" href="${url_for(page.path)}">${page.title || page.seo_title}</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
`;
|
||||||
}
|
}
|
||||||
return el;
|
return el;
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,9 +11,10 @@ function layoutDiv() {
|
||||||
el += ' href="' + url_for(config.wiki_dir || "/wiki/") + '">' + __("btn.all_wiki") + '</a>';
|
el += ' href="' + url_for(config.wiki_dir || "/wiki/") + '">' + __("btn.all_wiki") + '</a>';
|
||||||
el += '</a>';
|
el += '</a>';
|
||||||
// 项目分类
|
// 项目分类
|
||||||
for (let id of Object.keys(theme.wiki.all_tags)) {
|
const { shelf, all_tags } = theme.wiki;
|
||||||
let tag = theme.wiki.all_tags[id];
|
for (let id of Object.keys(all_tags)) {
|
||||||
let projects = tag.items.filter(item => item.index !== false)
|
let tag = all_tags[id];
|
||||||
|
let projects = tag.items.filter(item => shelf.includes(item))
|
||||||
if (projects && projects.length > 0) {
|
if (projects && projects.length > 0) {
|
||||||
el += '<a';
|
el += '<a';
|
||||||
if (tag.name && tag.name.length > 0 && page.tagName === tag.name) {
|
if (tag.name && tag.name.length > 0 && page.tagName === tag.name) {
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
try {
|
try {
|
||||||
el.innerHTML = '';
|
el.innerHTML = '';
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log(error);
|
console.error(error);
|
||||||
}
|
}
|
||||||
var script = document.createElement('script');
|
var script = document.createElement('script');
|
||||||
script.src = 'https://beaudar.lipk.org/client.js';
|
script.src = 'https://beaudar.lipk.org/client.js';
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
try {
|
try {
|
||||||
el.innerHTML = '';
|
el.innerHTML = '';
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log(error);
|
console.error(error);
|
||||||
}
|
}
|
||||||
var script = document.createElement('script');
|
var script = document.createElement('script');
|
||||||
script.src = 'https://giscus.app/client.js';
|
script.src = 'https://giscus.app/client.js';
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
try {
|
try {
|
||||||
el.innerHTML = '';
|
el.innerHTML = '';
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log(error);
|
console.error(error);
|
||||||
}
|
}
|
||||||
var script = document.createElement('script');
|
var script = document.createElement('script');
|
||||||
script.src = 'https://utteranc.es/client.js';
|
script.src = 'https://utteranc.es/client.js';
|
||||||
|
|
|
@ -4,11 +4,12 @@ function layoutDiv() {
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
var related = [];
|
var related = [];
|
||||||
let proj = theme.wiki.tree[page.wiki];
|
const { shelf, tree } = theme.wiki;
|
||||||
|
let proj = tree[page.wiki];
|
||||||
if (proj?.related?.length > 0) {
|
if (proj?.related?.length > 0) {
|
||||||
proj.related.forEach((pid, i) => {
|
proj.related.filter(pid => shelf.includes(pid)).forEach((pid, i) => {
|
||||||
let p = theme.wiki.tree[pid];
|
let p = tree[pid];
|
||||||
if (p && p.title !== proj?.title && p.index !== false) {
|
if (p && p.title !== proj?.title) {
|
||||||
related.push(p);
|
related.push(p);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -25,8 +26,11 @@ function layoutDiv() {
|
||||||
el += '</div>';
|
el += '</div>';
|
||||||
el += '<div class="widget-body related-posts">';
|
el += '<div class="widget-body related-posts">';
|
||||||
related.forEach((p, i) => {
|
related.forEach((p, i) => {
|
||||||
|
if (p.homepage == null) {
|
||||||
|
console.error("未找到首页:", p.title);
|
||||||
|
}
|
||||||
// 同一个分组中的其它项目
|
// 同一个分组中的其它项目
|
||||||
el += '<a class="item wiki" href="' + url_for(p.homepage.path) + '">';
|
el += '<a class="item wiki" href="' + url_for(p.homepage?.path) + '">';
|
||||||
el += '<span class="title">' + p.title + '</span>';
|
el += '<span class="title">' + p.title + '</span>';
|
||||||
if (p.description && p.description.length > 0) {
|
if (p.description && p.description.length > 0) {
|
||||||
el += '<span class="excerpt">' + p.description + '</span>';
|
el += '<span class="excerpt">' + p.description + '</span>';
|
||||||
|
|
|
@ -22,7 +22,10 @@ function layoutTocHeader(title) {
|
||||||
|
|
||||||
function layoutDocTree(pages) {
|
function layoutDocTree(pages) {
|
||||||
var el = '';
|
var el = '';
|
||||||
pages.forEach((p, i) => {
|
for (let p of pages) {
|
||||||
|
if (p.title == null || p.title.length == 0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
let isActive = '';
|
let isActive = '';
|
||||||
if (p.path === page.path) {
|
if (p.path === page.path) {
|
||||||
isActive += ' active';
|
isActive += ' active';
|
||||||
|
@ -34,14 +37,14 @@ function layoutDocTree(pages) {
|
||||||
href += '#start'
|
href += '#start'
|
||||||
}
|
}
|
||||||
el += '<a class="doc-tree-link' + isActive + '" href="' + href + '">';
|
el += '<a class="doc-tree-link' + isActive + '" href="' + href + '">';
|
||||||
el += '<span class="toc-text">' + (p.title || p.seo_title) + '</span>';
|
el += '<span class="toc-text">' + p.title + '</span>';
|
||||||
el += '</a>';
|
el += '</a>';
|
||||||
}
|
}
|
||||||
if (p.path === page.path) {
|
if (p.path === page.path) {
|
||||||
el += layoutToc();
|
el += layoutToc();
|
||||||
}
|
}
|
||||||
el += '</div>';
|
el += '</div>';
|
||||||
});
|
}
|
||||||
return el;
|
return el;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -74,9 +77,8 @@ function layoutDiv(fallback) {
|
||||||
el += '</div>';
|
el += '</div>';
|
||||||
} else if (proj) {
|
} else if (proj) {
|
||||||
// wiki 布局
|
// wiki 布局
|
||||||
if (proj.sections && proj.sections.length > 1) {
|
if (proj.sections && proj.sections.length > 0 && proj.pages.length > 1) { // 多 pages
|
||||||
proj.sections.forEach((sec, i) => {
|
proj.sections.forEach((sec, i) => {
|
||||||
// 多 section
|
|
||||||
if (sec.title?.length > 0) {
|
if (sec.title?.length > 0) {
|
||||||
el += layoutTocHeader(sec.title);
|
el += layoutTocHeader(sec.title);
|
||||||
}
|
}
|
||||||
|
@ -84,8 +86,7 @@ function layoutDiv(fallback) {
|
||||||
el += layoutDocTree(sec.pages);
|
el += layoutDocTree(sec.pages);
|
||||||
el += '</div>';
|
el += '</div>';
|
||||||
});
|
});
|
||||||
} else {
|
} else { // 单 page
|
||||||
// 单 section
|
|
||||||
if (proj.pages.length == 1) {
|
if (proj.pages.length == 1) {
|
||||||
el += layoutTocHeader(page.toc_title);
|
el += layoutTocHeader(page.toc_title);
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,13 +51,13 @@ function layout_posts(partial) {
|
||||||
function layout_wikis(partial) {
|
function layout_wikis(partial) {
|
||||||
var el = '';
|
var el = '';
|
||||||
var wikis = [];
|
var wikis = [];
|
||||||
const wiki_tree = theme.wiki.tree;
|
const { shelf, tree } = theme.wiki;
|
||||||
for (let proj_name of Object.keys(wiki_tree)) {
|
for (let pid of shelf) {
|
||||||
let proj = wiki_tree[proj_name];
|
let proj = tree[pid];
|
||||||
if (proj == null) {
|
if (proj == null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (proj.index === false || proj.pages == undefined || proj.pages.length === 0) {
|
if (proj.pages == undefined || proj.pages.length === 0) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (page.filter === false) {
|
if (page.filter === false) {
|
||||||
|
|
|
@ -35,10 +35,16 @@ function getWikiObject(ctx) {
|
||||||
if (obj.sort == null) {
|
if (obj.sort == null) {
|
||||||
obj.sort = 0
|
obj.sort = 0
|
||||||
}
|
}
|
||||||
|
if (obj.path?.startsWith('/')) {
|
||||||
|
obj.path = obj.path.substring(1)
|
||||||
|
}
|
||||||
|
if (obj.path?.endsWith('/') == false) {
|
||||||
|
obj.path = obj.path + '/'
|
||||||
|
}
|
||||||
list.push(obj)
|
list.push(obj)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
list = list.sort((p1, p2) => p1.sort - p2.sort)
|
list = list.sort((p1, p2) => p2.sort - p1.sort)
|
||||||
for (let item of list) {
|
for (let item of list) {
|
||||||
wiki.tree[item.id] = item
|
wiki.tree[item.id] = item
|
||||||
}
|
}
|
||||||
|
@ -81,10 +87,13 @@ module.exports = ctx => {
|
||||||
}
|
}
|
||||||
|
|
||||||
// 数据整合:每个项目的子页面
|
// 数据整合:每个项目的子页面
|
||||||
for (let id of wiki_list) {
|
for (let i = 0; i < wiki_list.length; i++) {
|
||||||
|
let id = wiki_list[i];
|
||||||
let item = wiki.tree[id]
|
let item = wiki.tree[id]
|
||||||
let sub_pages = wiki_pages.filter(p => p.wiki === id)
|
let sub_pages = wiki_pages.filter(p => p.wiki === id)
|
||||||
if (!sub_pages || sub_pages.length == 0) {
|
if (!sub_pages || sub_pages.length == 0) {
|
||||||
|
wiki_list.splice(i, 1)
|
||||||
|
delete wiki.tree[id]
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -92,10 +101,15 @@ module.exports = ctx => {
|
||||||
// 未特别指定首页时,获取TOC第一页作为首页
|
// 未特别指定首页时,获取TOC第一页作为首页
|
||||||
if (item.homepage == null && item.toc != null) {
|
if (item.homepage == null && item.toc != null) {
|
||||||
for (let id of Object.keys(item.toc)) {
|
for (let id of Object.keys(item.toc)) {
|
||||||
const path_key = item.toc[id]
|
const sec = item.toc[id]
|
||||||
let hs = sub_pages.filter(p => (p.path_key.endsWith(path_key)))
|
for (let key of sec) {
|
||||||
if (hs.length > 0) {
|
let hs = sub_pages.filter(p => p.path_key == item.path + key)
|
||||||
item.homepage = hs[0]
|
if (hs.length > 0) {
|
||||||
|
item.homepage = hs[0]
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (item.homepage != null) {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -108,24 +122,35 @@ module.exports = ctx => {
|
||||||
var sections = []
|
var sections = []
|
||||||
var others = sub_pages
|
var others = sub_pages
|
||||||
if (item.toc) {
|
if (item.toc) {
|
||||||
|
// 根据配置设置顺序
|
||||||
for (let title of Object.keys(item.toc)) {
|
for (let title of Object.keys(item.toc)) {
|
||||||
let key_list = item.toc[title]
|
var sec = { title: title, pages: []}
|
||||||
var arr = []
|
for (let key of item.toc[title]) {
|
||||||
for (let key of key_list) {
|
sec.pages = sec.pages.concat(sub_pages.filter(p => p.path_key == item.path + key))
|
||||||
arr = arr.concat(sub_pages.filter(p => p.path_key.endsWith(key)))
|
others = others.filter(p => p.path_key != item.path + key)
|
||||||
others = others.filter(p => p.path_key.endsWith(key) == false)
|
|
||||||
}
|
}
|
||||||
|
sections.push(sec)
|
||||||
|
}
|
||||||
|
if (others.length > 0 && others.filter(p => p.title?.length > 0).length > 0) {
|
||||||
sections.push({
|
sections.push({
|
||||||
title: title,
|
title: '...',
|
||||||
pages: arr
|
pages: others.sort((p1, p2) => p1.path - p2.path)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
if (others.length > 0) {
|
// 自动设置顺序
|
||||||
sections.push({
|
sections.push({
|
||||||
pages: others
|
pages: sub_pages.sort((p1, p2) => p1.path - p2.path)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// page number
|
||||||
|
var page_number = 0
|
||||||
|
for (let sec of sections) {
|
||||||
|
for (let page of sec.pages) {
|
||||||
|
page.page_number = page_number++
|
||||||
|
}
|
||||||
|
}
|
||||||
item.sections = sections
|
item.sections = sections
|
||||||
item.pages = sub_pages
|
item.pages = sub_pages
|
||||||
}
|
}
|
||||||
|
@ -163,6 +188,7 @@ module.exports = ctx => {
|
||||||
|
|
||||||
wiki.all_tags = all_tags
|
wiki.all_tags = all_tags
|
||||||
wiki.all_pages = wiki_pages
|
wiki.all_pages = wiki_pages
|
||||||
|
wiki.shelf = ctx.locals.get('data').wiki
|
||||||
ctx.theme.config.wiki = wiki
|
ctx.theme.config.wiki = wiki
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,6 +32,6 @@ hexo.extend.tag.register('navbar', require('./lib/navbar')(hexo))
|
||||||
hexo.extend.tag.register('note', require('./lib/note')(hexo))
|
hexo.extend.tag.register('note', require('./lib/note')(hexo))
|
||||||
hexo.extend.tag.register('poetry', require('./lib/poetry')(hexo), true)
|
hexo.extend.tag.register('poetry', require('./lib/poetry')(hexo), true)
|
||||||
hexo.extend.tag.register('quot', require('./lib/quot')(hexo))
|
hexo.extend.tag.register('quot', require('./lib/quot')(hexo))
|
||||||
hexo.extend.tag.register('tag', require('./lib/tag')(hexo))
|
hexo.extend.tag.register('hashtag', require('./lib/hashtag')(hexo))
|
||||||
|
|
||||||
// others
|
// others
|
||||||
|
|
|
@ -0,0 +1,36 @@
|
||||||
|
/**
|
||||||
|
* hashtag.js v1.0 | https://github.com/xaoxuu/hexo-theme-stellar/
|
||||||
|
* 格式与官方标签插件一致使用空格分隔,中括号内的是可选参数(中括号不需要写出来)
|
||||||
|
*
|
||||||
|
* {% hashtag text href [color:color] %}
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
'use strict'
|
||||||
|
|
||||||
|
const tag_colors = ['red', 'orange', 'yellow', 'green', 'cyan', 'blue', 'purple']
|
||||||
|
var tag_index = 0
|
||||||
|
|
||||||
|
module.exports = ctx => function(args) {
|
||||||
|
args = ctx.args.map(args, ['color'], ['text', 'href'])
|
||||||
|
if (args.color == null) {
|
||||||
|
const default_color = ctx.theme.config.tag_plugins.hashtag?.default_color
|
||||||
|
if (default_color) {
|
||||||
|
args.color = default_color
|
||||||
|
} else {
|
||||||
|
args.color = tag_colors[tag_index]
|
||||||
|
tag_index += 1
|
||||||
|
if (tag_index >= tag_colors.length) {
|
||||||
|
tag_index = 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
var el = ''
|
||||||
|
el += '<a class="tag-plugin hashtag"'
|
||||||
|
el += ' ' + ctx.args.joinTags(args, ['color', 'href']).join(' ')
|
||||||
|
el += '>'
|
||||||
|
el += '<svg t="1701408144765" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="4228" width="200" height="200"><path d="M426.6 64.8c34.8 5.8 58.4 38.8 52.6 73.6l-19.6 117.6h190.2l23-138.6c5.8-34.8 38.8-58.4 73.6-52.6s58.4 38.8 52.6 73.6l-19.4 117.6H896c35.4 0 64 28.6 64 64s-28.6 64-64 64h-137.8l-42.6 256H832c35.4 0 64 28.6 64 64s-28.6 64-64 64h-137.8l-23 138.6c-5.8 34.8-38.8 58.4-73.6 52.6s-58.4-38.8-52.6-73.6l19.6-117.4h-190.4l-23 138.6c-5.8 34.8-38.8 58.4-73.6 52.6s-58.4-38.8-52.6-73.6l19.4-117.8H128c-35.4 0-64-28.6-64-64s28.6-64 64-64h137.8l42.6-256H192c-35.4 0-64-28.6-64-64s28.6-64 64-64h137.8l23-138.6c5.8-34.8 38.8-58.4 73.6-52.6z m11.6 319.2l-42.6 256h190.2l42.6-256h-190.2z" p-id="4229"></path></svg>'
|
||||||
|
el += '<span>' + args.text + '</span>'
|
||||||
|
el += '</a>'
|
||||||
|
return el
|
||||||
|
}
|
|
@ -1,35 +0,0 @@
|
||||||
/**
|
|
||||||
* tag.js v1.0 | https://github.com/xaoxuu/hexo-theme-stellar/
|
|
||||||
* 格式与官方标签插件一致使用空格分隔,中括号内的是可选参数(中括号不需要写出来)
|
|
||||||
*
|
|
||||||
* {% tag text href [color:color] %}
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
'use strict'
|
|
||||||
|
|
||||||
const tag_colors = ['red', 'orange', 'yellow', 'green', 'cyan', 'blue', 'purple']
|
|
||||||
var tag_index = 0
|
|
||||||
|
|
||||||
module.exports = ctx => function(args) {
|
|
||||||
args = ctx.args.map(args, ['color'], ['text', 'href'])
|
|
||||||
if (args.color == null) {
|
|
||||||
const default_color = ctx.theme.config.tag_plugins.tag?.default_color
|
|
||||||
if (default_color) {
|
|
||||||
args.color = default_color
|
|
||||||
} else {
|
|
||||||
args.color = tag_colors[tag_index]
|
|
||||||
tag_index += 1
|
|
||||||
if (tag_index >= tag_colors.length) {
|
|
||||||
tag_index = 0
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
var el = ''
|
|
||||||
el += '<a class="tag-plugin tag"'
|
|
||||||
el += ' ' + ctx.args.joinTags(args, ['color', 'href']).join(' ')
|
|
||||||
el += '>'
|
|
||||||
el += args.text
|
|
||||||
el += '</a>'
|
|
||||||
return el
|
|
||||||
}
|
|
|
@ -171,6 +171,8 @@ table:not([class])
|
||||||
content: "Go"
|
content: "Go"
|
||||||
&.typescript .code:before,&.ts .code:before
|
&.typescript .code:before,&.ts .code:before
|
||||||
content: "TS"
|
content: "TS"
|
||||||
|
&.matlab .code:before
|
||||||
|
content: "MATLAB"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -44,8 +44,8 @@ $fs-14 = .875rem
|
||||||
$fs-13 = .8125rem
|
$fs-13 = .8125rem
|
||||||
$fs-12 = .75rem
|
$fs-12 = .75rem
|
||||||
|
|
||||||
$fs-h1 = 1.75rem // 32px
|
$fs-h1 = 2rem // 32px
|
||||||
$fs-h2 = 1.5rem // 24px
|
$fs-h2 = 1.75rem // 28px
|
||||||
$fs-h3 = 1.375rem // 22px
|
$fs-h3 = 1.375rem // 22px
|
||||||
$fs-h4 = 1.125rem // 18px
|
$fs-h4 = 1.125rem // 18px
|
||||||
$fs-h5 = $fs-15
|
$fs-h5 = $fs-15
|
||||||
|
|
|
@ -47,6 +47,11 @@ h1.article-title
|
||||||
&:hover
|
&:hover
|
||||||
a.headerlink:before
|
a.headerlink:before
|
||||||
opacity: 1
|
opacity: 1
|
||||||
|
blockquote, .tag-plugin
|
||||||
|
h2,h3,h4,h5,h6
|
||||||
|
margin-top: 0.25em
|
||||||
|
margin-bottom: 0.25em
|
||||||
|
padding-top: 0
|
||||||
|
|
||||||
.md-text.content:first-child
|
.md-text.content:first-child
|
||||||
padding-top: 0
|
padding-top: 0
|
||||||
|
@ -82,7 +87,7 @@ h1.article-title
|
||||||
opacity: 0
|
opacity: 0
|
||||||
content: '#'
|
content: '#'
|
||||||
position: absolute
|
position: absolute
|
||||||
margin-left: -0.75em
|
margin-left: -0.6em
|
||||||
h2
|
h2
|
||||||
margin-top: 2rem
|
margin-top: 2rem
|
||||||
border-bottom: 1px solid var(--block-border)
|
border-bottom: 1px solid var(--block-border)
|
||||||
|
|
|
@ -3,6 +3,8 @@
|
||||||
padding: 0.25rem 1rem 0
|
padding: 0.25rem 1rem 0
|
||||||
color: var(--text-p3)
|
color: var(--text-p3)
|
||||||
font-weight: 500
|
font-weight: 500
|
||||||
|
display: flex
|
||||||
|
justify-content: space-between
|
||||||
div#breadcrumb
|
div#breadcrumb
|
||||||
display: flex
|
display: flex
|
||||||
align-items: center
|
align-items: center
|
||||||
|
@ -17,3 +19,26 @@
|
||||||
color: $color-hover
|
color: $color-hover
|
||||||
div#post-meta
|
div#post-meta
|
||||||
margin-top: 2px
|
margin-top: 2px
|
||||||
|
|
||||||
|
.bread-nav .ghrepo
|
||||||
|
font-size: $fs-13
|
||||||
|
display: flex
|
||||||
|
flex-direction: column
|
||||||
|
align-items: flex-start
|
||||||
|
border-left: 1px solid var(--text-meta)
|
||||||
|
padding-left: 8px
|
||||||
|
a
|
||||||
|
display: flex
|
||||||
|
align-items: center
|
||||||
|
color: var(--text-p2)
|
||||||
|
svg
|
||||||
|
margin-right: 4px
|
||||||
|
&.bold
|
||||||
|
font-weight: 600
|
||||||
|
color: var(--text-p1)
|
||||||
|
span
|
||||||
|
margin-left: 4px
|
||||||
|
&:hover
|
||||||
|
color: var(--theme-link)
|
||||||
|
a+a
|
||||||
|
margin-top: 8px
|
||||||
|
|
|
@ -14,7 +14,7 @@ set_text_black()
|
||||||
set_dynamic_color($theme)
|
set_dynamic_color($theme)
|
||||||
--theme: $theme
|
--theme: $theme
|
||||||
--theme-bg1: hsl(hue($theme), 90, 90)
|
--theme-bg1: hsl(hue($theme), 90, 90)
|
||||||
--theme-bg2: hsl(hue($theme), 80, 95)
|
--theme-bg2: hsl(hue($theme), 90, 92)
|
||||||
--theme-border: hsl(hue($theme), 50, 80)
|
--theme-border: hsl(hue($theme), 50, 80)
|
||||||
--text-p0: hsl(hue($theme), 55, 16)
|
--text-p0: hsl(hue($theme), 55, 16)
|
||||||
--text-p1: hsl(hue($theme), 55, 20)
|
--text-p1: hsl(hue($theme), 55, 20)
|
||||||
|
@ -25,8 +25,6 @@ set_dynamic_color($theme)
|
||||||
--theme-border: var(--block-border)
|
--theme-border: var(--block-border)
|
||||||
--theme-bg1: hsl(hue($color-theme), 90, 90)
|
--theme-bg1: hsl(hue($color-theme), 90, 90)
|
||||||
--theme-bg2: var(--block)
|
--theme-bg2: var(--block)
|
||||||
&.tag
|
|
||||||
--text-p2: hsl(hue($color-theme), 90, 24)
|
|
||||||
|
|
||||||
.tag-plugin[color='red']
|
.tag-plugin[color='red']
|
||||||
set_dynamic_color($c-red)
|
set_dynamic_color($c-red)
|
||||||
|
|
|
@ -0,0 +1,17 @@
|
||||||
|
.md-text .tag-plugin.hashtag
|
||||||
|
padding: 0px 8px
|
||||||
|
border-radius: 100px
|
||||||
|
background: var(--theme-bg1)
|
||||||
|
color: var(--text-p2)
|
||||||
|
margin: 2px 0
|
||||||
|
display: inline-flex
|
||||||
|
align-items: center
|
||||||
|
font-size: $fs-13
|
||||||
|
font-weight: 500
|
||||||
|
trans2 background color
|
||||||
|
span
|
||||||
|
margin: 0 2px
|
||||||
|
&:hover
|
||||||
|
background: var(--text-p2)
|
||||||
|
color: var(--theme-bg1)
|
||||||
|
|
|
@ -1,8 +1,5 @@
|
||||||
.md-text .tag-plugin.mark
|
.md-text .tag-plugin.mark
|
||||||
padding: 0 1px
|
padding: 2px
|
||||||
border-radius: 2px
|
border-radius: 2px
|
||||||
background: var(--theme-bg2)
|
background: var(--theme-bg2)
|
||||||
border: 1px solid var(--theme-border)
|
|
||||||
color: var(--text-p0)
|
color: var(--text-p0)
|
||||||
&[color=dark]
|
|
||||||
border-color: var(--theme-bg2)
|
|
||||||
|
|
|
@ -1,13 +0,0 @@
|
||||||
.md-text .tag-plugin.tag
|
|
||||||
padding: 0px 4px
|
|
||||||
border-radius: 2px
|
|
||||||
background: var(--theme-bg1)
|
|
||||||
color: var(--text-p2)
|
|
||||||
margin: 2px 0
|
|
||||||
display: inline-block
|
|
||||||
font-size: $fs-14
|
|
||||||
trans2 background color
|
|
||||||
&:hover
|
|
||||||
background: var(--text-p2)
|
|
||||||
color: var(--theme-bg1)
|
|
||||||
|
|
|
@ -126,7 +126,7 @@ const init = {
|
||||||
highlightItem.addClass("active")
|
highlightItem.addClass("active")
|
||||||
const e0 = document.querySelector('.widgets')
|
const e0 = document.querySelector('.widgets')
|
||||||
const e1 = document.querySelector('#data-toc a.toc-link[href="' + encodeURI(link) + '"]')
|
const e1 = document.querySelector('#data-toc a.toc-link[href="' + encodeURI(link) + '"]')
|
||||||
const offsetBottom = e1.getBoundingClientRect().bottom - e0.getBoundingClientRect().bottom + 100
|
const offsetBottom = e1.getBoundingClientRect().bottom - e0.getBoundingClientRect().bottom + 200
|
||||||
const offsetTop = e1.getBoundingClientRect().top - e0.getBoundingClientRect().top - 64
|
const offsetTop = e1.getBoundingClientRect().top - e0.getBoundingClientRect().top - 64
|
||||||
if (offsetTop < 0) {
|
if (offsetTop < 0) {
|
||||||
e0.scrollBy(0, offsetTop)
|
e0.scrollBy(0, offsetTop)
|
||||||
|
|
|
@ -26,12 +26,10 @@ codeElementArr.forEach(code => {
|
||||||
})
|
})
|
||||||
|
|
||||||
async function copyCode(currentCode) {
|
async function copyCode(currentCode) {
|
||||||
// console.log(currentCode)
|
|
||||||
// console.log('复制代码')
|
|
||||||
if (navigator.clipboard) {
|
if (navigator.clipboard) {
|
||||||
try {
|
try {
|
||||||
await navigator.clipboard.writeText(currentCode)
|
await navigator.clipboard.writeText(currentCode)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
// 未获得用户许可
|
// 未获得用户许可
|
||||||
codeCopyBtn.innerText = '未获得用户许可'
|
codeCopyBtn.innerText = '未获得用户许可'
|
||||||
codeCopyBtn.classList.add('warning')
|
codeCopyBtn.classList.add('warning')
|
||||||
|
|
|
@ -42,7 +42,7 @@ function setCardLink(nodes) {
|
||||||
}).then(function(data) {
|
}).then(function(data) {
|
||||||
renderer(el, data);
|
renderer(el, data);
|
||||||
}).catch(function(error) {
|
}).catch(function(error) {
|
||||||
console.log(error);
|
console.error(error);
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue