hexo-theme-stellar 1.26.8 → 1.28.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/_config.yml +139 -95
- package/_data/icons.yml +8 -1
- package/_data/widgets.yml +19 -7
- package/languages/en.yml +5 -2
- package/languages/zh-CN.yml +4 -1
- package/languages/zh-TW.yml +5 -2
- package/layout/404.ejs +1 -1
- package/layout/_partial/{plugins/comments → comments}/artalk/script.ejs +2 -2
- package/layout/_partial/{plugins/comments/utterances → comments/giscus}/layout.ejs +5 -2
- package/layout/_partial/{plugins/comments → comments}/giscus/script.ejs +1 -4
- package/layout/_partial/{plugins/comments → comments}/layout.ejs +14 -9
- package/layout/_partial/{plugins/comments → comments}/twikoo/script.ejs +1 -1
- package/layout/_partial/comments/waline/script.ejs +43 -0
- package/layout/_partial/head.ejs +2 -2
- package/layout/_partial/main/article/article_footer.ejs +1 -1
- package/layout/_partial/main/footer.ejs +1 -1
- package/layout/_partial/main/navbar/article_banner.ejs +81 -17
- package/layout/_partial/main/navbar/ghinfo.ejs +1 -1
- package/layout/_partial/main/post_list/post_card.ejs +1 -1
- package/layout/_partial/menubtn.ejs +6 -3
- package/layout/_partial/scripts/defines.ejs +31 -0
- package/layout/_partial/scripts/services.ejs +29 -0
- package/layout/_partial/scripts/sidebar.ejs +25 -0
- package/layout/_partial/scripts/utils.ejs +158 -0
- package/layout/_partial/scripts.ejs +32 -0
- package/layout/_partial/sidebar/{index.ejs → index_leftbar.ejs} +22 -20
- package/layout/_partial/sidebar/index_rightbar.ejs +84 -0
- package/layout/_partial/sidebar/logo.ejs +1 -1
- package/layout/_partial/widgets/author.ejs +37 -0
- package/layout/_partial/widgets/components/edit.ejs +24 -0
- package/layout/_partial/widgets/ghissues.ejs +1 -1
- package/layout/_partial/widgets/ghrepo.ejs +2 -2
- package/layout/_partial/widgets/ghuser.ejs +2 -2
- package/layout/_partial/widgets/markdown.ejs +1 -1
- package/layout/_partial/widgets/recent.ejs +1 -5
- package/layout/_partial/widgets/related.ejs +1 -1
- package/layout/_partial/widgets/timeline.ejs +1 -1
- package/layout/_partial/widgets/toc.ejs +38 -85
- package/layout/_partial/widgets/tree.ejs +71 -0
- package/layout/_plugins/copycode.ejs +13 -0
- package/layout/_plugins/fancybox.ejs +32 -0
- package/layout/_plugins/heti.ejs +21 -0
- package/layout/_plugins/index.ejs +24 -0
- package/layout/_plugins/lazyload.ejs +21 -0
- package/layout/{_partial/plugins/parser/mathjax/script.ejs → _plugins/mathjax.ejs} +1 -1
- package/layout/_plugins/mermaid.ejs +29 -0
- package/layout/_plugins/preload.ejs +9 -0
- package/layout/_plugins/scrollreveal.ejs +15 -0
- package/layout/_plugins/search/algolia_search.ejs +13 -0
- package/layout/_plugins/search/local_search.ejs +8 -0
- package/layout/_plugins/swiper.ejs +26 -0
- package/layout/_plugins/tianli_gpt.ejs +14 -0
- package/layout/archive.ejs +9 -2
- package/layout/layout.ejs +9 -6
- package/layout/page.ejs +2 -10
- package/package.json +1 -1
- package/scripts/events/lib/doc_tree.js +8 -8
- package/scripts/events/lib/topic_tree.js +3 -0
- package/scripts/generators/author.js +3 -2
- package/scripts/helpers/parse_config.js +6 -5
- package/scripts/tags/lib/albums.js +2 -2
- package/scripts/tags/lib/button.js +1 -1
- package/scripts/tags/lib/emoji.js +1 -1
- package/scripts/tags/lib/friends.js +1 -1
- package/scripts/tags/lib/icon.js +10 -5
- package/scripts/tags/lib/link.js +2 -2
- package/scripts/tags/lib/md.js +1 -1
- package/scripts/tags/lib/posters.js +2 -2
- package/scripts/tags/lib/sites.js +1 -1
- package/scripts/tags/lib/timeline.js +2 -2
- package/source/css/_common/button.styl +8 -2
- package/source/css/_common/device.styl +39 -12
- package/source/css/_custom.styl +15 -16
- package/source/css/_defines/const.styl +1 -1
- package/source/css/_defines/func.styl +14 -4
- package/source/css/_defines/theme.styl +38 -27
- package/source/css/_layout/layout.styl +62 -27
- package/source/css/_layout/list.styl +1 -1
- package/source/css/_layout/main.styl +1 -4
- package/source/css/_layout/md.styl +16 -2
- package/source/css/_layout/pages/archives.styl +4 -0
- package/source/css/_layout/partial/article-banner.styl +14 -15
- package/source/css/_layout/partial/article-footer.styl +0 -5
- package/source/css/_layout/partial/footer.styl +9 -6
- package/source/css/_layout/partial/related.styl +4 -0
- package/source/css/_layout/sidebar/footer.styl +3 -1
- package/source/css/_layout/sidebar/logo.styl +3 -1
- package/source/css/_layout/sidebar/menu.styl +1 -1
- package/source/css/_layout/sidebar/nav-area.styl +1 -1
- package/source/css/_layout/sidebar/sidebar.styl +25 -16
- package/source/css/_layout/tag-plugins/banner.styl +1 -8
- package/source/css/_layout/tag-plugins/common.styl +10 -5
- package/source/css/_layout/tag-plugins/emoji.styl +1 -0
- package/source/css/_layout/tag-plugins/icon.styl +6 -0
- package/source/css/_layout/tag-plugins/image.styl +1 -1
- package/source/css/_layout/tag-plugins/quot.styl +1 -1
- package/source/css/_layout/tag-plugins/timeline.styl +26 -27
- package/source/css/_layout/widgets/ghrepo.styl +1 -1
- package/source/css/_layout/widgets/ghuser.styl +9 -5
- package/source/css/_layout/widgets/list.styl +4 -3
- package/source/css/_layout/widgets/related.styl +0 -1
- package/source/css/_layout/widgets/timeline.styl +27 -21
- package/source/css/_layout/widgets/toc.styl +182 -0
- package/source/css/_layout/widgets/tree.styl +0 -0
- package/source/css/_layout/widgets/widgets.styl +26 -7
- package/source/css/_plugins/comments/twikoo.styl +103 -59
- package/source/css/_plugins/comments/waline.styl +13 -10
- package/source/css/_plugins/index.styl +2 -0
- package/source/css/_plugins/katex.styl +5 -0
- package/source/css/_plugins/mermaid.styl +49 -59
- package/source/css/_plugins/tianli_gpt.styl +208 -151
- package/source/js/main.js +52 -251
- package/source/js/plugins/copycode.js +28 -41
- package/source/js/search/algolia-search.js +75 -0
- package/source/js/search/local-search.js +32 -0
- package/source/js/services/fcircle.js +36 -0
- package/source/js/services/friends.js +27 -0
- package/source/js/services/ghinfo.js +33 -0
- package/source/js/services/mdrender.js +10 -0
- package/source/js/services/memos.js +73 -0
- package/source/js/services/siteinfo.js +38 -0
- package/source/js/services/sites.js +30 -0
- package/source/js/services/timeline.js +106 -0
- package/source/js/services/weibo.js +60 -0
- package/layout/_partial/main/navbar/article_top_area.ejs +0 -35
- package/layout/_partial/main/navbar/author_banner.ejs +0 -29
- package/layout/_partial/plugins/ai/tianli_gpt.ejs +0 -9
- package/layout/_partial/plugins/comments/waline/script.ejs +0 -39
- package/layout/_partial/plugins/parser/head.ejs +0 -3
- package/layout/_partial/plugins/parser/katex/head.ejs +0 -3
- package/layout/_partial/plugins/parser/katex/script.ejs +0 -4
- package/layout/_partial/plugins/parser/mermaid/script.ejs +0 -29
- package/layout/_partial/plugins/parser/script.ejs +0 -9
- package/layout/_partial/scripts/index.ejs +0 -176
- package/source/css/_layout/widgets/toc_blog.styl +0 -3
- package/source/css/_layout/widgets/toc_common.styl +0 -92
- package/source/css/_layout/widgets/toc_wiki.styl +0 -62
- package/source/js/plugins/fcircle.js +0 -92
- package/source/js/plugins/friends.js +0 -84
- package/source/js/plugins/ghinfo.js +0 -85
- package/source/js/plugins/linkcard.js +0 -48
- package/source/js/plugins/marked.js +0 -50
- package/source/js/plugins/memos.js +0 -132
- package/source/js/plugins/sites.js +0 -87
- package/source/js/plugins/timeline.js +0 -162
- package/source/js/plugins/weibo.js +0 -116
- /package/layout/_partial/{plugins/comments → comments}/artalk/layout.ejs +0 -0
- /package/layout/_partial/{plugins/comments → comments}/beaudar/layout.ejs +0 -0
- /package/layout/_partial/{plugins/comments → comments}/beaudar/script.ejs +0 -0
- /package/layout/_partial/{plugins/comments → comments}/script.ejs +0 -0
- /package/layout/_partial/{plugins/comments → comments}/twikoo/layout.ejs +0 -0
- /package/layout/_partial/{plugins/comments/giscus → comments/utterances}/layout.ejs +0 -0
- /package/layout/_partial/{plugins/comments → comments}/utterances/script.ejs +0 -0
- /package/layout/_partial/{plugins/comments → comments}/waline/layout.ejs +0 -0
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
<%
|
|
2
|
+
|
|
3
|
+
const wiki = theme.wiki.tree[page.wiki]
|
|
4
|
+
const topic = theme.topic.tree[page.topic]
|
|
5
|
+
|
|
6
|
+
if (page.rightbar == null) {
|
|
7
|
+
const { site_tree } = theme
|
|
8
|
+
var sidebar
|
|
9
|
+
if (is_home()) {
|
|
10
|
+
sidebar = site_tree.home.rightbar
|
|
11
|
+
} else if (is_category() || is_tag() || is_archive() || ['categories', 'tags', 'archives'].includes(page.layout)) {
|
|
12
|
+
sidebar = site_tree.index_blog.rightbar
|
|
13
|
+
} else if (page.layout === 'index_topic') {
|
|
14
|
+
// 专栏列表页等同于博客列表页
|
|
15
|
+
sidebar = site_tree.index_blog.rightbar
|
|
16
|
+
} else if (page.topic?.length > 0) {
|
|
17
|
+
// 专栏文章内页等同于普通文章内页
|
|
18
|
+
sidebar = site_tree.post.rightbar
|
|
19
|
+
} else if (page.layout === 'index_wiki') {
|
|
20
|
+
sidebar = site_tree.index_wiki.rightbar
|
|
21
|
+
} else if (page.wiki?.length > 0) {
|
|
22
|
+
sidebar = site_tree.wiki.rightbar
|
|
23
|
+
} else if (page.layout === '404') {
|
|
24
|
+
sidebar = site_tree.error_page.rightbar
|
|
25
|
+
} else if (page.layout === 'page') {
|
|
26
|
+
sidebar = site_tree.page.rightbar
|
|
27
|
+
} else if (page.layout === 'post') {
|
|
28
|
+
sidebar = site_tree.post.rightbar
|
|
29
|
+
} else if (page.layout == null) {
|
|
30
|
+
sidebar = site_tree.page.rightbar
|
|
31
|
+
} else {
|
|
32
|
+
sidebar = []
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
if (topic?.rightbar) {
|
|
36
|
+
sidebar = topic.rightbar
|
|
37
|
+
}
|
|
38
|
+
if (wiki?.rightbar) {
|
|
39
|
+
sidebar = wiki.rightbar
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
page.rightbar = sidebar
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
// parse array string
|
|
47
|
+
if (typeof page.rightbar == 'string') {
|
|
48
|
+
page.rightbar = page.rightbar.replace(/ /g, '').split(',');
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function layoutWidgets() {
|
|
52
|
+
if (page.rightbar == null || page.rightbar.length == 0) {
|
|
53
|
+
return ''
|
|
54
|
+
}
|
|
55
|
+
var el = ''
|
|
56
|
+
if (page.rightbar) {
|
|
57
|
+
page.rightbar.forEach((w, i) => {
|
|
58
|
+
let name = ''
|
|
59
|
+
let widget = {}
|
|
60
|
+
if (typeof w == 'string') {
|
|
61
|
+
name = w
|
|
62
|
+
} else if (typeof w == 'object' && w.override) {
|
|
63
|
+
name = w.override
|
|
64
|
+
}
|
|
65
|
+
if (name in theme.widgets) {
|
|
66
|
+
Object.assign(widget, theme.widgets[name])
|
|
67
|
+
}
|
|
68
|
+
if (typeof w == 'object' && (w.override || w.layout)) {
|
|
69
|
+
Object.assign(widget, w)
|
|
70
|
+
}
|
|
71
|
+
if (widget && widget.layout) {
|
|
72
|
+
el += partial('../widgets/' + widget.layout, {item: widget})
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
if (el.trim().length > 0) {
|
|
77
|
+
return `<div class="widgets">${el}</div>`
|
|
78
|
+
} else {
|
|
79
|
+
return ''
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
%>
|
|
84
|
+
<%- layoutWidgets() %>
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
<%
|
|
2
|
+
|
|
3
|
+
var author = null
|
|
4
|
+
if (theme.authors) {
|
|
5
|
+
if (page.author?.length > 0 && theme.authors[page.author] != null) {
|
|
6
|
+
author = theme.authors[page.author]
|
|
7
|
+
} else {
|
|
8
|
+
author = theme.default_author
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
function layoutDiv() {
|
|
13
|
+
if (author == null) {
|
|
14
|
+
return ''
|
|
15
|
+
}
|
|
16
|
+
var el = ''
|
|
17
|
+
el += `<widget class="widget-wrapper${scrollreveal(' ')} user-card author">`
|
|
18
|
+
// body
|
|
19
|
+
el += `<div class="widget-body">`
|
|
20
|
+
if (item.avatar) {
|
|
21
|
+
el += `<div class="avatar"><img type="img" id="avatar_url" src="${author.avatar}"></div>`
|
|
22
|
+
}
|
|
23
|
+
// username
|
|
24
|
+
el += `<p class="username" ff="title" type="text" id="name">${author.name}</p>`
|
|
25
|
+
el += `<p class="bio" type="text" id="bio">${author.desc || author.description}</p>`
|
|
26
|
+
|
|
27
|
+
// homepage
|
|
28
|
+
el += `<a class="follow" href="${url_for(author.path)}">`
|
|
29
|
+
el += icon('solar:documents-bold-duotone')
|
|
30
|
+
el += __('btn.all_posts')
|
|
31
|
+
el += `</a>`
|
|
32
|
+
el += `</div>`
|
|
33
|
+
el += `</widget>`
|
|
34
|
+
return el
|
|
35
|
+
}
|
|
36
|
+
%>
|
|
37
|
+
<%- layoutDiv() %>
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
<%
|
|
2
|
+
function parseURL() {
|
|
3
|
+
const source = page.source || ''
|
|
4
|
+
var url
|
|
5
|
+
for (let id of Object.keys(map)) {
|
|
6
|
+
if (source.startsWith(id) && map[id]) {
|
|
7
|
+
return source.replace(id, map[id])
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
function layoutDiv() {
|
|
12
|
+
const url = parseURL()
|
|
13
|
+
if (url == null) {
|
|
14
|
+
return ''
|
|
15
|
+
}
|
|
16
|
+
var el = ''
|
|
17
|
+
el += `<a class="edit" href="${url_for(url)}">`
|
|
18
|
+
el += icon('default:edit')
|
|
19
|
+
el += `<span>${__('btn.edit')}</span>`
|
|
20
|
+
el += `</a>`
|
|
21
|
+
return el
|
|
22
|
+
}
|
|
23
|
+
%>
|
|
24
|
+
<%- layoutDiv() %>
|
|
@@ -26,7 +26,7 @@ function layoutDiv() {
|
|
|
26
26
|
el += '</div>';
|
|
27
27
|
}
|
|
28
28
|
el += '<div class="widget-body fs14">';
|
|
29
|
-
el += '<div class="tag-plugin timeline
|
|
29
|
+
el += '<div class="tag-plugin timeline ds-timeline"';
|
|
30
30
|
['api', 'user'].forEach(key => {
|
|
31
31
|
if (item[key]) {
|
|
32
32
|
el += ' ' + key + '="' + item[key] + '"';
|
|
@@ -19,7 +19,7 @@ function layoutDiv() {
|
|
|
19
19
|
el += `<widget class="widget-wrapper${scrollreveal(' ')} ghrepo">`
|
|
20
20
|
// body
|
|
21
21
|
el += '<div class="widget-body">';
|
|
22
|
-
el += '<div class="items
|
|
22
|
+
el += '<div class="items ds-ghinfo" api="' + theme.api_host.ghapi + '/repos/' + repo + '">';
|
|
23
23
|
el += '<a class="repo" href="https://github.com/' + repo + '" target="_blank" rel="external nofollow noopener noreferrer">';
|
|
24
24
|
el += '<div class="repo-name flex-row">';
|
|
25
25
|
el += icon('github:repo')
|
|
@@ -35,7 +35,7 @@ function layoutDiv() {
|
|
|
35
35
|
el += icon('github:fork')
|
|
36
36
|
el += '<span type="text" id="forks_count"></span>';
|
|
37
37
|
el += '</div>';
|
|
38
|
-
el += '<div class="flex-row
|
|
38
|
+
el += '<div class="flex-row ds-ghinfo" index="0" api="' + theme.api_host.ghapi + '/repos/' + repo + '/tags">';
|
|
39
39
|
el += icon('github:tag')
|
|
40
40
|
el += '<span type="text" id="latest-tag-name">0</span>';
|
|
41
41
|
el += '</div>';
|
|
@@ -22,9 +22,9 @@ function layoutDiv() {
|
|
|
22
22
|
return el;
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
el += `<widget class="widget-wrapper${scrollreveal(' ')} ghuser">`
|
|
25
|
+
el += `<widget class="widget-wrapper${scrollreveal(' ')} user-card ghuser">`
|
|
26
26
|
// body
|
|
27
|
-
el += '<div class="widget-body
|
|
27
|
+
el += '<div class="widget-body ds-ghinfo" api="' + theme.api_host.ghapi + '/users/' + item.username + '">';
|
|
28
28
|
if (item.avatar) {
|
|
29
29
|
el += '<div class="avatar" ><img no-lazy type="img" id="avatar_url" src="' + config.avatar + '"></div>';
|
|
30
30
|
}
|
|
@@ -13,7 +13,7 @@ function layoutDiv() {
|
|
|
13
13
|
el += markdown(item.content);
|
|
14
14
|
}
|
|
15
15
|
if (item.src) {
|
|
16
|
-
el += `<div class="
|
|
16
|
+
el += `<div class="ds-mdrender" src="${item.src}"></div>`
|
|
17
17
|
}
|
|
18
18
|
if (item.linklist) {
|
|
19
19
|
el += partial('components/linklist', {item: item.linklist})
|
|
@@ -30,8 +30,7 @@ function layoutDiv() {
|
|
|
30
30
|
arr.length = item.limit
|
|
31
31
|
arr.forEach(post => {
|
|
32
32
|
if (!post) { return }
|
|
33
|
-
|
|
34
|
-
el += `<a class="item title${post.path == page.path ? ' active' : ''}" href="${url_for(post.link || post.path)}">`
|
|
33
|
+
el += `<a class="item title" href="${url_for(post.link || post.path)}">`
|
|
35
34
|
el += '<span class="title">'
|
|
36
35
|
if (post.wiki) {
|
|
37
36
|
const proj = theme.wiki.tree[post.wiki];
|
|
@@ -41,9 +40,6 @@ function layoutDiv() {
|
|
|
41
40
|
}
|
|
42
41
|
}
|
|
43
42
|
el += post.title + '</span>';
|
|
44
|
-
if (isActive) {
|
|
45
|
-
el += icon('default:bookmark.active')
|
|
46
|
-
}
|
|
47
43
|
el += '</a>';
|
|
48
44
|
el += '';
|
|
49
45
|
});
|
|
@@ -31,7 +31,7 @@ function relatedWiki() {
|
|
|
31
31
|
if (thisItemObject == null) {
|
|
32
32
|
return ''
|
|
33
33
|
}
|
|
34
|
-
const relatedItems = thisItemObject.relatedItems
|
|
34
|
+
const relatedItems = thisItemObject.relatedItems || []
|
|
35
35
|
var el = ''
|
|
36
36
|
for (let relatedItem of relatedItems) {
|
|
37
37
|
el += `<widget class="widget-wrapper${scrollreveal(' ')} post-card">`
|
|
@@ -11,7 +11,7 @@ function layoutDiv() {
|
|
|
11
11
|
el += '</div>';
|
|
12
12
|
}
|
|
13
13
|
el += '<div class="widget-body fs14">';
|
|
14
|
-
el +=
|
|
14
|
+
el += `<div class="tag-plugin timeline ds-${(item.type || 'timeline')}"`;
|
|
15
15
|
['api', 'user', 'hide', 'limit'].forEach(key => {
|
|
16
16
|
if (item[key]) {
|
|
17
17
|
el += ' ' + key + '="' + item[key] + '"';
|
|
@@ -1,16 +1,13 @@
|
|
|
1
1
|
<%
|
|
2
|
-
|
|
3
|
-
var hasTOC = true
|
|
2
|
+
|
|
4
3
|
function layoutTocBody() {
|
|
5
4
|
if (toc(page.content).length > 0) {
|
|
6
|
-
hasTOC = true
|
|
7
5
|
return toc(page.content, {
|
|
8
6
|
list_number: item.list_number,
|
|
9
7
|
min_depth: item.min_depth,
|
|
10
8
|
max_depth: item.max_depth
|
|
11
|
-
})
|
|
9
|
+
})
|
|
12
10
|
}
|
|
13
|
-
hasTOC = false
|
|
14
11
|
return ''
|
|
15
12
|
}
|
|
16
13
|
|
|
@@ -18,98 +15,54 @@ function layoutTocHeader(title) {
|
|
|
18
15
|
var el = ''
|
|
19
16
|
el += `<div class="widget-header dis-select">`
|
|
20
17
|
el += `<span class="name">${title || __("meta.toc")}</span>`
|
|
18
|
+
el += `<a class="cap-action" onclick="sidebar.toggleTOC()" >${icon('default:rightbar')}</a>`
|
|
21
19
|
el += `</div>`
|
|
22
20
|
return el
|
|
23
21
|
}
|
|
24
22
|
|
|
25
|
-
function
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
continue
|
|
30
|
-
}
|
|
31
|
-
let isActive = ''
|
|
32
|
-
if (p.path === page.path) {
|
|
33
|
-
isActive += ' active'
|
|
34
|
-
}
|
|
35
|
-
el += `<div class="doc-tree${isActive}">`
|
|
36
|
-
if (proj.pages.length > 1) {
|
|
37
|
-
let href = url_for(p.path);
|
|
38
|
-
if (p.is_homepage) {
|
|
39
|
-
href += '#start'
|
|
40
|
-
}
|
|
41
|
-
el += `<a class="doc-tree-link${isActive}" href="${href}">`
|
|
42
|
-
el += `<span class="toc-text">${p.title}</span>`
|
|
43
|
-
if (isActive.length > 0) {
|
|
44
|
-
el += icon('default:bookmark.active')
|
|
45
|
-
}
|
|
46
|
-
el += `</a>`
|
|
47
|
-
}
|
|
48
|
-
if (p.path === page.path) {
|
|
49
|
-
el += layoutTocBody()
|
|
50
|
-
}
|
|
51
|
-
el += `</div>`
|
|
23
|
+
function layoutToc(fallback) {
|
|
24
|
+
const tocBody = layoutTocBody()
|
|
25
|
+
if (tocBody.length == 0) {
|
|
26
|
+
return ''
|
|
52
27
|
}
|
|
28
|
+
var el = ''
|
|
29
|
+
el += `<widget class="widget-wrapper${scrollreveal(' ')} toc" id="data-toc" collapse="${item.collapse}">`
|
|
30
|
+
el += layoutTocHeader()
|
|
31
|
+
el += `<div class="widget-body">`
|
|
32
|
+
el += tocBody
|
|
33
|
+
el += `</div>`
|
|
34
|
+
el += `</widget>`
|
|
53
35
|
return el
|
|
54
36
|
}
|
|
55
37
|
|
|
56
|
-
|
|
57
38
|
function layoutDiv(fallback) {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
let toc_content = toc(page.content)
|
|
63
|
-
if (toc_content && toc_content.length > 0) {
|
|
64
|
-
type = 'single'
|
|
65
|
-
}
|
|
39
|
+
const editBtn = partial('components/edit', {map: item.edit_this_page})
|
|
40
|
+
const tocBody = layoutTocBody()
|
|
41
|
+
if (tocBody.trim().length == 0 && editBtn.trim().length == 0) {
|
|
42
|
+
return ''
|
|
66
43
|
}
|
|
67
|
-
|
|
68
44
|
var el = ''
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
if (sec.pages.length == 0) {
|
|
76
|
-
continue
|
|
77
|
-
}
|
|
78
|
-
if (sec.title?.length > 0) {
|
|
79
|
-
el += layoutTocHeader(sec.title)
|
|
80
|
-
}
|
|
81
|
-
el += `<div class="widget-body fs14">`
|
|
82
|
-
el += layoutDocTree(sec.pages)
|
|
83
|
-
el += `</div>`
|
|
84
|
-
}
|
|
85
|
-
} else { // 单 page
|
|
86
|
-
if (proj.pages.length == 1) {
|
|
87
|
-
el += layoutTocHeader()
|
|
88
|
-
}
|
|
89
|
-
el += `<div class="widget-body fs14">`
|
|
90
|
-
el += layoutDocTree(proj.pages)
|
|
91
|
-
el += `</div>`
|
|
92
|
-
if (hasTOC == false) {
|
|
93
|
-
return ''
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
} else {
|
|
97
|
-
// post 布局
|
|
98
|
-
el += layoutTocHeader()
|
|
99
|
-
el += `<div class="widget-body fs14">`
|
|
100
|
-
el += `<div class="doc-tree active">`
|
|
101
|
-
el += layoutTocBody()
|
|
102
|
-
el += `</div>`
|
|
103
|
-
el += `</div>`
|
|
104
|
-
if (hasTOC == false) {
|
|
105
|
-
return ''
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
el += `</widget>`
|
|
109
|
-
} else if (item.fallback) {
|
|
110
|
-
const fallback = theme.widgets[item.fallback]
|
|
111
|
-
el += partial(fallback.layout, {item: fallback})
|
|
45
|
+
el += `<widget class="widget-wrapper${scrollreveal(' ')} toc" id="data-toc" collapse="${item.collapse}">`
|
|
46
|
+
if (tocBody.length > 0) {
|
|
47
|
+
el += layoutTocHeader()
|
|
48
|
+
el += `<div class="widget-body">`
|
|
49
|
+
el += tocBody
|
|
50
|
+
el += `</div>`
|
|
112
51
|
}
|
|
52
|
+
el += `<div class="widget-footer">`
|
|
53
|
+
el += editBtn
|
|
54
|
+
el += `<a class="top" onclick="util.scrollTop()">`
|
|
55
|
+
el += icon('default:upup')
|
|
56
|
+
el += `<span>${__('btn.top')}</span>`
|
|
57
|
+
el += `</a>`
|
|
58
|
+
if (page.comments) {
|
|
59
|
+
el += `<a class="buttom" onclick="util.scrollComment()">`
|
|
60
|
+
el += icon('default:tocomment')
|
|
61
|
+
el += `<span>${__('btn.comments')}</span>`
|
|
62
|
+
el += `</a>`
|
|
63
|
+
}
|
|
64
|
+
el += `</div>`
|
|
65
|
+
el += `</widget>`
|
|
113
66
|
return el
|
|
114
67
|
}
|
|
115
68
|
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
<%
|
|
2
|
+
const proj = theme.wiki.tree[page.wiki]
|
|
3
|
+
|
|
4
|
+
function layoutTocHeader(title) {
|
|
5
|
+
var el = ''
|
|
6
|
+
el += `<div class="widget-header dis-select">`
|
|
7
|
+
el += `<span class="name">${title || __("meta.toc")}</span>`
|
|
8
|
+
el += `</div>`
|
|
9
|
+
return el
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
function layoutDocTree(pages) {
|
|
13
|
+
var el = ''
|
|
14
|
+
for (let p of pages) {
|
|
15
|
+
if (p.title == null || p.title.length == 0) {
|
|
16
|
+
continue
|
|
17
|
+
}
|
|
18
|
+
let isActive = ''
|
|
19
|
+
if (p.path === page.path) {
|
|
20
|
+
isActive += ' active'
|
|
21
|
+
}
|
|
22
|
+
if (proj.pages.length > 1) {
|
|
23
|
+
let href = url_for(p.path);
|
|
24
|
+
if (p.is_homepage) {
|
|
25
|
+
href += '#start'
|
|
26
|
+
}
|
|
27
|
+
el += `<a class="link${isActive}" href="${href}">`
|
|
28
|
+
el += `<span class="toc-text">${p.title}</span>`
|
|
29
|
+
if (isActive.length > 0) {
|
|
30
|
+
el += icon('default:bookmark.active')
|
|
31
|
+
}
|
|
32
|
+
el += `</a>`
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
return el
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
function layoutDiv(fallback) {
|
|
40
|
+
if (proj == null) {
|
|
41
|
+
return ''
|
|
42
|
+
}
|
|
43
|
+
if (proj.pages == null || proj.pages.length == 0) {
|
|
44
|
+
return ''
|
|
45
|
+
}
|
|
46
|
+
if (proj.sections == null || proj.sections.length == 0) {
|
|
47
|
+
return ''
|
|
48
|
+
}
|
|
49
|
+
var el = ''
|
|
50
|
+
for (let sec of proj.sections) {
|
|
51
|
+
if (sec.pages.length == 0) {
|
|
52
|
+
continue
|
|
53
|
+
}
|
|
54
|
+
if (sec.title?.length > 0) {
|
|
55
|
+
el += layoutTocHeader(sec.title)
|
|
56
|
+
}
|
|
57
|
+
const docTree = layoutDocTree(sec.pages)
|
|
58
|
+
if (docTree.trim().length > 0) {
|
|
59
|
+
el += `<div class="widget-body fs14">${docTree}</div>`
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
if (el.trim().length > 0) {
|
|
63
|
+
return `<widget class="widget-wrapper${scrollreveal(' ')} post-list">${el}</widget>`
|
|
64
|
+
} else {
|
|
65
|
+
return ''
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
%>
|
|
70
|
+
|
|
71
|
+
<%- layoutDiv() %>
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
document.addEventListener('DOMContentLoaded', function () {
|
|
3
|
+
window.codeElements = document.querySelectorAll('.code');
|
|
4
|
+
if (window.codeElements.length > 0) {
|
|
5
|
+
ctx.copycode = {
|
|
6
|
+
default_text: `<%- conf.default_text %>`,
|
|
7
|
+
success_text: `<%- conf.success_text %>`,
|
|
8
|
+
toast: `<%- conf.toast %>`,
|
|
9
|
+
};
|
|
10
|
+
utils.js('/js/plugins/copycode.js');
|
|
11
|
+
}
|
|
12
|
+
});
|
|
13
|
+
</script>
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
ctx.fancybox = {
|
|
3
|
+
selector: `<%- conf.selector %>`,
|
|
4
|
+
css: `<%- conf.css %>`,
|
|
5
|
+
js: `<%- conf.js %>`
|
|
6
|
+
};
|
|
7
|
+
var selector = '[data-fancybox]:not(.error)';
|
|
8
|
+
if (ctx.fancybox.selector) {
|
|
9
|
+
selector += `, ${ctx.fancybox.selector}`
|
|
10
|
+
}
|
|
11
|
+
var needFancybox = document.querySelectorAll(selector).length !== 0;
|
|
12
|
+
if (!needFancybox) {
|
|
13
|
+
const els = document.getElementsByClassName('ds-memos');
|
|
14
|
+
if (els != undefined && els.length > 0) {
|
|
15
|
+
needFancybox = true;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
if (needFancybox) {
|
|
19
|
+
utils.css(ctx.fancybox.css);
|
|
20
|
+
utils.js(ctx.fancybox.js, { defer: true }).then(function () {
|
|
21
|
+
Fancybox.bind(selector, {
|
|
22
|
+
hideScrollbar: false,
|
|
23
|
+
Thumbs: {
|
|
24
|
+
autoStart: false,
|
|
25
|
+
},
|
|
26
|
+
caption: (fancybox, slide) => {
|
|
27
|
+
return slide.triggerEl.alt || null
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
})
|
|
31
|
+
}
|
|
32
|
+
</script>
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
utils.css(`<%- conf.css %>`);
|
|
3
|
+
utils.js(`<%- conf.js %>`, { defer: true }).then(function () {
|
|
4
|
+
const heti = new Heti('.heti');
|
|
5
|
+
|
|
6
|
+
// Copied from heti.autoSpacing() without DOMContentLoaded.
|
|
7
|
+
// https://github.com/sivan/heti/blob/eadee6a3b748b3b7924a9e7d5b395d4bce479c9a/js/heti-addon.js
|
|
8
|
+
//
|
|
9
|
+
// We managed to minimize the code modification to ensure .autoSpacing()
|
|
10
|
+
// is synced with upstream; therefore, we use `.bind()` to emulate the
|
|
11
|
+
// behavior of .autoSpacing() so we can even modify almost no code.
|
|
12
|
+
void (function () {
|
|
13
|
+
const $$rootList = document.querySelectorAll(this.rootSelector)
|
|
14
|
+
|
|
15
|
+
for (let $$root of $$rootList) {
|
|
16
|
+
this.spacingElement($$root)
|
|
17
|
+
}
|
|
18
|
+
}).bind(heti)();
|
|
19
|
+
|
|
20
|
+
});
|
|
21
|
+
</script>
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
<%
|
|
2
|
+
function loadPlugins() {
|
|
3
|
+
var el = ''
|
|
4
|
+
|
|
5
|
+
// search
|
|
6
|
+
if (theme.search[theme.search.service]) {
|
|
7
|
+
el += partial(`search/${theme.search.service}`, {conf: theme.search[theme.search.service]});
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
// others
|
|
11
|
+
for (let id of Object.keys(theme.plugins)) {
|
|
12
|
+
const conf = Object.assign({}, theme.plugins[id], page[id])
|
|
13
|
+
if (page[id] == true || conf.enable) {
|
|
14
|
+
if (conf.inject?.length > 0) {
|
|
15
|
+
el += conf.inject
|
|
16
|
+
} else {
|
|
17
|
+
el += partial(`${id}`, {conf: conf})
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
return el
|
|
22
|
+
}
|
|
23
|
+
%>
|
|
24
|
+
<%- loadPlugins() %>
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
<script defer src="<%- conf.js %>"></script>
|
|
2
|
+
<script>
|
|
3
|
+
// https://www.npmjs.com/package/vanilla-lazyload
|
|
4
|
+
// Set the options globally
|
|
5
|
+
// to make LazyLoad self-initialize
|
|
6
|
+
window.lazyLoadOptions = {
|
|
7
|
+
elements_selector: ".lazy",
|
|
8
|
+
};
|
|
9
|
+
// Listen to the initialization event
|
|
10
|
+
// and get the instance of LazyLoad
|
|
11
|
+
window.addEventListener(
|
|
12
|
+
"LazyLoad::Initialized",
|
|
13
|
+
function (event) {
|
|
14
|
+
window.lazyLoadInstance = event.detail.instance;
|
|
15
|
+
},
|
|
16
|
+
false
|
|
17
|
+
);
|
|
18
|
+
document.addEventListener('DOMContentLoaded', function () {
|
|
19
|
+
window.lazyLoadInstance?.update();
|
|
20
|
+
});
|
|
21
|
+
</script>
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
<script defer type="text/javascript" src="<%- conf.js %>"></script>
|
|
2
|
+
<script>
|
|
3
|
+
window.addEventListener('DOMContentLoaded', (event) => {
|
|
4
|
+
var mermaid_config = {
|
|
5
|
+
startOnLoad: true,
|
|
6
|
+
theme:
|
|
7
|
+
"<%- theme.style.darkmode %>" == "auto" &&
|
|
8
|
+
window.matchMedia("(prefers-color-scheme: dark)").matches
|
|
9
|
+
? "dark"
|
|
10
|
+
: "<%- conf.theme %>",
|
|
11
|
+
logLevel: 3,
|
|
12
|
+
themeVariables: {
|
|
13
|
+
darkMode: true
|
|
14
|
+
},
|
|
15
|
+
flowchart: {
|
|
16
|
+
useMaxWidth: false,
|
|
17
|
+
htmlLabels: true,
|
|
18
|
+
curve: "linear"
|
|
19
|
+
},
|
|
20
|
+
gantt: {
|
|
21
|
+
axisFormat: "%Y/%m/%d"
|
|
22
|
+
},
|
|
23
|
+
sequence: {
|
|
24
|
+
actorMargin: 50
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
mermaid.initialize(mermaid_config);
|
|
28
|
+
});
|
|
29
|
+
</script>
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
<script defer src="<%- conf.js %>"></script>
|
|
2
|
+
<script>
|
|
3
|
+
window.addEventListener('DOMContentLoaded', (event) => {
|
|
4
|
+
const slideUp = {
|
|
5
|
+
distance: `<%- conf.distance %>`,
|
|
6
|
+
duration: `<%- conf.duration %>`,
|
|
7
|
+
interval: `<%- conf.interval %>`,
|
|
8
|
+
scale: `<%- conf.scale %>`,
|
|
9
|
+
opacity: 0,
|
|
10
|
+
easing: "ease-out"
|
|
11
|
+
};
|
|
12
|
+
ScrollReveal().reveal('.l_left .slide-up', slideUp);
|
|
13
|
+
ScrollReveal().reveal('.l_main .slide-up', slideUp);
|
|
14
|
+
});
|
|
15
|
+
</script>
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
window.addEventListener('DOMContentLoaded', (event) => {
|
|
3
|
+
window.searchConfig = {
|
|
4
|
+
appId: '<%- conf.appId %>',
|
|
5
|
+
apiKey: '<%- conf.apiKey %>',
|
|
6
|
+
indexName: '<%- conf.indexName %>',
|
|
7
|
+
hitsPerPage: 100,
|
|
8
|
+
};
|
|
9
|
+
utils.js('https://gcore.jsdelivr.net/algoliasearch/3/algoliasearch.min.js', { defer: true });
|
|
10
|
+
utils.js('/js/search/algolia-search.js', { defer: true });
|
|
11
|
+
});
|
|
12
|
+
</script>
|
|
13
|
+
|