hexo-theme-shokax
Advanced tools
Comparing version 0.1.9 to 0.2.0-rc1
{ | ||
"name": "hexo-theme-shokax", | ||
"version": "0.1.9", | ||
"version": "0.2.0-rc1", | ||
"description": "a hexo theme based on shoka", | ||
@@ -22,6 +22,6 @@ "main": "index.js", | ||
"@types/lozad": "^1.16.1", | ||
"@types/node": "^18.13.0", | ||
"@types/node": "^18.14.1", | ||
"@types/shelljs": "^0.8.11", | ||
"@typescript-eslint/eslint-plugin": "^5.51.0", | ||
"@typescript-eslint/parser": "^5.51.0", | ||
"@typescript-eslint/eslint-plugin": "^5.53.0", | ||
"@typescript-eslint/parser": "^5.53.0", | ||
"@vuepress/client": "2.0.0-beta.60", | ||
@@ -34,6 +34,8 @@ "eslint": "^8.34.0", | ||
"eslint-plugin-vue": "^9.9.0", | ||
"hexo-fs": "^4.1.1", | ||
"hexo-util": "^3.0.1", | ||
"typescript": "^4.9.5", | ||
"vue": "^3.2.47", | ||
"vuepress": "2.0.0-beta.60", | ||
"vuepress-plugin-sitemap2": "2.0.0-beta.180" | ||
"vuepress-plugin-sitemap2": "2.0.0-beta.181" | ||
}, | ||
@@ -40,0 +42,0 @@ "dependencies": { |
@@ -10,3 +10,2 @@ # hexo-theme-shokaX | ||
诞生原因是目前shoka已经两年没有更新了,积压了大量BUG和功能请求。\ | ||
`0.0.2-alpha2`开始,`lantern`和`qweather`已迁移为插件 | ||
@@ -43,3 +42,3 @@ shokaX的社区资源导航和插件仓库为[awesome-shokaX](https://github.com/zkz098/awesome-shokaX) | ||
``` | ||
[点此](https://docs.kaitaku.xyz/guide/#%E9%85%8D%E7%BD%AE%E4%B8%BB%E9%A2%98)以进行下一步配置([国内加速源](https://www.kaitaku.xyz/webbuild/shokaX/)) | ||
[点此](https://docs.kaitaku.xyz/guide/#%E9%85%8D%E7%BD%AE%E4%B8%BB%E9%A2%98)以进行下一步配置 | ||
@@ -76,12 +75,6 @@ github仓库建议通过右边的 releases 下载,步骤为: | ||
## 贡献者 | ||
shokaX的贡献者包括以非代码形式进行贡献的开发者(例如社区教程、想法分享、DEBUG等)和以代码形式进行贡献的开发者 | ||
## 开发者们 | ||
[![](https://contributors-img.web.app/image?repo=zkz098/hexo-theme-shokaX)](https://github.com/zkz098/hexo-theme-shokaX/graphs/contributors) | ||
| 名称 | 站点 | | ||
|:----------------------------------------|:---------------------------| | ||
| Lavender | https://www.lavenderdh.cn/ | | ||
| AdminZhang | https://www.a9-9.top/ | | ||
| [D-Sketon](https://github.com/D-Sketon) | https://d-sketon.top/ | | ||
## 特别鸣谢 | ||
[<img src="https://resources.jetbrains.com/storage/products/company/brand/logos/jb_beam.png" width="25%">](https://jb.gg/OpenSourceSupport) |
@@ -0,1 +1,2 @@ | ||
/* global hexo */ | ||
'use strict' | ||
@@ -5,16 +6,11 @@ | ||
const { config } = hexo | ||
const theme = hexo.theme.config | ||
data.content = data.content.replace(/(<img[^>]*) src=/img, '$1 data-src=') | ||
const url = require('url') | ||
// eslint-disable-next-line n/no-deprecated-api | ||
const siteHost = url.parse(config.url).hostname || config.url | ||
const siteHost = new URL(config.url).hostname || config.url | ||
data.content = data.content.replace(/<a[^>]* href="([^"]+)"[^>]*>([^<]*)<\/a>/img, (match, href, html) => { | ||
// Exit if the href attribute doesn't exists. | ||
if (!href) return match | ||
// Exit if the url has same host with `config.url`, which means it's an internal link. | ||
// eslint-disable-next-line n/no-deprecated-api | ||
const link = url.parse(href) | ||
const link = new URL(href, config.url) | ||
if (!link.protocol || link.hostname === siteHost) return match | ||
@@ -21,0 +17,0 @@ |
@@ -17,3 +17,2 @@ 'use strict' | ||
if (data.languages) { | ||
const { language } = hexo.config | ||
const { i18n } = hexo.theme | ||
@@ -20,0 +19,0 @@ |
@@ -7,3 +7,2 @@ /* global hexo */ | ||
hexo.extend.generator.register('images', function (locals) { | ||
const config = hexo.config | ||
const theme = hexo.theme.config | ||
@@ -10,0 +9,0 @@ const dir = 'source/_data/' + theme.assets + '/' |
@@ -17,3 +17,2 @@ /* global hexo */ | ||
const config = hexo.config | ||
const theme = hexo.theme.config | ||
const sticky = locals.posts.find({ sticky: true }).sort(config.index_generator.order_by) | ||
@@ -73,5 +72,5 @@ const posts = locals.posts.find({ sticky: { $exists: false } }).sort(config.index_generator.order_by) | ||
if (pl > 0) { | ||
// eslint-disable-next-line array-callback-return | ||
// TODO 需要测试 | ||
cat.subs.push.apply(cat.subs, cat.posts.sort({ title: 1 }).filter(function (item, i) { | ||
if (item.categories.last()._id === cat._id) { return true } | ||
return item.categories.last()._id === cat._id | ||
}).limit(pl).toArray()) | ||
@@ -78,0 +77,0 @@ } |
@@ -6,6 +6,4 @@ /* global hexo */ | ||
const { htmlTag, url_for } = require('hexo-util') | ||
const url = require('url') | ||
const crypto = require('crypto') | ||
const randomServer = parseInt(Math.random() * 4, 10) + 1 | ||
const randomServer = parseInt(String(Math.random() * 4), 10) + 1 | ||
@@ -57,11 +55,13 @@ const randomBG = function (count = 1, image_server = null, image_list = []) { | ||
// 注册hexo主题中的URL帮助方法 | ||
hexo.extend.helper.register('_url', function (path, text, options = {}) { | ||
// 如果未提供URL路径,则返回 | ||
if (!path) { return } | ||
// 获取hexo配置和URL路径信息 | ||
const { config } = this | ||
// eslint-disable-next-line n/no-deprecated-api | ||
const data = url.parse(path) | ||
// eslint-disable-next-line n/no-deprecated-api | ||
const siteHost = url.parse(config.url).hostname || config.url | ||
const data = new URL(path, hexo.config.url) | ||
const siteHost = new URL(config.url).hostname || config.url | ||
// 获取主题配置 | ||
const theme = hexo.theme.config | ||
@@ -72,6 +72,7 @@ let exturl = '' | ||
// If `exturl` enabled, set spanned links only on external links. | ||
// 如果启用了 `exturl`,则只为外部链接设置spanned链接。 | ||
if (theme.exturl && data.protocol && data.hostname !== siteHost) { | ||
tag = 'span' | ||
exturl = 'exturl' | ||
// 编码URL字符串,并将其存储在数据属性中。 | ||
const encoded = Buffer.from(path).toString('base64') | ||
@@ -86,4 +87,4 @@ attrs = { | ||
/** | ||
* If option have `class` attribute, add it to | ||
* 'exturl' class if `exturl` option enabled. | ||
* 如果选项包含 `class` 属性,则将其添加到 `exturl` 类中(如果启用了 `exturl` 选项)。 | ||
* 否则,将其添加到属性集中。 | ||
*/ | ||
@@ -101,3 +102,3 @@ if (exturl !== '' && key === 'class') { | ||
// If it's external link, rewrite attributes. | ||
// 如果是外部链接,则重写属性 | ||
if (data.protocol && data.hostname !== siteHost) { | ||
@@ -107,7 +108,7 @@ attrs.external = null | ||
if (!theme.exturl) { | ||
// Only for simple link need to rewrite/add attributes. | ||
// 仅需要为简单链接重写/添加属性。 | ||
attrs.rel = 'noopener' | ||
attrs.target = '_blank' | ||
} else { | ||
// Remove rel attributes for `exturl` in main menu. | ||
// 在主菜单中移除 `exturl` 的 rel 属性。 | ||
attrs.rel = null | ||
@@ -117,2 +118,3 @@ } | ||
// 返回HTML标记字符串 | ||
return htmlTag(tag, attrs, decodeURI(text), false) | ||
@@ -133,3 +135,3 @@ }) | ||
hexo.extend.helper.register('_cover', function (item, num) { | ||
const { statics, js, image_server, image_list } = hexo.theme.config | ||
const { image_server, image_list } = hexo.theme.config | ||
@@ -145,16 +147,13 @@ if (item.cover) { | ||
// TODO 此函数已被废弃 | ||
hexo.extend.helper.register('_md5', function (path) { | ||
const str = url_for.call(this, path) | ||
str.replace('index.html', '') | ||
return crypto.createHash('md5').update(str).digest('hex') | ||
}) | ||
// 注册hexo主题的永久链接帮助方法 | ||
hexo.extend.helper.register('_permapath', function (str) { | ||
// https://support.google.com/webmasters/answer/139066 | ||
// 获取hexo的永久链接配置 | ||
const { permalink } = hexo.config | ||
// 将输入字符串中的'index.html'替换为空字符串 | ||
let url = str.replace(/index\.html$/, '') | ||
// 如果永久链接不以'.html'结尾,将输入字符串中的'.html'替换为空字符串 | ||
if (!permalink.endsWith('.html')) { | ||
url = url.replace(/\.html$/, '') | ||
} | ||
// 返回处理后的URL字符串 | ||
return url | ||
@@ -170,5 +169,9 @@ }) | ||
*/ | ||
// 注册hexo主题的国际化路径帮助方法 | ||
hexo.extend.helper.register('i18n_path', function (language) { | ||
// 获取当前页面的path和lang | ||
const { path, lang } = this.page | ||
// 如果path以lang开头,则截取掉lang部分,作为基础路径 | ||
const base = path.startsWith(lang) ? path.slice(lang.length + 1) : path | ||
// 通过调用url_for方法,生成国际化路径 | ||
return url_for.call(this, `${this.languages.indexOf(language) === 0 ? '' : '/' + language}/${base}`) | ||
@@ -180,4 +183,7 @@ }) | ||
*/ | ||
// 注册hexo主题的语言名称帮助方法 | ||
hexo.extend.helper.register('language_name', function (language) { | ||
// 从主题配置中获取指定语言的名称 | ||
const name = hexo.theme.i18n.__(language)('name') | ||
// 如果名称为默认值'name',则返回语言代码,否则返回语言名称 | ||
return name === 'name' ? language : name | ||
@@ -187,2 +193,5 @@ }) | ||
hexo.extend.helper.register('random_color', function () { | ||
/** | ||
@type {number[]} | ||
*/ | ||
const arr = [] | ||
@@ -189,0 +198,0 @@ for (let i = 0; i < 3; i++) { |
const statics = CONFIG.statics.indexOf('//') > 0 ? CONFIG.statics : CONFIG.root; | ||
const scrollAction = { x: undefined, y: undefined }; | ||
const scrollAction = { x: 0, y: 0 }; | ||
let diffY = 0; | ||
@@ -56,3 +56,3 @@ let originTitle, titleTime; | ||
const Loader = { | ||
timer: null, | ||
timer: undefined, | ||
lock: false, | ||
@@ -59,0 +59,0 @@ show: function () { |
@@ -234,3 +234,3 @@ let NOWPLAYING = null; | ||
if (item.el) { | ||
return; | ||
return null; | ||
} | ||
@@ -324,3 +324,3 @@ const id = 'list-' + t.player._id + '-' + item.group; | ||
}; | ||
let option = { | ||
const option = { | ||
type: 'audio', | ||
@@ -350,3 +350,3 @@ mode: 'random', | ||
}; | ||
let utils = { | ||
const utils = { | ||
random: function (len) { | ||
@@ -353,0 +353,0 @@ return Math.floor((Math.random() * len)); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
5188
549646
24
77