hexo-theme-volantis 5.0.0-rc.9 → 5.2.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.
Files changed (62) hide show
  1. package/CHANGELOG.md +36 -0
  2. package/README.md +2 -1
  3. package/_config.yml +69 -46
  4. package/layout/_meta/counter.ejs +27 -5
  5. package/layout/_meta/walinecount.ejs +2 -1
  6. package/layout/_partial/article.ejs +2 -2
  7. package/layout/_partial/head.ejs +29 -28
  8. package/layout/_partial/header.ejs +1 -1
  9. package/layout/_partial/scripts/content-visibility-scroll-fix.ejs +71 -69
  10. package/layout/_partial/scripts/global.ejs +47 -23
  11. package/layout/_partial/scripts/index.ejs +22 -9
  12. package/layout/_partial/scripts/toc.ejs +61 -38
  13. package/layout/_plugins/_page_plugins/indent/index.ejs +1 -1
  14. package/layout/_plugins/_page_plugins/index.ejs +27 -7
  15. package/layout/_plugins/_page_plugins/snackbar/index.ejs +1 -1
  16. package/layout/_plugins/analytics/script.ejs +11 -1
  17. package/layout/_plugins/aplayer/script.ejs +1 -1
  18. package/layout/_plugins/comments/artalk/script.ejs +38 -11
  19. package/layout/_plugins/comments/beaudar/script.ejs +2 -2
  20. package/layout/_plugins/comments/discuss/script.ejs +30 -0
  21. package/layout/_plugins/comments/hashover/script.ejs +2 -2
  22. package/layout/_plugins/comments/index.ejs +4 -4
  23. package/layout/_plugins/comments/twikoo/script.ejs +1 -1
  24. package/layout/_plugins/comments/waline/script.ejs +40 -22
  25. package/layout/_plugins/parallax/script.ejs +1 -1
  26. package/layout/_plugins/pjax/index.ejs +4 -1
  27. package/layout/_plugins/rightmenu/layout.ejs +2 -2
  28. package/layout/_plugins/rightmenus/layout.ejs +17 -17
  29. package/layout/_widget/lastupdate.ejs +27 -27
  30. package/layout/_widget/webinfo.ejs +7 -7
  31. package/layout/layout.ejs +20 -3
  32. package/layout/tag.ejs +1 -1
  33. package/package.json +1 -1
  34. package/scripts/events/lib/check-configuration.js +43 -0
  35. package/scripts/events/lib/check-environment.js +20 -1
  36. package/scripts/events/lib/config.js +3 -0
  37. package/scripts/events/lib/render-stylus.js +1 -1
  38. package/scripts/filters/content-visibility.js +2 -2
  39. package/scripts/helpers/custom-files.js +3 -1
  40. package/scripts/helpers/head/generate_seo.js +1 -1
  41. package/scripts/helpers/structured-data/lib/blogposting.js +18 -6
  42. package/scripts/helpers/structured-data/lib/breadcrumblist.js +25 -1
  43. package/scripts/helpers/structured-data/lib/index.js +1 -9
  44. package/scripts/tags/fancybox.js +1 -1
  45. package/scripts/tags/tabs.js +85 -86
  46. package/source/css/_defines/AutoPrefixCSS.styl +16 -16
  47. package/source/css/_first/base_first.styl +6 -0
  48. package/source/css/_first/navbar_first.styl +1 -1
  49. package/source/css/_style/_base/base.styl +1 -1
  50. package/source/css/_style/_layout/toc.styl +2 -2
  51. package/source/css/_style/_plugins/_dark/dark_async.styl +1 -1
  52. package/source/css/_style/_plugins/_dark/dark_plugins.styl +8 -4
  53. package/source/css/_style/_plugins/_rightmenu/reading.styl +2 -2
  54. package/source/css/_style/_plugins/_rightmenu/rightmenu.styl +1 -1
  55. package/source/css/_style/_plugins/fontcolor.styl +1 -1
  56. package/source/css/first.styl +5 -7
  57. package/source/js/app.js +32 -35
  58. package/source/js/plugins/aplayer.js +1 -3
  59. package/source/js/plugins/rightMenu.js +22 -22
  60. package/source/js/plugins/rightMenus.js +115 -78
  61. package/source/js/search/hexo.js +3 -0
  62. package/layout/_partial/scripts/import.ejs +0 -3
@@ -1,4 +1,4 @@
1
- <!--
1
+ <!--
2
2
  pjax重载区域接口:
3
3
  1. <pjax></pjax> 标签 pjax 标签必须存在于所有页面 否则 pjax error
4
4
  2. script[data-pjax]
@@ -19,6 +19,9 @@
19
19
  pjax = new Pjax({
20
20
  elements: 'a[href]:not([href^="#"]):not([href="javascript:void(0)"]):not([pjax-fancybox]):not([onclick="return false;"]):not([onclick="return!1"]):not([target="_blank"]):not([target="view_window"]):not([href$=".xml"])',
21
21
  selectors: [
22
+ "head title",
23
+ "head meta[name=keywords]",
24
+ "head meta[name=description]",
22
25
  <% if (!theme.plugins.pjax.cover){ %>"#l_cover",<% } %>
23
26
  "#l_main",
24
27
  "#pjax-header-nav-list",
@@ -80,13 +80,13 @@
80
80
  <span class='vlts-menu opt fix-cursor-default' id='printHtml'>
81
81
  <i class='<%= theme.rightmenu.print.icon %> fa-fw '></i> <%- trim(theme.rightmenu.print.name) %>
82
82
  </span>
83
- </li>
83
+ </li>
84
84
  <% } else if (item == 'reading') { %>
85
85
  <li class='option menuOption-Content'>
86
86
  <span class='vlts-menu opt fix-cursor-default' id='readingModel'>
87
87
  <i class='<%= theme.rightmenu.reading.icon %> fa-fw '></i> <%- trim(theme.rightmenu.reading.name) %>
88
88
  </span>
89
- </li>
89
+ </li>
90
90
  <% } else if (item == 'music' && theme.plugins.aplayer.enable == true) { %>
91
91
  <div id="menuMusic">
92
92
  <li class='music name menuOption-Content'>
@@ -1,7 +1,7 @@
1
1
  <%
2
2
  const rightMenu = {
3
3
  defaultEvent: ['copyText', 'copyLink', 'copyPaste', 'copyAll', 'copyCut', 'copyImg', 'printMode', 'readMode'],
4
- defaultGroup: ['navigation', 'inputBox', 'seletctText', 'elementCheck', 'articlePage'],
4
+ defaultGroup: ['navigation', 'inputBox', 'seletctText', 'elementCheck', 'elementImage', 'articlePage'],
5
5
  dataGet: (data, keyStr) => {
6
6
  const keys = keyStr.split('.');
7
7
  let currentData = data;
@@ -20,10 +20,10 @@
20
20
  } else {
21
21
  if(Array.isArray(data)) {
22
22
  data.forEach(item => {
23
- rightMenu.loadMenu(item)
24
- })
23
+ rightMenu.loadMenu(item)
24
+ })
25
25
  } else {
26
- rightMenu.loadMenu(data)
26
+ rightMenu.loadMenu(data)
27
27
  }
28
28
  }
29
29
  })
@@ -33,10 +33,10 @@
33
33
  let data = rightMenu.dataGet(theme.rightmenus, item);
34
34
  if(Array.isArray(data)) {
35
35
  data.forEach(item => {
36
- rightMenu.rederFunction(item)
37
- })
36
+ rightMenu.rederFunction(item)
37
+ })
38
38
  } else {
39
- rightMenu.rederFunction(data)
39
+ rightMenu.rederFunction(data)
40
40
  }
41
41
  })
42
42
  }
@@ -45,7 +45,7 @@
45
45
 
46
46
  <% rightMenu.loadMenu = item => { %>
47
47
  <% if(item === undefined) { %>
48
- <hr class="menuLoad-Content" >
48
+ <hr class="menuLoad-Content" >
49
49
  <% } else if(item['id'] === undefined) { %>
50
50
  <hr class="menuLoad-Content" >
51
51
  <% } else if(item['link'] === undefined) { %>
@@ -54,14 +54,14 @@
54
54
  <i class="<%- item.icon %> fa-fw"></i>
55
55
  <%- item.name %>
56
56
  </span>
57
- </li>
57
+ </li>
58
58
  <% } else { %>
59
59
  <li class="menuLoad-Content">
60
60
  <a class="vlts-menu fix-cursor-default" id="<%- item.id %>" href="<%- item.link %>" data-group="<%- item.group %>">
61
61
  <i class="<%- item.icon %> fa-fw"></i>
62
62
  <%- item.name %>
63
63
  </a>
64
- </li>
64
+ </li>
65
65
  <% } %>
66
66
  <% } %>
67
67
 
@@ -69,7 +69,7 @@
69
69
  <% rightMenu.loadNavigation = objs => { %>
70
70
  <li class='navigation menuNavigation-Content'>
71
71
  <% objs.forEach(item => { %>
72
- <% if(item.link === undefined) { %>
72
+ <% if(item.link === undefined) { %>
73
73
  <a class="nav icon-only fix-cursor-default" onclick="<%- item.event %>"><i class="<%- item.icon %> fa-fw"></i></a>
74
74
  <% } else { %>
75
75
  <a class="nav icon-only fix-cursor-default" href="<%- item.link %>"><i class="<%- item.icon %> fa-fw"></i></a>
@@ -79,18 +79,18 @@
79
79
  <% } %>
80
80
 
81
81
 
82
- <% rightMenu.rederFunction = item => { %>
82
+ <% rightMenu.rederFunction = item => { %>
83
83
  <% if (!!item && !!item['event'] && item['group'] !== 'navigation') { %>
84
84
  <% if (rightMenu.defaultEvent.some(value => { return value === item['event'] })) { %>
85
85
  <!-- RightMenusFunction['<%- item.id %>'] = (fun) => {fun()} -->
86
- <% } else if (item['group'] === 'seletctText') { %>
86
+ <% } else if (item['group'] === 'seletctText') { %>
87
87
  RightMenusFunction['<%- item.id %>'] = (__text__) => {<%- item.event %>}
88
- <% } else if (item['group'] === 'elementCheck') { %>
88
+ <% } else if (item['group'] === 'elementCheck' || item['group'] === 'elementImage') { %>
89
89
  RightMenusFunction['<%- item.id %>'] = (__link__) => {<%- item.event %>}
90
- <% } else { %>
90
+ <% } else { %>
91
91
  RightMenusFunction['<%- item.id %>'] = () => {<%- item.event %>}
92
- <% } %>
93
- <% } %>
92
+ <% } %>
93
+ <% } %>
94
94
  <% } %>
95
95
 
96
96
 
@@ -1,27 +1,27 @@
1
- <%
2
- function genList() {
3
- let content = '';
4
- site.posts.filter(p => {
5
- return p.title && p.title.length > 0;
6
- }).sort("updated", -1).limit(5).each(item => {
7
- content += `<li><a class="widget-last" href="${url_for(item.link || item.path)}">`;
8
- content += '<div class="item">';
9
- content += `<time>${date(item.updated, config.date_format)}</time>`;
10
- item.categories.limit(1).forEach((cat, i) => {
11
- content += `<span>${cat.name}</span>`;
12
- });
13
- content += '</div>';
14
- content += `<span>${item.title}</span>`;
15
- content += '</a></li>';
16
- content += '';
17
- })
18
- return `<ul class="list entry navigation">${content}</ul>`;
19
- }
20
- %>
21
- <%- partial('_pre') %>
22
- <section class="widget <%- page.widget_style %> <%- page.widget_platform %> <%- page.widget_pjax %>">
23
- <%- partial('header', {item: item}) %>
24
- <div class='content'>
25
- <%- genList() %>
26
- </div>
27
- </section>
1
+ <%
2
+ function genList() {
3
+ let content = '';
4
+ site.posts.filter(p => {
5
+ return p.title && p.title.length > 0;
6
+ }).sort("updated", -1).limit(5).each(item => {
7
+ content += `<li><a class="widget-last" href="${url_for(item.link || item.path)}">`;
8
+ content += '<div class="item">';
9
+ content += `<time>${date(item.updated, config.date_format)}</time>`;
10
+ item.categories.limit(1).forEach((cat, i) => {
11
+ content += `<span>${cat.name}</span>`;
12
+ });
13
+ content += '</div>';
14
+ content += `<span>${item.title}</span>`;
15
+ content += '</a></li>';
16
+ content += '';
17
+ })
18
+ return `<ul class="list entry navigation">${content}</ul>`;
19
+ }
20
+ %>
21
+ <%- partial('_pre') %>
22
+ <section class="widget <%- page.widget_style %> <%- page.widget_platform %> <%- page.widget_pjax %>">
23
+ <%- partial('header', {item: item}) %>
24
+ <div class='content'>
25
+ <%- genList() %>
26
+ </div>
27
+ </section>
@@ -25,23 +25,23 @@
25
25
  </div>
26
26
  <% } %>
27
27
 
28
- <% if (item.type.visitcounter.siteuv.enable && item.type.visitcounter.service) { %>
28
+ <% if (item.type.visitcounter.siteuv.enable && (!!theme.analytics.busuanz || !!theme.analytics.leancloud.app_id)) { %>
29
29
  <div class="webinfo-item">
30
30
  <div><%= item.type.visitcounter.siteuv.text %></div>
31
- <% if (item.type.visitcounter.service == "busuanzi") {%>
31
+ <% if (!!theme.analytics.busuanz) {%>
32
32
  <div><span id="busuanzi_value_site_uv"><i class="fa-solid fa-fan fa-spin fa-fw" aria-hidden="true"></i></span> <%= item.type.visitcounter.siteuv.unit %></div>
33
- <% } else if (item.type.visitcounter.service == "leancloud") { %>
33
+ <% } else { %>
34
34
  <div><span id="lc-uv"><span id='number'><i class="fa-solid fa-circle-notch fa-spin fa-fw" aria-hidden="true"></i></span></span> <%= item.type.visitcounter.siteuv.unit %></div>
35
35
  <% } %>
36
36
  </div>
37
37
  <% } %>
38
38
 
39
- <% if (item.type.visitcounter.sitepv.enable && item.type.visitcounter.service) { %>
39
+ <% if (item.type.visitcounter.sitepv.enable && (!!theme.analytics.busuanz || !!theme.analytics.leancloud.app_id)) { %>
40
40
  <div class="webinfo-item">
41
41
  <div><%= item.type.visitcounter.sitepv.text %></div>
42
- <% if (item.type.visitcounter.service == "busuanzi") {%>
42
+ <% if (!!theme.analytics.busuanz) {%>
43
43
  <div><span id="busuanzi_value_site_pv"><i class="fa-solid fa-fan fa-spin fa-fw" aria-hidden="true"></i></span> <%= item.type.visitcounter.sitepv.unit %></div>
44
- <% } else if (item.type.visitcounter.service == "leancloud") { %>
44
+ <% } else { %>
45
45
  <div><span id="lc-sv"><span id='number'><i class="fa-solid fa-circle-notch fa-spin fa-fw" aria-hidden="true"></i></span></span> <%= item.type.visitcounter.sitepv.unit %></div>
46
46
  <% } %>
47
47
  </div>
@@ -50,7 +50,7 @@
50
50
  <% if (item.type.lastupd.enable) { %>
51
51
  <div class="webinfo-item">
52
52
  <div><%= item.type.lastupd.text %></div>
53
- <div id="last-update-show"><%- date(Date.now()) %> <%= item.type.lastupd.unit %></div>
53
+ <div id="last-update-show"><%- date(Date.now()) %> <%= item.type.lastupd.unit %></div>
54
54
  </div>
55
55
  <% } %>
56
56
  </div>
package/layout/layout.ejs CHANGED
@@ -3,6 +3,16 @@
3
3
  <%- partial('_partial/scripts/_ctrl') _%>
4
4
  <%- partial('_partial/head') _%>
5
5
  <body itemscope itemtype="http://schema.org/WebPage">
6
+ <!-- import body_begin begin-->
7
+ <%_ if (config.import && config.import.body_begin){ _%>
8
+ <%_ ([...config.import.body_begin]).forEach(function(item){ _%>
9
+ <%- item %>
10
+ <%_ }) _%>
11
+ <%_ } _%>
12
+ <!-- import body_begin end-->
13
+ <!-- Custom Files bodyBegin begin-->
14
+ <%- volantis_inject('bodyBegin') %>
15
+ <!-- Custom Files bodyBegin end-->
6
16
  <%- partial('_partial/header', null, {cache: false, path: path}) %>
7
17
  <div id="l_body">
8
18
  <%- partial('_partial/cover') %>
@@ -21,8 +31,15 @@
21
31
  <%- partial('_plugins/pjax/index') %>
22
32
  <% } %>
23
33
  </div>
24
- <!-- Custom Files bodyEnd begin-->
25
- <%- volantis_inject('bodyEnd') %>
26
- <!-- Custom Files bodyEnd end-->
34
+ <!-- import body_end begin-->
35
+ <%_ if (config.import && config.import.body_end){ _%>
36
+ <%_ ([...config.import.body_end]).forEach(function(item){ _%>
37
+ <%- item %>
38
+ <%_ }) _%>
39
+ <%_ } _%>
40
+ <!-- import body_end end-->
41
+ <!-- Custom Files bodyEnd begin-->
42
+ <%- volantis_inject('bodyEnd') %>
43
+ <!-- Custom Files bodyEnd end-->
27
44
  </body>
28
45
  </html>
package/layout/tag.ejs CHANGED
@@ -1,5 +1,5 @@
1
1
  <%- partial('_pre') %>
2
- <%
2
+ <%
3
3
  page.comments = false;
4
4
  if (!page.robots) {
5
5
  page.robots = 'noindex,follow';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hexo-theme-volantis",
3
- "version": "5.0.0-rc.9",
3
+ "version": "5.2.0",
4
4
  "description": "Elegant and powerful theme for Hexo.",
5
5
  "main": "package.json",
6
6
  "scripts": {
@@ -0,0 +1,43 @@
1
+ module.exports =(hexo) => {
2
+ try {
3
+ let config = hexo.config;
4
+ let themeConfig = hexo.theme.config;
5
+ if (!config.title) {
6
+ return `title 未配置!
7
+ 请在站点配置 _config.yml 中配置 title
8
+ see: https://hexo.io/zh-cn/docs/configuration
9
+ title not configured!
10
+ see: https://hexo.io/zh-cn/docs/configuration`
11
+ }
12
+ if (!config.description) {
13
+ return `description 未配置!
14
+ 请在站点配置 _config.yml 中配置 description
15
+ description主要用于SEO,告诉搜索引擎一个关于您站点的简单描述,通常建议在其中包含您网站的关键词。
16
+ see: https://hexo.io/zh-cn/docs/configuration
17
+ description not configured!
18
+ see: https://hexo.io/zh-cn/docs/configuration`
19
+ }
20
+ if (themeConfig?.search?.service===`google`||themeConfig?.search?.service===`algolia`||themeConfig?.search?.service===`azure`||themeConfig?.search?.service===`baidu`) {
21
+ return `原 google, algolia, azure, baidu 站内搜索 系祖传代码, 且文档丢失, 不便后续维护 在 5.0 版本被移除
22
+ The google, algolia, azure, baidu site search is ancestral code, and the document is lost, which is inconvenient for subsequent maintenance. It was removed in version 5.0
23
+ see: https://volantis.js.org/v5/theme-settings/#站内搜索`
24
+ }
25
+ if (`backstretch` in themeConfig?.plugins) {
26
+ return `jquery.backstretch 在 5.0 版本被移除, 被 parallax 替代
27
+ jquery.backstretch was removed in version 5.0, replaced by parallax
28
+ see: https://volantis.js.org/v5/theme-settings/#幻灯片背景-视差滚动效果`
29
+ }
30
+ if ("valinecount" in themeConfig?.article?.body?.top_meta||"valinecount" in themeConfig?.article?.body?.bottom_meta||"valinecount" in themeConfig?.article?.body?.meta_library) {
31
+ return `ValineCount 在 5.0 版本被移除
32
+ ValineCount has been removed in 5.0 version
33
+ see: https://volantis.js.org/v5/theme-settings/#文章布局配置`
34
+ }
35
+ if (themeConfig?.comments?.service=="valine"||themeConfig?.comments?.service=="minivaline") {
36
+ return `Valine 在 5.0 版本被移除
37
+ Valine has been removed in 5.0 version
38
+ see: https://volantis.js.org/v5/theme-settings/#选择评论系统`
39
+ }
40
+ } catch (error) {}
41
+ return true;
42
+ };
43
+
@@ -1,9 +1,18 @@
1
- 'use strict';
1
+ // 环境配置检查可以避免一些奇葩的报错
2
+
2
3
  const exec = require('child_process').exec;
3
4
  module.exports =(hexo) => {
4
5
  if (!hexo.checkEnvironment) {
5
6
  hexo.checkEnvironment=1;
6
7
  hexo.log.info(`Checking environment configuration...`);
8
+
9
+ // Checking configuration
10
+ let checkConfiguration = require('./check-configuration')(hexo);
11
+ if (checkConfiguration!==true) {
12
+ CheckConfError(hexo,checkConfiguration);
13
+ }
14
+
15
+ // Checking environment
7
16
  exec('node -v', (err, stdout, stderr) => {
8
17
  if (err) {
9
18
  CheckError(hexo,`node.js: ${err}`);
@@ -52,4 +61,14 @@ node.js: 16.x LTS ~ latest LTS
52
61
  npm: 8.x ~ latest LTS
53
62
  ============================================================`);
54
63
  throw new Error('环境配置检查失败!| Environment configuration check failed!');
64
+ }
65
+
66
+ function CheckConfError(hexo,msg) {
67
+ hexo.log.error(`
68
+ ============================================================
69
+ 配置文件检查失败!| Configuration check failed!
70
+ ============================================================
71
+ ${msg}
72
+ ============================================================`);
73
+ throw new Error('配置文件检查失败!| Configuration check failed!');
55
74
  }
@@ -1,5 +1,7 @@
1
1
  'use strict';
2
2
 
3
+ const { version } = require('../../../package.json');
4
+
3
5
  function isObject(item) {
4
6
  return item && typeof item === 'object' && !Array.isArray(item);
5
7
  }
@@ -85,4 +87,5 @@ module.exports = hexo => {
85
87
  }
86
88
  }
87
89
  volantis_static_cdn(hexo.theme.config,hexo);
90
+ hexo.theme.config.info.theme_version = version;
88
91
  };
@@ -1,4 +1,4 @@
1
- // hexo.renderStylus 渲染 Stylus 的工具函数
1
+ // hexo.renderStylus 渲染 Stylus 的工具函数
2
2
  // hexo.createUuid 创建 uuid
3
3
 
4
4
  const stylus = require("stylus");
@@ -9,9 +9,9 @@ hexo.extend.filter.register('after_post_render', function (data) {
9
9
  let yy = e.replace(/<h2.*?>.*?<\/h2>/, function (str) {
10
10
  if (flag) {
11
11
  flag = 0
12
- return str + `<div class="story post-story">`
12
+ return `<div class="story post-story">` + str
13
13
  } else {
14
- return `</div>` + str + `<div class="story post-story">`
14
+ return `</div><div class="story post-story">` + str
15
15
  }
16
16
  })
17
17
  mydata += yy
@@ -11,13 +11,15 @@ let points = {
11
11
  "darkVar",
12
12
  ],
13
13
  views: [
14
- "head",
14
+ "headBegin",
15
+ "headEnd",
15
16
  "header",
16
17
  "side",
17
18
  "topMeta",
18
19
  "bottomMeta",
19
20
  "footer",
20
21
  "postEnd",
22
+ "bodyBegin",
21
23
  "bodyEnd",
22
24
  ]
23
25
  }
@@ -10,7 +10,7 @@ hexo.extend.helper.register('generate_seo', function (theme, page) {
10
10
  }else{
11
11
  robots_content=theme.seo.robots.home_other_pages
12
12
  }
13
- } else if (hexo.is_archive()) {
13
+ } else if (hexo.is_archive()) {
14
14
  robots_content=theme.seo.robots.archive
15
15
  } else if (hexo.is_category()) {
16
16
  robots_content=theme.seo.robots.category
@@ -4,10 +4,8 @@ module.exports = (hexo, option) => {
4
4
  const blogposting = {
5
5
  "@context": "http://schema.org",
6
6
  "@type": "BlogPosting",
7
- headline: post.title,
8
- description: post.description || hexo.strip_html(post.excerpt),
9
- datePublished: post.date.toISOString(),
10
- dateModified: post.updated.toISOString(),
7
+ headline: post.title || post.seo_title,
8
+ description: post.description || hexo.strip_html(post.excerpt) || config.description,
11
9
  inLanguage: config.language,
12
10
  mainEntityOfPage: {
13
11
  "@type": "WebPage",
@@ -37,12 +35,26 @@ module.exports = (hexo, option) => {
37
35
 
38
36
  blogposting.wordCount = hexo.strip_html(post.excerpt).length;
39
37
 
38
+ if (post.date) {
39
+ blogposting.datePublished = post.date.toISOString();
40
+ }
41
+ if (post.updated) {
42
+ blogposting.dateModified = post.updated.toISOString();
43
+ }
40
44
  if (post.categories && post.categories.length) {
41
- blogposting.articleSection = post.categories.data[0].name;
45
+ if (post.categories.data) {
46
+ blogposting.articleSection = post.categories.data[0].name;
47
+ } else {
48
+ blogposting.articleSection = post.categories[0];
49
+ }
42
50
  }
43
51
 
44
52
  if (post.tags && post.tags.length) {
45
- blogposting.keywords = post.tags.map((tag) => tag.name).join(",");
53
+ if (post.tags.data) {
54
+ blogposting.keywords = post.tags.map((tag) => tag.name).join(",");
55
+ } else {
56
+ blogposting.keywords = post.tags.map((tag) => tag).join(",");
57
+ }
46
58
  }
47
59
  let image = post.headimg || "";
48
60
  if (image) {
@@ -119,7 +119,31 @@ module.exports = (hexo, option) => {
119
119
  position: 3,
120
120
  item: {
121
121
  "@id": config.url + config.root + page.path,
122
- name: page.title,
122
+ name: page.title || page.seo_title,
123
+ },
124
+ });
125
+ }
126
+
127
+ if (hexo.is_page()&&page.categories) {
128
+ let temp = "/"
129
+ for (let index = 0; index < page.categories.length; index++) {
130
+ const cat = page.categories[index];
131
+ temp = temp + cat + "/"
132
+ breadcrumb.itemListElement.push({
133
+ "@type": "ListItem",
134
+ position: 2,
135
+ item: {
136
+ "@id": config.url + config.root + config.category_dir + temp,
137
+ name: cat,
138
+ },
139
+ })
140
+ }
141
+ breadcrumb.itemListElement.push({
142
+ "@type": "ListItem",
143
+ position: 3,
144
+ item: {
145
+ "@id": config.url + config.root + page.path,
146
+ name: page.title || page.seo_title,
123
147
  },
124
148
  });
125
149
  }
@@ -24,15 +24,7 @@ function merge(target, source) {
24
24
  module.exports = function () {
25
25
  const hexo = this;
26
26
  const option = merge(config(hexo), hexo.theme.structured_data.data);
27
- const builder = [Organization, Person, BreadcrumbList];
28
-
29
- if (hexo.is_post()) {
30
- builder.push(BlogPosting);
31
- } else {
32
- builder.push(WebSite);
33
- }
34
-
27
+ const builder = [Organization, Person, BreadcrumbList, WebSite, BlogPosting];
35
28
  const jsonld = JSON.stringify(builder.map((f) => f(hexo, option)));
36
-
37
29
  return `<script type="application/ld+json">${jsonld}</script>`;
38
30
  };
@@ -17,7 +17,7 @@ function buidImgFancybox(content, group) {
17
17
  if(html.startsWith('<p>') && html.endsWith('</p>')) { // 去除无用的 p 标签包裹
18
18
  html=html.substring(0, html.length-4).substring(3);
19
19
  }
20
-
20
+
21
21
  let imageTags = html.includes('image-caption') ? 'image' : undefined;
22
22
  let imgList = html.match(/<img.*?>/g) || [];
23
23
  imgList.forEach(item => {