hexo-theme-shokax 0.4.1 → 0.4.2

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.
@@ -23,11 +23,6 @@ mixin WRender(item)
23
23
  div(class="rpost pjax")
24
24
  h2
25
25
  != __('index.recent_comments')
26
- ul(class="leancloud-recent-comment" id="new-comment")
27
- if tk || waline
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:#939393;")
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
@@ -47,14 +47,14 @@ html(lang=page.language?page.language:config.language, style=theme.grayMode ? 'f
47
47
  if theme.homeConfig.gradient || enableFixedCover
48
48
  //- cover不可用时用Bing随机图片代替
49
49
  - var coverImage = theme.homeConfig?.fixedCover || "https://7ed.net/bing/api"
50
- img(src=coverImage loading="eager" decoding="async" fetchpriority="high")
50
+ img(src=coverImage loading="eager" decoding="async" fetchpriority="high" alt=title)
51
51
  else
52
52
  if covers.length === 6
53
53
  ul
54
54
  each image in covers
55
55
  li(class="item" style=`background-image: url("${image}");`)
56
56
  else
57
- img(src=covers loading="eager" decoding="async" fetchpriority="high")
57
+ img(src=covers loading="eager" decoding="async" fetchpriority="high" alt=title)
58
58
  div(id="waves")
59
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")
60
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="javascript:void(0);")
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="eager" decoding="async" class="image" itemprop="image" alt=author
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.1",
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.0-alpha.11",
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",
@@ -22,7 +22,7 @@ hexo.extend.helper.register('_vendor_font', () => {
22
22
  return '';
23
23
  const fontDisplay = '&display=swap';
24
24
  const fontSubset = '&subset=latin,latin-ext';
25
- const fontStyles = ':300,300italic,400,400italic,700,700italic';
25
+ const fontStyles = ':400,400italic,700,700italic';
26
26
  const fontHost = 'https://fonts.googleapis.com';
27
27
  // Get a font list from config
28
28
  let fontFamilies = ['global', 'logo', 'title', 'headings', 'posts', 'codes'].map(item => {
@@ -6,7 +6,7 @@
6
6
  background: var(--body-bg-shadow);
7
7
 
8
8
  .inner {
9
- margin: 0 auto;
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, pageviewCount, RecentComments } from '@waline/client'
2
+ import { init, RecentComments } from '@waline/client'
3
+ import { pageviewCount } from '@waline/client/pageview'
3
4
 
4
- import { createApp } from 'vue'
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
- comments.forEach(function (item) {
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
- // @ts-ignore
45
- time: item.insertedAt.split('T').shift(),
63
+ time: dateStr,
46
64
  text: cText
47
65
  })
48
66
  })
49
- createApp({
50
- data () {
51
- return {
52
- coms: items,
53
- root
54
- }
55
- }
56
- }).mount('#new-comment')
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 { createApp } from 'vue'
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
- createApp({
34
- data () {
35
- return {
36
- coms: comments,
37
- root
38
- }
39
- }
40
- }).mount('#new-comment')
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
  }