[feat] topic
This commit is contained in:
parent
3c01b510b8
commit
3c115b66a7
34
_config.yml
34
_config.yml
|
@ -16,6 +16,11 @@ open_graph:
|
||||||
enable: true
|
enable: true
|
||||||
twitter_id: # for open_graph meta
|
twitter_id: # for open_graph meta
|
||||||
|
|
||||||
|
# 只影响生成的页面路径,不影响配置文件命名规则
|
||||||
|
base_dir:
|
||||||
|
wiki: wiki
|
||||||
|
topic: topic
|
||||||
|
author: author
|
||||||
|
|
||||||
######## Sidebar ########
|
######## Sidebar ########
|
||||||
sidebar:
|
sidebar:
|
||||||
|
@ -36,13 +41,17 @@ sidebar:
|
||||||
blog_index: search_blog, recent, timeline # for categories/tags/archives
|
blog_index: search_blog, recent, timeline # for categories/tags/archives
|
||||||
# 文档索引页
|
# 文档索引页
|
||||||
wiki_index: search_docs, recent, timeline # for wiki
|
wiki_index: search_docs, recent, timeline # for wiki
|
||||||
|
# 专栏索引页
|
||||||
|
index_topic: search_blog, recent, timeline # for topic
|
||||||
# 其它(404)
|
# 其它(404)
|
||||||
others: search, recent, timeline # for 404 and ...
|
others: search, recent, timeline # for 404 and ...
|
||||||
#### 手动创建的页面 ####
|
#### 手动创建的页面 ####
|
||||||
# 文章内页
|
# 文章内页
|
||||||
post: search_blog, toc, related, ghrepo, ghissues # for pages using 'layout:post'
|
post: search_blog, toc, related, ghrepo, ghissues # for pages using 'layout:post'
|
||||||
|
# 专栏内页
|
||||||
|
topic: search_blog, toc, related # for pages using 'layout:wiki'
|
||||||
# 文档内页
|
# 文档内页
|
||||||
wiki: search, toc, ghissues, related # for pages using 'layout:wiki'
|
wiki: search_blog, 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'
|
||||||
|
|
||||||
|
@ -189,16 +198,16 @@ comments:
|
||||||
footer:
|
footer:
|
||||||
social:
|
social:
|
||||||
# github:
|
# github:
|
||||||
# icon: '<img src="https://gcore.jsdelivr.net/gh/cdn-x/placeholder@1.0.9/social/08a41b181ce68.svg"/>'
|
# icon: '<img src="https://gcore.jsdelivr.net/gh/cdn-x/placeholder@1.0.12/social/08a41b181ce68.svg"/>'
|
||||||
# url: /
|
# url: /
|
||||||
# music:
|
# music:
|
||||||
# icon: '<img src="https://gcore.jsdelivr.net/gh/cdn-x/placeholder@1.0.9/social/3845874.svg"/>'
|
# icon: '<img src="https://gcore.jsdelivr.net/gh/cdn-x/placeholder@1.0.12/social/3845874.svg"/>'
|
||||||
# url: /
|
# url: /
|
||||||
# unsplash:
|
# unsplash:
|
||||||
# icon: '<img src="https://gcore.jsdelivr.net/gh/cdn-x/placeholder@1.0.9/social/3616429.svg"/>'
|
# icon: '<img src="https://gcore.jsdelivr.net/gh/cdn-x/placeholder@1.0.12/social/3616429.svg"/>'
|
||||||
# url: /
|
# url: /
|
||||||
# comments:
|
# comments:
|
||||||
# icon: '<img src="https://gcore.jsdelivr.net/gh/cdn-x/placeholder@1.0.9/social/942ebbf1a4b91.svg"/>'
|
# icon: '<img src="https://gcore.jsdelivr.net/gh/cdn-x/placeholder@1.0.12/social/942ebbf1a4b91.svg"/>'
|
||||||
# url: /about/#comments
|
# url: /about/#comments
|
||||||
sitemap:
|
sitemap:
|
||||||
# '博客':
|
# '博客':
|
||||||
|
@ -443,7 +452,7 @@ style:
|
||||||
underline: true # true / false
|
underline: true # true / false
|
||||||
animated_avatar:
|
animated_avatar:
|
||||||
animate: auto # auto, always
|
animate: auto # auto, always
|
||||||
background: https://gcore.jsdelivr.net/gh/cdn-x/placeholder@1.0.9/avatar/round/rainbow64@3x.webp
|
background: https://gcore.jsdelivr.net/gh/cdn-x/placeholder@1.0.12/avatar/round/rainbow64@3x.webp
|
||||||
codeblock:
|
codeblock:
|
||||||
scrollbar: 4px
|
scrollbar: 4px
|
||||||
highlightjs_theme: https://gcore.jsdelivr.net/gh/highlightjs/cdn-release@11.7.0/build/styles/atom-one-dark.min.css
|
highlightjs_theme: https://gcore.jsdelivr.net/gh/highlightjs/cdn-release@11.7.0/build/styles/atom-one-dark.min.css
|
||||||
|
@ -455,12 +464,13 @@ style:
|
||||||
search: 'linear-gradient(to right, #04F3FF, #08FFC6, #DDF730, #FFBD19, #FF1FE0, #C418FF, #04F3FF)'
|
search: 'linear-gradient(to right, #04F3FF, #08FFC6, #DDF730, #FFBD19, #FF1FE0, #C418FF, #04F3FF)'
|
||||||
|
|
||||||
default:
|
default:
|
||||||
avatar: https://gcore.jsdelivr.net/gh/cdn-x/placeholder@1.0.9/avatar/round/3442075.svg
|
avatar: https://gcore.jsdelivr.net/gh/cdn-x/placeholder@1.0.12/avatar/round/3442075.svg
|
||||||
link: https://gcore.jsdelivr.net/gh/cdn-x/placeholder@1.0.9/link/8f277b4ee0ecd.svg
|
link: https://gcore.jsdelivr.net/gh/cdn-x/placeholder@1.0.12/link/8f277b4ee0ecd.svg
|
||||||
cover: https://gcore.jsdelivr.net/gh/cdn-x/placeholder@1.0.9/cover/76b86c0226ffd.svg
|
cover: https://gcore.jsdelivr.net/gh/cdn-x/placeholder@1.0.12/cover/76b86c0226ffd.svg
|
||||||
image: https://gcore.jsdelivr.net/gh/cdn-x/placeholder@1.0.9/image/2659360.svg
|
image: https://gcore.jsdelivr.net/gh/cdn-x/placeholder@1.0.12/image/2659360.svg
|
||||||
project: https://gcore.jsdelivr.net/gh/cdn-x/placeholder@1.0.9/image/2779789.png
|
project: https://gcore.jsdelivr.net/gh/cdn-x/placeholder@1.0.12/image/2779789.png
|
||||||
banner: https://gcore.jsdelivr.net/gh/cdn-x/placeholder@1.0.9/banner/books.jpg
|
banner: https://gcore.jsdelivr.net/gh/cdn-x/placeholder@1.0.12/banner/books.jpg
|
||||||
|
topic: https://gcore.jsdelivr.net/gh/cdn-x/placeholder@1.0.12/image/10433048.png
|
||||||
|
|
||||||
api_host:
|
api_host:
|
||||||
ghapi: https://api.github.com
|
ghapi: https://api.github.com
|
||||||
|
|
|
@ -2,6 +2,7 @@ btn:
|
||||||
home: Home
|
home: Home
|
||||||
blog: Blog
|
blog: Blog
|
||||||
wiki: Wiki
|
wiki: Wiki
|
||||||
|
topic: Topic
|
||||||
recent_publish: Recent
|
recent_publish: Recent
|
||||||
all_wiki: All Products
|
all_wiki: All Products
|
||||||
category: Category
|
category: Category
|
||||||
|
@ -24,7 +25,6 @@ meta:
|
||||||
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'
|
||||||
posts_in_category: 'Category: %s'
|
|
||||||
created_author: '%s posted on'
|
created_author: '%s posted on'
|
||||||
created: 'Posted on'
|
created: 'Posted on'
|
||||||
updated: 'Updated on'
|
updated: 'Updated on'
|
||||||
|
|
|
@ -2,6 +2,7 @@ btn:
|
||||||
home: 主页
|
home: 主页
|
||||||
blog: 文章
|
blog: 文章
|
||||||
wiki: 项目
|
wiki: 项目
|
||||||
|
topic: 专栏
|
||||||
recent_publish: 近期发布
|
recent_publish: 近期发布
|
||||||
all_wiki: 所有项目
|
all_wiki: 所有项目
|
||||||
category: 分类
|
category: 分类
|
||||||
|
@ -24,7 +25,6 @@ meta:
|
||||||
comment_title: 快来参与讨论吧
|
comment_title: 快来参与讨论吧
|
||||||
back_to_top: 回到顶部
|
back_to_top: 回到顶部
|
||||||
more: '更多「%s」'
|
more: '更多「%s」'
|
||||||
posts_in_category: '专栏:%s'
|
|
||||||
created_author: 本文由 %s 发布于
|
created_author: 本文由 %s 发布于
|
||||||
created: 发布于
|
created: 发布于
|
||||||
updated: 更新于
|
updated: 更新于
|
||||||
|
|
|
@ -2,6 +2,7 @@ btn:
|
||||||
home: 首頁
|
home: 首頁
|
||||||
blog: 網誌
|
blog: 網誌
|
||||||
wiki: Wiki
|
wiki: Wiki
|
||||||
|
topic: 專欄
|
||||||
recent_publish: 近期發布
|
recent_publish: 近期發布
|
||||||
all_wiki: 所有 Wiki
|
all_wiki: 所有 Wiki
|
||||||
category: 分類
|
category: 分類
|
||||||
|
@ -24,7 +25,6 @@ meta:
|
||||||
comment_title: 參與討論
|
comment_title: 參與討論
|
||||||
back_to_top: 回到頁首
|
back_to_top: 回到頁首
|
||||||
more: '更多「%s」'
|
more: '更多「%s」'
|
||||||
posts_in_category: '專欄:%s'
|
|
||||||
created_author: 本文由 %s 發布於
|
created_author: 本文由 %s 發布於
|
||||||
created: 發布於
|
created: 發布於
|
||||||
updated: 更新於
|
updated: 更新於
|
||||||
|
|
|
@ -6,7 +6,7 @@ page.header = 'auto';
|
||||||
page.robots = 'none';
|
page.robots = 'none';
|
||||||
%>
|
%>
|
||||||
<article class='md-text error-page'>
|
<article class='md-text error-page'>
|
||||||
<h1><img id='error' src='https://gcore.jsdelivr.net/gh/cdn-x/placeholder@1.0.9/404/1c830bfcd517d.svg' alt='404'></h1>
|
<h1><img id='error' src='https://gcore.jsdelivr.net/gh/cdn-x/placeholder@1.0.12/404/1c830bfcd517d.svg' alt='404'></h1>
|
||||||
<p class='what'>
|
<p class='what'>
|
||||||
<strong>
|
<strong>
|
||||||
<%- __('page.error.what') %>
|
<%- __('page.error.what') %>
|
||||||
|
|
|
@ -114,13 +114,13 @@ function layoutDiv() {
|
||||||
}
|
}
|
||||||
el += '>';
|
el += '>';
|
||||||
if (item == 'wechat') {
|
if (item == 'wechat') {
|
||||||
el += '<img src="https://gcore.jsdelivr.net/gh/cdn-x/placeholder@1.0.9/social/b32ef3da1162a.svg"/>';
|
el += '<img src="https://gcore.jsdelivr.net/gh/cdn-x/placeholder@1.0.12/social/b32ef3da1162a.svg"/>';
|
||||||
} else if (item == 'weibo') {
|
} else if (item == 'weibo') {
|
||||||
el += '<img src="https://gcore.jsdelivr.net/gh/cdn-x/placeholder@1.0.9/social/80c07e4dbb303.svg"/>';
|
el += '<img src="https://gcore.jsdelivr.net/gh/cdn-x/placeholder@1.0.12/social/80c07e4dbb303.svg"/>';
|
||||||
} else if (item == 'email') {
|
} else if (item == 'email') {
|
||||||
el += '<img src="https://gcore.jsdelivr.net/gh/cdn-x/placeholder@1.0.9/social/a1b00e20f425d.svg"/>';
|
el += '<img src="https://gcore.jsdelivr.net/gh/cdn-x/placeholder@1.0.12/social/a1b00e20f425d.svg"/>';
|
||||||
} else if (item == 'link') {
|
} else if (item == 'link') {
|
||||||
el += '<img src="https://gcore.jsdelivr.net/gh/cdn-x/placeholder@1.0.9/social/8411ed322ced6.svg"/>';
|
el += '<img src="https://gcore.jsdelivr.net/gh/cdn-x/placeholder@1.0.12/social/8411ed322ced6.svg"/>';
|
||||||
}
|
}
|
||||||
el += '</a>';
|
el += '</a>';
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,15 +1,31 @@
|
||||||
<%
|
<%
|
||||||
function layoutDiv() {
|
function layoutDiv() {
|
||||||
var prev,next;
|
var prev,next
|
||||||
var title = __('meta.read_next');
|
var title = __('meta.read_next')
|
||||||
|
title_prev = __('meta.newer')
|
||||||
|
title_next = __('meta.older')
|
||||||
|
if (page.layout === 'post') {
|
||||||
|
prev = page.prev
|
||||||
|
next = page.next
|
||||||
|
} else if (page.layout === 'topic' && page.topic?.length > 0) {
|
||||||
|
const topicObject = theme.topic.tree[page.topic]
|
||||||
|
if (topicObject) {
|
||||||
|
const current_page_date = topicObject.pages.filter(p => p.path == page.path)[0].date
|
||||||
|
for (let p of topicObject.pages) {
|
||||||
|
if (p.date > current_page_date) {
|
||||||
|
if (prev == undefined || p.date < prev.date) {
|
||||||
|
prev = p
|
||||||
|
}
|
||||||
|
} else if (p.date < current_page_date) {
|
||||||
|
if (next == undefined || p.date > next.date) {
|
||||||
|
next = p
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (page.layout === 'wiki' && page.wiki?.length > 0) {
|
||||||
var title_prev = __('meta.prev');
|
var title_prev = __('meta.prev');
|
||||||
var title_next = __('meta.next');
|
var title_next = __('meta.next');
|
||||||
if (page.layout === 'post') {
|
|
||||||
prev = page.prev;
|
|
||||||
next = page.next;
|
|
||||||
title_prev = __('meta.newer');
|
|
||||||
title_next = __('meta.older');
|
|
||||||
} 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) {
|
||||||
let ps = proj.pages?.filter(p => p.path == page.path)
|
let ps = proj.pages?.filter(p => p.path == page.path)
|
||||||
|
|
|
@ -63,7 +63,38 @@ function layoutDiv() {
|
||||||
|
|
||||||
el += '</div>';
|
el += '</div>';
|
||||||
el += '</div>';
|
el += '</div>';
|
||||||
} else if (page.layout === "wiki" && page.wiki && page.wiki.length > 0) {
|
} else if (page.layout === 'topic' && page.topic?.length > 0) {
|
||||||
|
el += '<div class="bread-nav fs12">';
|
||||||
|
el += '<div class="left">';
|
||||||
|
el += '<div id="breadcrumb">';
|
||||||
|
var nodes = [];
|
||||||
|
// home
|
||||||
|
el += '<a class="cap breadcrumb" id="home" href="' + url_for(config.root) + '">' + home_title + '</a>';
|
||||||
|
nodes.push('/');
|
||||||
|
// menu_id
|
||||||
|
el += '<span class="sep"></span>';
|
||||||
|
let url = url_for(theme.base_dir.topic);
|
||||||
|
nodes.push(url);
|
||||||
|
el += '<a class="cap breadcrumb" id="menu" href="' + url + '">' + __("btn.topic") + '</a>';
|
||||||
|
// 专栏名
|
||||||
|
let topicObject = theme.topic.tree[page.topic];
|
||||||
|
if (topicObject != null) {
|
||||||
|
let url_proj = url_for(topicObject.homepage?.path);
|
||||||
|
if (nodes.includes(url_proj) === false) {
|
||||||
|
el += '<span class="sep"></span>';
|
||||||
|
el += '<a class="cap breadcrumb" id="proj" href="' + url_proj + '">' + (topicObject.name || topicObject.title) + '</a>';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
el += '</div>';
|
||||||
|
// 更新日期
|
||||||
|
el += '<div id="post-meta">';
|
||||||
|
el += `
|
||||||
|
<span>${__("meta.updated")} <time datetime="${date_xml(page.updated)}">${date(page.updated, config.date_format)}</time></span>
|
||||||
|
`;
|
||||||
|
el += '</div>';
|
||||||
|
el += '</div>';
|
||||||
|
el += '</div>';
|
||||||
|
} else if (page.layout === "wiki" && page.wiki?.length > 0) {
|
||||||
el += '<div class="bread-nav fs12">';
|
el += '<div class="bread-nav fs12">';
|
||||||
el += '<div class="left">';
|
el += '<div class="left">';
|
||||||
el += '<div id="breadcrumb">';
|
el += '<div id="breadcrumb">';
|
||||||
|
|
|
@ -36,6 +36,13 @@ function layoutDiv() {
|
||||||
el += '<a href="' + url_for(config.archive_dir) + '">' + __("btn.archives") + '</a>';
|
el += '<a href="' + url_for(config.archive_dir) + '">' + __("btn.archives") + '</a>';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (theme.topic?.publish_list?.length > 0) {
|
||||||
|
if (page.layout == 'index_topic') {
|
||||||
|
el += '<a class="active" href="' + url_for(theme.base_dir.topic) + '">' + __("btn.topic") + '</a>';
|
||||||
|
} else {
|
||||||
|
el += '<a href="' + url_for(theme.base_dir.topic) + '">' + __("btn.topic") + '</a>';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (theme['post-index']) {
|
if (theme['post-index']) {
|
||||||
const obj = theme['post-index'];
|
const obj = theme['post-index'];
|
||||||
|
|
|
@ -102,7 +102,7 @@ function div_default() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (post.pin) {
|
if (post.pin) {
|
||||||
el += '<span class="pin"><img src="https://gcore.jsdelivr.net/gh/cdn-x/placeholder@1.0.9/badge/3279dd441df8b.svg"/></span>';
|
el += '<span class="pin"><img src="https://gcore.jsdelivr.net/gh/cdn-x/placeholder@1.0.12/badge/3279dd441df8b.svg"/></span>';
|
||||||
}
|
}
|
||||||
el += '</div>';
|
el += '</div>';
|
||||||
el += '</article>';
|
el += '</article>';
|
||||||
|
|
|
@ -0,0 +1,16 @@
|
||||||
|
<%
|
||||||
|
function layoutDiv() {
|
||||||
|
var el = '';
|
||||||
|
el += '<article class="md-text">';
|
||||||
|
el += `<div class="preview"><img src="${topic.icon ? topic.icon : theme.default.topic}"/></div>`
|
||||||
|
el += '<div class="excerpt">';
|
||||||
|
el += '<h2 class="post-title">' + (topic.title || topic.name) + '</h2>';
|
||||||
|
if (topic.description) {
|
||||||
|
el += '<p>' + topic.description + '</p>';
|
||||||
|
}
|
||||||
|
el += '</div>';
|
||||||
|
el += '</article>';
|
||||||
|
return el;
|
||||||
|
}
|
||||||
|
%>
|
||||||
|
<%- layoutDiv() %>
|
|
@ -1,8 +1,4 @@
|
||||||
<%
|
<%
|
||||||
var proj;
|
|
||||||
if (page.layout === 'wiki' && page.wiki) {
|
|
||||||
proj = theme.wiki.tree[page.wiki];
|
|
||||||
}
|
|
||||||
// 默认组件
|
// 默认组件
|
||||||
if (page.sidebar == undefined) {
|
if (page.sidebar == undefined) {
|
||||||
if (page.layout == 'post' && page.content) {
|
if (page.layout == 'post' && page.content) {
|
||||||
|
@ -14,6 +10,14 @@ if (page.sidebar == undefined) {
|
||||||
} else {
|
} else {
|
||||||
page.sidebar = theme.sidebar.widgets.wiki;
|
page.sidebar = theme.sidebar.widgets.wiki;
|
||||||
}
|
}
|
||||||
|
} else if (page.layout === 'topic') {
|
||||||
|
if (page.topic && theme.topic?.tree[page.topic]?.sidebar) {
|
||||||
|
page.sidebar = theme.topic.tree[page.topic].sidebar;
|
||||||
|
} else {
|
||||||
|
page.sidebar = theme.sidebar.widgets.topic;
|
||||||
|
}
|
||||||
|
} else if (page.layout === 'index_topic') {
|
||||||
|
page.sidebar = theme.sidebar.widgets.index_topic
|
||||||
} else if (is_home()) {
|
} else if (is_home()) {
|
||||||
page.sidebar = theme.sidebar.widgets.home;
|
page.sidebar = theme.sidebar.widgets.home;
|
||||||
} else if (is_category() || is_tag() || is_archive() || ['categories', 'tags', 'archives'].includes(page.layout)) {
|
} else if (is_category() || is_tag() || is_archive() || ['categories', 'tags', 'archives'].includes(page.layout)) {
|
||||||
|
@ -60,6 +64,10 @@ function layoutWidgets() {
|
||||||
el += __('btn.all_wiki');
|
el += __('btn.all_wiki');
|
||||||
el += '</a>';
|
el += '</a>';
|
||||||
// this product
|
// this product
|
||||||
|
var proj;
|
||||||
|
if (page.layout === 'wiki' && page.wiki) {
|
||||||
|
proj = theme.wiki.tree[page.wiki];
|
||||||
|
}
|
||||||
if (proj == undefined) {
|
if (proj == undefined) {
|
||||||
// 如果没有项目名,则使用menu中显示的名字
|
// 如果没有项目名,则使用menu中显示的名字
|
||||||
if (page.menu_id && theme.sidebar.menu[page.menu_id] && md_link(theme.sidebar.menu[page.menu_id])) {
|
if (page.menu_id && theme.sidebar.menu[page.menu_id] && md_link(theme.sidebar.menu[page.menu_id])) {
|
||||||
|
|
|
@ -8,7 +8,7 @@ function relatedPosts() {
|
||||||
var el = ''
|
var el = ''
|
||||||
el += `<widget class="widget-wrapper recent">`
|
el += `<widget class="widget-wrapper recent">`
|
||||||
el += `<div class="widget-header cap theme dis-select">`
|
el += `<div class="widget-header cap theme dis-select">`
|
||||||
el += `<span class="name">${__('meta.posts_in_category', relatedItem.name)}</span>`
|
el += `<span class="name">${__('btn.topic') + __('symbol.colon') + relatedItem.name}</span>`
|
||||||
el += `</div>`
|
el += `</div>`
|
||||||
el += `<div class="widget-body related-posts">`
|
el += `<div class="widget-body related-posts">`
|
||||||
relatedItem.posts.sort('date', -1).each(function(post) {
|
relatedItem.posts.sort('date', -1).each(function(post) {
|
||||||
|
@ -20,6 +20,29 @@ function relatedPosts() {
|
||||||
el += `</widget>`
|
el += `</widget>`
|
||||||
return el
|
return el
|
||||||
}
|
}
|
||||||
|
function relatedPostsInTopic() {
|
||||||
|
if (page.topic?.length == 0) {
|
||||||
|
return ''
|
||||||
|
}
|
||||||
|
const topic = theme.topic.tree[page.topic]
|
||||||
|
if (topic == null) {
|
||||||
|
return ''
|
||||||
|
}
|
||||||
|
var el = ''
|
||||||
|
el += `<widget class="widget-wrapper recent">`
|
||||||
|
el += `<div class="widget-header cap theme dis-select">`
|
||||||
|
el += `<span class="name">${__('btn.topic') + __('symbol.colon') + topic.name}</span>`
|
||||||
|
el += `</div>`
|
||||||
|
el += `<div class="widget-body related-posts">`
|
||||||
|
for (let post of topic.pages) {
|
||||||
|
el += `<a class="item${post.path == page.path ? ' active' : ''}" href="${url_for(post.path)}">`
|
||||||
|
el += `<span class="title">${post.title}</span>`
|
||||||
|
el += `</a>`
|
||||||
|
}
|
||||||
|
el += `</div>`
|
||||||
|
el += `</widget>`
|
||||||
|
return el
|
||||||
|
}
|
||||||
function relatedWiki() {
|
function relatedWiki() {
|
||||||
let thisItemObject = theme.wiki.tree[page.wiki]
|
let thisItemObject = theme.wiki.tree[page.wiki]
|
||||||
if (thisItemObject == null) {
|
if (thisItemObject == null) {
|
||||||
|
@ -53,6 +76,8 @@ function layoutDiv() {
|
||||||
return relatedWiki()
|
return relatedWiki()
|
||||||
} else if (page.layout == 'post') {
|
} else if (page.layout == 'post') {
|
||||||
return relatedPosts()
|
return relatedPosts()
|
||||||
|
} else if (page.layout == 'topic') {
|
||||||
|
return relatedPostsInTopic()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
%>
|
%>
|
||||||
|
|
|
@ -0,0 +1,36 @@
|
||||||
|
<%
|
||||||
|
if (page.menu_id == undefined) {
|
||||||
|
if (page.layout === 'wiki_topic' && page.topic) {
|
||||||
|
page.menu_id = 'blog'
|
||||||
|
} else {
|
||||||
|
page.menu_id = 'post'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function layout_topic_list(partial) {
|
||||||
|
var el = ''
|
||||||
|
const { publish_list, tree } = theme.topic
|
||||||
|
for (let id of publish_list) {
|
||||||
|
const topic = tree[id]
|
||||||
|
if (topic == null) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
el += `<div class="post-list wiki topic">`
|
||||||
|
el += `<a class="post-card wiki topic ${scrollreveal()}" href="${url_for(topic.homepage?.path || '/')}">`
|
||||||
|
el += partial(topic)
|
||||||
|
el += `</a>`
|
||||||
|
el += `</div>`
|
||||||
|
}
|
||||||
|
return el
|
||||||
|
}
|
||||||
|
function layoutDiv() {
|
||||||
|
var el = ''
|
||||||
|
el += partial('_partial/main/navbar/list_post')
|
||||||
|
el += layout_topic_list(function(topic) {
|
||||||
|
return partial('_partial/main/post_list/topic_card', {topic: topic})
|
||||||
|
})
|
||||||
|
return el
|
||||||
|
}
|
||||||
|
%>
|
||||||
|
|
||||||
|
<%- layoutDiv() %>
|
|
@ -0,0 +1,39 @@
|
||||||
|
<%
|
||||||
|
if (page.menu_id == undefined) {
|
||||||
|
page.menu_id = 'post'
|
||||||
|
}
|
||||||
|
if (page.layout == undefined) {
|
||||||
|
page.layout = 'index_topic'
|
||||||
|
}
|
||||||
|
if (page.title == undefined) {
|
||||||
|
page.title = __('btn.wiki')
|
||||||
|
}
|
||||||
|
function layoutTitle() {
|
||||||
|
const title = page.h1 != null ? page.h1 : page.title;
|
||||||
|
if (title && title.length > 0) {
|
||||||
|
return '<h1 class="article-title"><span>' + title + '</span></h1>';
|
||||||
|
} else {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
%>
|
||||||
|
<% if (page.layout === 'index_topic') { %>
|
||||||
|
<%- partial('index') %>
|
||||||
|
<% } else { %>
|
||||||
|
<%
|
||||||
|
if (page.header == undefined) {
|
||||||
|
page.header = 'auto';
|
||||||
|
}
|
||||||
|
%>
|
||||||
|
<%- partial('_partial/main/navbar/breadcrumb') %>
|
||||||
|
<article class='md-text content <%- page.layout %><%- page.indent ? ' indent' : '' %><%- scrollreveal() %>'>
|
||||||
|
<%- layoutTitle() %>
|
||||||
|
<%- markdown(page.content) %>
|
||||||
|
<% if (theme.plugins.tianli_gpt.enable && ['all', 'topic'].includes(theme.plugins.tianli_gpt.field)) { %>
|
||||||
|
<%- partial('_partial/plugins/ai/tianli_gpt') %>
|
||||||
|
<% } %>
|
||||||
|
<%- partial('_partial/main/article/article_footer') %>
|
||||||
|
</article>
|
||||||
|
<%- partial('_partial/main/article/read_next') %>
|
||||||
|
<%- partial('_partial/plugins/comments/layout') %>
|
||||||
|
<% } %>
|
|
@ -8,9 +8,14 @@ hexo.on('generateBefore', () => {
|
||||||
require('./lib/links')(hexo);
|
require('./lib/links')(hexo);
|
||||||
require('./lib/authors')(hexo);
|
require('./lib/authors')(hexo);
|
||||||
require('./lib/doc_tree')(hexo);
|
require('./lib/doc_tree')(hexo);
|
||||||
|
require('./lib/topic_tree')(hexo);
|
||||||
require('./lib/utils')(hexo);
|
require('./lib/utils')(hexo);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
hexo.on('generateAfter', () => {
|
||||||
|
require('./lib/merge_posts')(hexo);
|
||||||
|
});
|
||||||
|
|
||||||
hexo.on('ready', () => {
|
hexo.on('ready', () => {
|
||||||
const { version, homepage, repository } = require('../../package.json');
|
const { version, homepage, repository } = require('../../package.json');
|
||||||
hexo.log.info(`Welcome to Stellar ${version}
|
hexo.log.info(`Welcome to Stellar ${version}
|
||||||
|
|
|
@ -0,0 +1,47 @@
|
||||||
|
/**
|
||||||
|
* merge_posts.js v1 | https://github.com/xaoxuu/hexo-theme-stellar/
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
class RelatedPage {
|
||||||
|
constructor(page) {
|
||||||
|
this.id = page._id
|
||||||
|
this.wiki = page.wiki
|
||||||
|
this.topic = page.topic
|
||||||
|
this.title = page.title
|
||||||
|
this.seo_title = page.seo_title
|
||||||
|
this.path = page.path
|
||||||
|
this.path_key = page.path.replace('.html', '')
|
||||||
|
this.layout = page.layout
|
||||||
|
this.date = page.date
|
||||||
|
this.updated = page.updated
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = ctx => {
|
||||||
|
var topic = ctx.theme.config.topic
|
||||||
|
const posts = ctx.locals.get('posts')
|
||||||
|
posts.sort('date').each(function(post) {
|
||||||
|
let obj = new RelatedPage(post)
|
||||||
|
// 合并拥有共同 topic 的文章到 topic.tree
|
||||||
|
if (post.topic?.length > 0) {
|
||||||
|
var topicObject = topic.tree[post.topic]
|
||||||
|
if (topicObject) {
|
||||||
|
obj.page_number = topicObject.pages.length + 1
|
||||||
|
topicObject.pages.push(obj)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
// topic homepage
|
||||||
|
for (let tid of Object.keys(topic.tree)) {
|
||||||
|
let topicObject = topic.tree[tid]
|
||||||
|
if (topicObject.order_by == '-date') {
|
||||||
|
topicObject.pages = topicObject.pages.reverse()
|
||||||
|
}
|
||||||
|
topicObject.homepage = topicObject.pages[0]
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,45 @@
|
||||||
|
/**
|
||||||
|
* topic.js v1 | https://github.com/xaoxuu/hexo-theme-stellar/
|
||||||
|
* 用于专栏/专题文章,一个专栏类似于 wiki 模块中的一个项目文档
|
||||||
|
* 区别是:
|
||||||
|
* 1. 按发布日期排序,无需手动排序
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
function getTopicTree(ctx) {
|
||||||
|
var tree = {}
|
||||||
|
const data = ctx.locals.get('data')
|
||||||
|
var list = []
|
||||||
|
for (let key of Object.keys(data)) {
|
||||||
|
if (key.startsWith('topic/') && key.length > 5) {
|
||||||
|
let newKey = key.replace('topic/', '')
|
||||||
|
let obj = data[key]
|
||||||
|
obj.id = newKey
|
||||||
|
if (obj.order_by == null) {
|
||||||
|
obj.order_by = '-date'
|
||||||
|
}
|
||||||
|
if (obj.path == null) {
|
||||||
|
obj.path = `/topic/${newKey}/`
|
||||||
|
}
|
||||||
|
obj.pages = []
|
||||||
|
list.push(obj)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (let item of list) {
|
||||||
|
tree[item.id] = item
|
||||||
|
}
|
||||||
|
return tree
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = ctx => {
|
||||||
|
var topic = ctx.locals.get('data').topic || {}
|
||||||
|
// 专栏结构树
|
||||||
|
topic.tree = getTopicTree(ctx)
|
||||||
|
// 索引页显示的专栏列表
|
||||||
|
if (topic.publish_list == null) {
|
||||||
|
topic.publish_list = Object.keys(topic.tree)
|
||||||
|
}
|
||||||
|
ctx.theme.config.topic = topic
|
||||||
|
}
|
|
@ -0,0 +1,20 @@
|
||||||
|
/**
|
||||||
|
* topic v1 | https://github.com/xaoxuu/hexo-theme-stellar/
|
||||||
|
*/
|
||||||
|
|
||||||
|
hexo.extend.generator.register('topic', function (locals) {
|
||||||
|
const { topic } = hexo.theme.config
|
||||||
|
const topicIdList = Object.keys(topic.tree)
|
||||||
|
if (topicIdList.length == 0) {
|
||||||
|
return {}
|
||||||
|
}
|
||||||
|
var ret = []
|
||||||
|
ret.push({
|
||||||
|
path: (hexo.theme.config.base_dir.topic) + '/index.html',
|
||||||
|
data: {
|
||||||
|
layout: 'index_topic'
|
||||||
|
},
|
||||||
|
layout: ['index_topic']
|
||||||
|
})
|
||||||
|
return ret
|
||||||
|
})
|
|
@ -28,10 +28,10 @@
|
||||||
background-clip: content-box
|
background-clip: content-box
|
||||||
&.next
|
&.next
|
||||||
border-left: 1px dashed var(--block-border)
|
border-left: 1px dashed var(--block-border)
|
||||||
background-image: url('https://gcore.jsdelivr.net/gh/cdn-x/placeholder@1.0.9/arrow/064b95430caf4.svg')
|
background-image: url('https://gcore.jsdelivr.net/gh/cdn-x/placeholder@1.0.12/arrow/064b95430caf4.svg')
|
||||||
&.prev
|
&.prev
|
||||||
border-right: 1px dashed var(--block-border)
|
border-right: 1px dashed var(--block-border)
|
||||||
background-image: url('https://gcore.jsdelivr.net/gh/cdn-x/placeholder@1.0.9/arrow/f049bbd4e88ec.svg')
|
background-image: url('https://gcore.jsdelivr.net/gh/cdn-x/placeholder@1.0.12/arrow/f049bbd4e88ec.svg')
|
||||||
.current
|
.current
|
||||||
font-family: $ff-code
|
font-family: $ff-code
|
||||||
background: var(--block)
|
background: var(--block)
|
||||||
|
|
|
@ -27,7 +27,7 @@
|
||||||
margin-top: 19px
|
margin-top: 19px
|
||||||
margin-bottom: 20px
|
margin-bottom: 20px
|
||||||
.frame
|
.frame
|
||||||
background-image: url(https://gcore.jsdelivr.net/gh/cdn-x/placeholder@1.0.9/frame/iphone11.svg);
|
background-image: url(https://gcore.jsdelivr.net/gh/cdn-x/placeholder@1.0.12/frame/iphone11.svg);
|
||||||
width: 329px
|
width: 329px
|
||||||
height: 658px
|
height: 658px
|
||||||
&[focus='top']
|
&[focus='top']
|
||||||
|
|
|
@ -86,7 +86,7 @@ $(function () {
|
||||||
var cfg = new Object();
|
var cfg = new Object();
|
||||||
cfg.el = el;
|
cfg.el = el;
|
||||||
cfg.api = api;
|
cfg.api = api;
|
||||||
cfg.avatar = 'https://gcore.jsdelivr.net/gh/cdn-x/placeholder@1.0.9/avatar/round/3442075.svg';
|
cfg.avatar = 'https://gcore.jsdelivr.net/gh/cdn-x/placeholder@1.0.12/avatar/round/3442075.svg';
|
||||||
FCircle.layoutDiv(cfg);
|
FCircle.layoutDiv(cfg);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -78,7 +78,7 @@ $(function () {
|
||||||
cfg.el = el;
|
cfg.el = el;
|
||||||
cfg.api = api;
|
cfg.api = api;
|
||||||
cfg.class = el.getAttribute('class');
|
cfg.class = el.getAttribute('class');
|
||||||
cfg.avatar = 'https://gcore.jsdelivr.net/gh/cdn-x/placeholder@1.0.9/avatar/round/3442075.svg';
|
cfg.avatar = 'https://gcore.jsdelivr.net/gh/cdn-x/placeholder@1.0.12/avatar/round/3442075.svg';
|
||||||
friendsjs.layout(cfg);
|
friendsjs.layout(cfg);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -126,7 +126,7 @@ $(function () {
|
||||||
cfg.host = api.replace(/https:\/\/(.*?)\/(.*)/i, '$1');
|
cfg.host = api.replace(/https:\/\/(.*?)\/(.*)/i, '$1');
|
||||||
cfg.avatar = el.getAttribute('avatar');
|
cfg.avatar = el.getAttribute('avatar');
|
||||||
if (!cfg.avatar) {
|
if (!cfg.avatar) {
|
||||||
cfg.avatar = 'https://gcore.jsdelivr.net/gh/cdn-x/placeholder@1.0.9/avatar/round/3442075.svg';
|
cfg.avatar = 'https://gcore.jsdelivr.net/gh/cdn-x/placeholder@1.0.12/avatar/round/3442075.svg';
|
||||||
}
|
}
|
||||||
MemosJS.layoutDiv(cfg);
|
MemosJS.layoutDiv(cfg);
|
||||||
}
|
}
|
||||||
|
|
|
@ -80,8 +80,8 @@ $(function () {
|
||||||
cfg.class = el.getAttribute('class');
|
cfg.class = el.getAttribute('class');
|
||||||
cfg.el = el;
|
cfg.el = el;
|
||||||
cfg.api = api;
|
cfg.api = api;
|
||||||
cfg.avatar = 'https://gcore.jsdelivr.net/gh/cdn-x/placeholder@1.0.9/link/8f277b4ee0ecd.svg';
|
cfg.avatar = 'https://gcore.jsdelivr.net/gh/cdn-x/placeholder@1.0.12/link/8f277b4ee0ecd.svg';
|
||||||
cfg.screenshot = 'https://gcore.jsdelivr.net/gh/cdn-x/placeholder@1.0.9/cover/76b86c0226ffd.svg';
|
cfg.screenshot = 'https://gcore.jsdelivr.net/gh/cdn-x/placeholder@1.0.12/cover/76b86c0226ffd.svg';
|
||||||
sitesjs.layout(cfg);
|
sitesjs.layout(cfg);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -110,7 +110,7 @@ $(function () {
|
||||||
var cfg = new Object();
|
var cfg = new Object();
|
||||||
cfg.el = el;
|
cfg.el = el;
|
||||||
cfg.api = api;
|
cfg.api = api;
|
||||||
cfg.avatar = 'https://gcore.jsdelivr.net/gh/cdn-x/placeholder@1.0.9/avatar/round/3442075.svg';
|
cfg.avatar = 'https://gcore.jsdelivr.net/gh/cdn-x/placeholder@1.0.12/avatar/round/3442075.svg';
|
||||||
weibojs.layoutDiv(cfg);
|
weibojs.layoutDiv(cfg);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue