hexo-theme-shokax 0.4.0 → 0.4.2
Sign up to get free protection for your applications and to get access to all the features.
- package/layout/_mixin/widgets.pug +2 -7
- package/layout/_partials/footer.pug +4 -3
- package/layout/_partials/head/head_com.pug +7 -0
- package/layout/_partials/layout.pug +13 -5
- package/layout/_partials/sidebar/menu.pug +1 -1
- package/layout/_partials/sidebar/overview.pug +1 -1
- package/package.json +2 -2
- package/scripts/helpers/asset.js +4 -9
- package/scripts/plugin/index.js +2 -2
- package/source/css/_common/outline/footer/footer.styl +1 -3
- package/source/js/_app/components/comments.ts +45 -13
- package/source/js/_app/components/sidebar.ts +1 -1
- package/source/js/_app/components/tcomments.ts +23 -9
@@ -23,11 +23,6 @@ mixin WRender(item)
|
|
23
23
|
div(class="rpost pjax")
|
24
24
|
h2
|
25
25
|
!= __('index.recent_comments')
|
26
|
-
|
27
|
-
|
28
|
-
li(v-for="com in coms" class="item")
|
29
|
-
a(v-bind:href="root + com.href" data-pjax-state="data-pjax-state")
|
30
|
-
span(class="breadcrumb") {{com.nick}} @ {{com.time}}
|
31
|
-
span {{com.text}}
|
32
|
-
br
|
26
|
+
if tk || waline
|
27
|
+
ul(class="leancloud-recent-comment" id="new-comment")
|
33
28
|
|
@@ -15,7 +15,8 @@ div(class="status")
|
|
15
15
|
i(class="ic i-chart-area")
|
16
16
|
span(title=__('symbols_count_time.count_total'))
|
17
17
|
!= `${ symbolsCountTotal(site) } ${__('symbols_count_time.word')}`
|
18
|
-
span(class="post-meta-divider")
|
18
|
+
span(class="post-meta-divider")
|
19
|
+
!= " | "
|
19
20
|
span(class="post-meta-item-icon")
|
20
21
|
i(class="ic i-coffee")
|
21
22
|
span(title=__('symbols_count_time.time_total'))
|
@@ -27,14 +28,14 @@ div(class="status")
|
|
27
28
|
!= __('footer.powered', _url('https://hexo.io', 'Hexo') + ' & Theme.' + _url('https://github.com/theme-shoka-x/hexo-theme-shokaX/', 'ShokaX'))
|
28
29
|
if theme.footer.icp.enable
|
29
30
|
br
|
30
|
-
span(style="display:inline;height:20px;line-height:20px;margin: 0px 0px 0px 5px; color
|
31
|
+
span(style="display:inline;height:20px;line-height:20px;margin: 0px 0px 0px 5px; color:var(--grey-5);")
|
31
32
|
a(href="https://beian.miit.gov.cn")
|
32
33
|
!= theme.footer.icp.icpnumber
|
33
34
|
- var beianN = theme.footer.icp?.beian, RC=theme.footer.icp?.recordcode
|
34
35
|
if beianN && RC
|
35
36
|
br
|
36
37
|
a(target="_blank" href=`https://beian.mps.gov.cn/#/query/webSearch?code=${RC}`)
|
37
|
-
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")
|
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="备案")
|
38
39
|
!= beianN
|
39
40
|
!= shokax_inject('status')
|
40
41
|
|
@@ -11,6 +11,13 @@ else if page.tags && page.tags.length
|
|
11
11
|
else if config.keywords
|
12
12
|
meta(name="keywords" content=config.keywords)
|
13
13
|
|
14
|
+
if page.description
|
15
|
+
meta(name="description" content=page.description)
|
16
|
+
else if page.excerpt
|
17
|
+
meta(name="description" content=page.excerpt)
|
18
|
+
else if config.description
|
19
|
+
meta(name="description" content=config.description)
|
20
|
+
|
14
21
|
!= canonical()
|
15
22
|
|
16
23
|
if theme.open_graph
|
@@ -6,10 +6,19 @@ include ../_mixin/widgets.pug
|
|
6
6
|
if (theme.quicklink.ignores)
|
7
7
|
- ignores.push(theme.quicklink.ignores)
|
8
8
|
|
9
|
+
- var covers = _cover_index(page, 6)
|
10
|
+
- var enableFixedCover = theme.homeConfig?.fixedCover
|
11
|
+
|
9
12
|
doctype html
|
10
13
|
html(lang=page.language?page.language:config.language, style=theme.grayMode ? 'filter: grayscale(1);':'' )
|
11
14
|
head
|
12
15
|
!= partial('_partials/head/head.pug', {}, {cache: true})
|
16
|
+
if enableFixedCover
|
17
|
+
link(rel="preload" href=theme.homeConfig.fixedCover as="image" fetchpriority="high")
|
18
|
+
else
|
19
|
+
each image in covers
|
20
|
+
link(rel="preload" href=image as="image" fetchpriority="high")
|
21
|
+
|
13
22
|
!= partial('_partials/head/head_com.pug')
|
14
23
|
!= shokax_inject('head')
|
15
24
|
title
|
@@ -35,18 +44,17 @@ html(lang=page.language?page.language:config.language, style=theme.grayMode ? 'f
|
|
35
44
|
|
36
45
|
!= partial('_partials/header.pug', {}, {cache: true})
|
37
46
|
div(id="imgs" class="pjax")
|
38
|
-
if theme.homeConfig.gradient ||
|
47
|
+
if theme.homeConfig.gradient || enableFixedCover
|
39
48
|
//- cover不可用时用Bing随机图片代替
|
40
|
-
- var coverImage = theme.homeConfig
|
41
|
-
img(src=coverImage loading="eager" decoding="async" fetchpriority="high")
|
49
|
+
- var coverImage = theme.homeConfig?.fixedCover || "https://7ed.net/bing/api"
|
50
|
+
img(src=coverImage loading="eager" decoding="async" fetchpriority="high" alt=title)
|
42
51
|
else
|
43
|
-
- var covers = _cover_index(page, 6)
|
44
52
|
if covers.length === 6
|
45
53
|
ul
|
46
54
|
each image in covers
|
47
55
|
li(class="item" style=`background-image: url("${image}");`)
|
48
56
|
else
|
49
|
-
img(src=covers loading="eager" decoding="async" fetchpriority="high")
|
57
|
+
img(src=covers loading="eager" decoding="async" fetchpriority="high" alt=title)
|
50
58
|
div(id="waves")
|
51
59
|
svg(class="waves" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 24 150 28" preserveAspectRatio="none" shape-rendering="auto")
|
52
60
|
defs
|
@@ -8,7 +8,7 @@ mixin item(name, path, parent, sublist)
|
|
8
8
|
if parent
|
9
9
|
li(class="item dropdown")
|
10
10
|
if itemURL === '/'
|
11
|
-
a(href="
|
11
|
+
a(href="#" onclick="return false;")
|
12
12
|
!= menuIcon + menuText
|
13
13
|
else
|
14
14
|
!= _url(itemURL, menuIcon + menuText, {rel: 'section'})
|
@@ -1,5 +1,5 @@
|
|
1
1
|
div(class="author" itemprop="author" itemscope itemtype="http://schema.org/Person")
|
2
|
-
img(loading="
|
2
|
+
img(loading="lazy" decoding="async" class="image" itemprop="image" alt=author
|
3
3
|
src=url_for(theme.statics + theme.assets + '/'+ theme.sidebar.avatar))
|
4
4
|
p(class="name" itemprop="name")
|
5
5
|
!= author
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "hexo-theme-shokax",
|
3
|
-
"version": "0.4.
|
3
|
+
"version": "0.4.2",
|
4
4
|
"description": "a hexo theme based on shoka",
|
5
5
|
"main": "index.js",
|
6
6
|
"repository": "https://github.com/theme-shoka-x/hexo-theme-shokaX",
|
@@ -28,7 +28,7 @@
|
|
28
28
|
"typescript": "^5.3.3"
|
29
29
|
},
|
30
30
|
"dependencies": {
|
31
|
-
"@waline/client": "3.0.
|
31
|
+
"@waline/client": "^3.0.1",
|
32
32
|
"vue": "^3.4.15",
|
33
33
|
"@algolia/client-search": "^4.22.1",
|
34
34
|
"algoliasearch": "4.22.1",
|
package/scripts/helpers/asset.js
CHANGED
@@ -7,10 +7,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
7
|
const package_json_1 = __importDefault(require("../../package.json"));
|
8
8
|
const hexo_util_1 = require("hexo-util");
|
9
9
|
const utils_1 = require("../utils");
|
10
|
-
// TODO 弃用函数
|
11
|
-
hexo.extend.helper.register('_new_comments', function (mode) {
|
12
|
-
return '';
|
13
|
-
});
|
14
10
|
hexo.extend.helper.register('_safedump', (source) => {
|
15
11
|
return JSON.stringify(source);
|
16
12
|
});
|
@@ -26,7 +22,7 @@ hexo.extend.helper.register('_vendor_font', () => {
|
|
26
22
|
return '';
|
27
23
|
const fontDisplay = '&display=swap';
|
28
24
|
const fontSubset = '&subset=latin,latin-ext';
|
29
|
-
const fontStyles = ':
|
25
|
+
const fontStyles = ':400,400italic,700,700italic';
|
30
26
|
const fontHost = 'https://fonts.googleapis.com';
|
31
27
|
// Get a font list from config
|
32
28
|
let fontFamilies = ['global', 'logo', 'title', 'headings', 'posts', 'codes'].map(item => {
|
@@ -44,7 +40,9 @@ hexo.extend.helper.register('_vendor_font', () => {
|
|
44
40
|
return fontFamilies
|
45
41
|
? (0, hexo_util_1.htmlTag)('link', {
|
46
42
|
rel: 'stylesheet',
|
47
|
-
href: `${fontHost}/css?family=${fontFamilies.concat(fontDisplay, fontSubset)}
|
43
|
+
href: `${fontHost}/css?family=${fontFamilies.concat(fontDisplay, fontSubset)}`,
|
44
|
+
media: 'none',
|
45
|
+
onload: "this.media='all'"
|
48
46
|
})
|
49
47
|
: '';
|
50
48
|
});
|
@@ -65,9 +63,6 @@ hexo.extend.helper.register('vendor_js', function () {
|
|
65
63
|
for (const jsSync in vendors.js) {
|
66
64
|
res += (0, hexo_util_1.htmlTag)('script', { src: (0, utils_1.getVendorLink)(hexo, vendors.js[jsSync]), async: true }, '');
|
67
65
|
}
|
68
|
-
// for (const jsAsync in vendors.async_js) {
|
69
|
-
// res += htmlTag('script', { src: getVendorLink(hexo, vendors.async_js[jsAsync]), async: true }, '')
|
70
|
-
// }
|
71
66
|
return res;
|
72
67
|
});
|
73
68
|
hexo.extend.helper.register('_striptags', function (data) {
|
package/scripts/plugin/index.js
CHANGED
@@ -47,10 +47,10 @@ hexo.on('generateBefore', () => {
|
|
47
47
|
});
|
48
48
|
hexo.on('generateAfter', () => {
|
49
49
|
// 检查版本更新
|
50
|
-
fetch('https://
|
50
|
+
fetch('https://registry.npmmirror.com/hexo-theme-shokax').then((res) => {
|
51
51
|
res.json().then((resp) => {
|
52
52
|
try {
|
53
|
-
const latest = resp
|
53
|
+
const latest = resp['dist-tags'].latest;
|
54
54
|
const current = package_json_1.version.split('.');
|
55
55
|
let isOutdated = false;
|
56
56
|
for (let i = 0; i < Math.max(latest.length, current.length); i++) {
|
@@ -6,7 +6,7 @@
|
|
6
6
|
background: var(--body-bg-shadow);
|
7
7
|
|
8
8
|
.inner {
|
9
|
-
margin:
|
9
|
+
margin: 2rem auto .625rem;
|
10
10
|
width: $content-desktop;
|
11
11
|
position: relative;
|
12
12
|
|
@@ -35,7 +35,6 @@
|
|
35
35
|
.status {
|
36
36
|
width: 100%;
|
37
37
|
text-align: center;
|
38
|
-
margin-top: 2rem;
|
39
38
|
}
|
40
39
|
|
41
40
|
.languages {
|
@@ -65,5 +64,4 @@
|
|
65
64
|
|
66
65
|
.powered-by, .theme-info {
|
67
66
|
display: inline-block;
|
68
|
-
margin-bottom: .625rem;
|
69
67
|
}
|
@@ -1,7 +1,8 @@
|
|
1
1
|
import { CONFIG } from '../globals/globalVars'
|
2
|
-
import { init,
|
2
|
+
import { init, RecentComments } from '@waline/client'
|
3
|
+
import { pageviewCount } from '@waline/client/pageview'
|
3
4
|
|
4
|
-
import {
|
5
|
+
import { $dom } from '../library/dom'
|
5
6
|
|
6
7
|
export const walineComment = function () {
|
7
8
|
init({
|
@@ -21,6 +22,7 @@ export const walineComment = function () {
|
|
21
22
|
}
|
22
23
|
|
23
24
|
export const walinePageview = function () {
|
25
|
+
// TODO waline 上游此模块存在问题
|
24
26
|
pageviewCount({
|
25
27
|
serverURL: CONFIG.waline.serverURL,
|
26
28
|
path: window.location.pathname
|
@@ -34,24 +36,54 @@ export const walineRecentComments = async function () {
|
|
34
36
|
serverURL: CONFIG.waline.serverURL.replace(/\/+$/, ''),
|
35
37
|
count: 10
|
36
38
|
})
|
37
|
-
|
39
|
+
// TODO 疑似 waline API 返回格式与文档不一致,需要确认是否为上游问题
|
40
|
+
// @ts-ignore
|
41
|
+
comments.data.forEach(function (item) {
|
38
42
|
let cText = (item.orig.length > 50) ? item.orig.substring(0, 50) + '...' : item.orig
|
39
43
|
item.url = item.url.startsWith('/') ? item.url : '/' + item.url
|
40
44
|
const siteLink = item.url + '#' + item.objectId
|
45
|
+
|
46
|
+
const time = new Date(item.time)
|
47
|
+
const now = new Date()
|
48
|
+
const diff = now.valueOf() - time.valueOf()
|
49
|
+
let dateStr:string
|
50
|
+
if (diff < 3600000) {
|
51
|
+
dateStr = `${Math.floor(diff / 60000)} 分钟前`
|
52
|
+
} else if (diff < 86400000) {
|
53
|
+
dateStr = `${Math.floor(diff / 3600000)} 小时前`
|
54
|
+
} else if (diff < 2592000000) {
|
55
|
+
dateStr = `${Math.floor(diff / 86400000)} 天前`
|
56
|
+
} else {
|
57
|
+
dateStr = `${time.getFullYear()}-${time.getMonth() + 1}-${time.getDate()}`
|
58
|
+
}
|
59
|
+
|
41
60
|
items.push({
|
42
61
|
href: siteLink,
|
43
62
|
nick: item.nick,
|
44
|
-
|
45
|
-
time: item.insertedAt.split('T').shift(),
|
63
|
+
time: dateStr,
|
46
64
|
text: cText
|
47
65
|
})
|
48
66
|
})
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
67
|
+
const newComments = new DocumentFragment()
|
68
|
+
items.forEach(function (item) {
|
69
|
+
const commentEl = document.createElement('li')
|
70
|
+
const commentLink = document.createElement('a')
|
71
|
+
const commentTime = document.createElement('span')
|
72
|
+
const commentText = document.createElement('span')
|
73
|
+
|
74
|
+
commentText.innerText = item.text
|
75
|
+
commentTime.className = 'breadcrumb'
|
76
|
+
commentTime.innerText = `${item.nick} @ ${item.time}`
|
77
|
+
commentLink.href = root + item.href
|
78
|
+
commentLink['data-pjax-state'] = 'data-pjax-state'
|
79
|
+
commentEl.className = 'item'
|
80
|
+
|
81
|
+
commentText.appendChild(document.createElement('br'))
|
82
|
+
commentLink.appendChild(commentTime)
|
83
|
+
commentLink.appendChild(commentText)
|
84
|
+
commentEl.appendChild(commentLink)
|
85
|
+
newComments.appendChild(commentEl)
|
86
|
+
})
|
87
|
+
|
88
|
+
$dom('#new-comment').appendChild(newComments)
|
57
89
|
}
|
@@ -228,7 +228,7 @@ export const menuActive = () => {
|
|
228
228
|
if (!target) return
|
229
229
|
const isSamePath = target.pathname === location.pathname || target.pathname === location.pathname.replace('index.html', '')
|
230
230
|
const isSubPath = !CONFIG.root.startsWith(target.pathname) && location.pathname.startsWith(target.pathname)
|
231
|
-
const active = target.hostname === location.hostname && (isSamePath || isSubPath)
|
231
|
+
const active = !target.onclick && target.hostname === location.hostname && (isSamePath || isSubPath)
|
232
232
|
element.toggleClass('active', active)
|
233
233
|
if (element.parentNode.child('.active') && parentItem.hasClass('dropdown')) {
|
234
234
|
parentItem.removeClass('active').addClass('expand')
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import twikoo from 'twikoo'
|
2
2
|
import { CONFIG } from '../globals/globalVars'
|
3
|
-
import {
|
3
|
+
import { $dom } from '../library/dom'
|
4
4
|
|
5
5
|
export const twikooComment = function () {
|
6
6
|
twikoo.init({
|
@@ -30,12 +30,26 @@ export const twikooRecentComments = async function () {
|
|
30
30
|
text: cText
|
31
31
|
})
|
32
32
|
})
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
33
|
+
const newComments = new DocumentFragment()
|
34
|
+
comments.forEach(function (item) {
|
35
|
+
const commentEl = document.createElement('li')
|
36
|
+
const commentLink = document.createElement('a')
|
37
|
+
const commentTime = document.createElement('span')
|
38
|
+
const commentText = document.createElement('span')
|
39
|
+
|
40
|
+
commentText.innerText = item.text
|
41
|
+
commentTime.className = 'breadcrumb'
|
42
|
+
commentTime.innerText = `${item.nick} @ ${item.time}`
|
43
|
+
commentLink.href = root + item.href
|
44
|
+
commentLink['data-pjax-state'] = 'data-pjax-state'
|
45
|
+
commentEl.className = 'item'
|
46
|
+
|
47
|
+
commentText.appendChild(document.createElement('br'))
|
48
|
+
commentLink.appendChild(commentTime)
|
49
|
+
commentLink.appendChild(commentText)
|
50
|
+
commentEl.appendChild(commentLink)
|
51
|
+
newComments.appendChild(commentEl)
|
52
|
+
})
|
53
|
+
|
54
|
+
$dom('#new-comment').appendChild(newComments)
|
41
55
|
}
|