hexo-theme-shokax 0.5.0-dev-f96faf9 → 0.5.0-dev-0282edf
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/README.md +2 -2
- package/layout/_mixin/card.pug +1 -2
- package/layout/_mixin/comment.pug +0 -1
- package/layout/_partials/footer.pug +0 -3
- package/layout/_partials/header.pug +0 -1
- package/layout/_partials/layout.pug +0 -3
- package/layout/_partials/post/footer.pug +0 -2
- package/layout/_partials/post/post.pug +0 -1
- package/layout/_partials/sidebar/overview.pug +0 -2
- package/package.json +1 -1
- package/scripts/generaters/index.js +37 -34
- package/scripts/helpers/engine.js +0 -3
- package/source/js/_app/components/sidebar.ts +2 -1
package/README.md
CHANGED
package/layout/_mixin/card.pug
CHANGED
@@ -1,9 +1,8 @@
|
|
1
1
|
mixin CardRender(item)
|
2
|
-
- cover = url_for(theme.statics + item.slug + this.getCoverExt(item.slug))
|
3
2
|
- itemname = item.name
|
4
3
|
|
5
4
|
section(class="item")
|
6
|
-
div(class="cover" data-background-image
|
5
|
+
div(class="cover" data-background-image=`${theme.statics}${item.slug}/cover.${getCoverExt(item.slug)}`)
|
7
6
|
h2(class="title")
|
8
7
|
!= itemname
|
9
8
|
- var temp = item?.top?.name
|
@@ -37,7 +37,4 @@ div(class="status")
|
|
37
37
|
a(target="_blank" href=`https://beian.mps.gov.cn/#/query/webSearch?code=${RC}`)
|
38
38
|
img(loading="lazy" decoding="async" data-src=theme.statics + theme.assets + '/' + theme.footer.icp.icon style="max-width: 2em;display:inline;" width="20" height="20" alt="备案")
|
39
39
|
!= beianN
|
40
|
-
!= shokax_inject('status')
|
41
|
-
|
42
|
-
!= shokax_inject('footer')
|
43
40
|
|
@@ -21,7 +21,6 @@ html(lang=page.language?page.language:config.language, style=theme.grayMode ? 'f
|
|
21
21
|
link(rel="preload" href!=covers as="image" fetchpriority="high")
|
22
22
|
|
23
23
|
!= partial('_partials/head/head_com.pug')
|
24
|
-
!= shokax_inject('head')
|
25
24
|
block head
|
26
25
|
title
|
27
26
|
block title
|
@@ -140,6 +139,4 @@ html(lang=page.language?page.language:config.language, style=theme.grayMode ? 'f
|
|
140
139
|
|
141
140
|
!= _js('siteInit.js')
|
142
141
|
|
143
|
-
!= shokax_inject('bodyEnd')
|
144
|
-
|
145
142
|
|
@@ -36,7 +36,5 @@ div(class="social")
|
|
36
36
|
- var sidebarIcon = '<i class="ic i-' + link.split('||')[1].trim() + '"></i>'
|
37
37
|
!= _url(sidebarURL, sidebarIcon, {title: sidebarURL, class: 'item ' + name})
|
38
38
|
|
39
|
-
!= shokax_inject('sidebar')
|
40
|
-
|
41
39
|
div(class="menu")
|
42
40
|
!= partial('_partials/sidebar/menu.pug')
|
package/package.json
CHANGED
@@ -33,6 +33,7 @@ hexo.config.index_generator = Object.assign({
|
|
33
33
|
order_by: "-date"
|
34
34
|
}, hexo.config.index_generator);
|
35
35
|
hexo.extend.helper.register("getCoverExt", function(path) {
|
36
|
+
const theme = hexo.theme.config;
|
36
37
|
if (theme.homeConfig.cateCards.length > 0) {
|
37
38
|
const cardMap = /* @__PURE__ */ new Map();
|
38
39
|
theme.homeConfig.cateCards.forEach((card) => {
|
@@ -44,7 +45,7 @@ hexo.extend.helper.register("getCoverExt", function(path) {
|
|
44
45
|
}
|
45
46
|
}
|
46
47
|
});
|
47
|
-
hexo.extend.generator.register("index", function(locals) {
|
48
|
+
hexo.extend.generator.register("index", async function(locals) {
|
48
49
|
const covers = [];
|
49
50
|
const catlist = [];
|
50
51
|
let pages;
|
@@ -54,7 +55,7 @@ hexo.extend.generator.register("index", function(locals) {
|
|
54
55
|
const paginationDir = config.pagination_dir || "page";
|
55
56
|
const path = config.index_generator.path || "";
|
56
57
|
const categories = locals.categories;
|
57
|
-
const
|
58
|
+
const theme = hexo.theme.config;
|
58
59
|
const getTopcat = function(cat) {
|
59
60
|
if (cat.parent) {
|
60
61
|
const pCat = categories.findOne({ _id: cat.parent });
|
@@ -64,42 +65,44 @@ hexo.extend.generator.register("index", function(locals) {
|
|
64
65
|
}
|
65
66
|
};
|
66
67
|
if (categories && categories.length) {
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
if (cardMap.has(cat.slug)) {
|
75
|
-
const cover2 = cardMap.get(cat.slug);
|
76
|
-
const coverData = await (0, import_promises.readFile)(`source/_posts/${cover2}`);
|
77
|
-
covers.push({
|
78
|
-
path: `${cat.slug}/cover.${getFileExtension(cover2)}`,
|
79
|
-
data: coverData
|
68
|
+
await Promise.all(
|
69
|
+
categories.map(async (cat) => {
|
70
|
+
const cover = `source/_posts/${cat.slug}`;
|
71
|
+
if (theme.homeConfig.cateCards.length > 0) {
|
72
|
+
const cardMap = /* @__PURE__ */ new Map();
|
73
|
+
theme.homeConfig.cateCards.forEach((card) => {
|
74
|
+
cardMap.set(card.slug, card.cover);
|
80
75
|
});
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
76
|
+
if (cardMap.has(cat.slug)) {
|
77
|
+
const cover2 = cardMap.get(cat.slug);
|
78
|
+
const coverData = await (0, import_promises.readFile)(`source/_posts/${cover2}`);
|
79
|
+
covers.push({
|
80
|
+
path: `${cat.slug}/cover.${getFileExtension(cover2)}`,
|
81
|
+
data: coverData
|
82
|
+
});
|
83
|
+
const topcat = getTopcat(cat);
|
84
|
+
if (topcat._id !== cat._id) {
|
85
|
+
cat.top = topcat;
|
86
|
+
}
|
87
|
+
const child = categories.find({ parent: cat._id });
|
88
|
+
let pl = 6;
|
89
|
+
if (child.length !== 0) {
|
90
|
+
cat.child = child.length;
|
91
|
+
cat.subs = child.sort({ name: 1 }).limit(6).toArray();
|
92
|
+
pl = Math.max(0, pl - child.length);
|
93
|
+
if (pl > 0) {
|
94
|
+
cat.subs.push(...cat.posts.sort({ title: 1 }).filter(function(item, i) {
|
95
|
+
return item.categories.last()._id === cat._id;
|
96
|
+
}).limit(pl).toArray());
|
97
|
+
}
|
98
|
+
} else {
|
99
|
+
cat.subs = cat.posts.sort({ title: 1 }).limit(6).toArray();
|
95
100
|
}
|
96
|
-
|
97
|
-
cat.subs = cat.posts.sort({ title: 1 }).limit(6).toArray();
|
101
|
+
catlist.push(cat);
|
98
102
|
}
|
99
|
-
catlist.push(cat);
|
100
103
|
}
|
101
|
-
}
|
102
|
-
|
104
|
+
})
|
105
|
+
);
|
103
106
|
}
|
104
107
|
if (posts.length > 0) {
|
105
108
|
pages = (0, import_hexo_pagination.default)(path, posts, {
|
@@ -156,6 +156,3 @@ hexo.extend.helper.register("random_color", function() {
|
|
156
156
|
const [r, g, b] = arr;
|
157
157
|
return `#${r.toString(16).length > 1 ? r.toString(16) : "0" + r.toString(16)}${g.toString(16).length > 1 ? g.toString(16) : "0" + g.toString(16)}${b.toString(16).length > 1 ? b.toString(16) : "0" + b.toString(16)}`;
|
158
158
|
});
|
159
|
-
hexo.extend.helper.register("shokax_inject", function(point) {
|
160
|
-
return hexo.theme.config.injects[point].map((item) => this.partial(item.layout, item.locals, item.options)).join("");
|
161
|
-
});
|
@@ -59,7 +59,8 @@ export const sideBarTab = () => {
|
|
59
59
|
const text = document.createTextNode(element.getAttribute('data-title'))
|
60
60
|
span.appendChild(text)
|
61
61
|
tab.appendChild(span)
|
62
|
-
tab.classList.add(item
|
62
|
+
tab.classList.add(item)
|
63
|
+
tab.classList.add('item')
|
63
64
|
|
64
65
|
if (active) {
|
65
66
|
element.classList.add(active)
|