Skip to content

Commit

Permalink
refactor: page ts拆分 & 递归js合并
Browse files Browse the repository at this point in the history
  • Loading branch information
zkz098 committed Jul 11, 2023
1 parent 2942ac6 commit 775961b
Show file tree
Hide file tree
Showing 31 changed files with 1,657 additions and 1,657 deletions.
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
如果你访问的仓库地址是**zkz098/hexo-theme-shokaX**,请转为访问最新地址: [theme-shoka-x/hexo-theme-shokaX](https://github.com/theme-shoka-x/hexo-theme-shokaX)

# hexo-theme-shokaX
[![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2Fzkz098%2Fhexo-theme-shokaX.svg?type=shield)](https://app.fossa.com/projects/git%2Bgithub.com%2Fzkz098%2Fhexo-theme-shokaX?ref=badge_shield)
![LICENSE]( https://img.shields.io/github/license/theme-shoka-x/hexo-theme-shokaX)
Expand Down
33 changes: 26 additions & 7 deletions scripts/generaters/script.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,22 @@
/* global hexo */
import env from '../../package.json'
import fs = require('hexo-fs')
import pathLib from 'node:path'

function findJsFile (path:string):string[] {
let result:string[] = []
fs.readdirSync(path).forEach((item) => {
if (item.indexOf('player') || item.indexOf('fireworks')) {
return
}
if (item.indexOf('.js') === -1) {
result = result.concat(findJsFile(pathLib.join(path, item)))
} else {
result.push(pathLib.join(path, item))
}
})
return result
}
hexo.extend.generator.register('script', function (locals) {
const log = hexo.log || console.log
const config = hexo.config
Expand Down Expand Up @@ -59,14 +74,18 @@ hexo.extend.generator.register('script', function (locals) {
siteConfig.audio = theme.audio
}

let text = '';
let text = ''
let path = ''
if (fs.existsSync('themes/shokaX/source/js/_app/library/dom.js')) {
path = 'themes/shokaX/source/js/_app'
} else {
path = 'node_modules/hexo-theme-shokax/source/js/_app'
}

['library', 'global', 'page', 'vue', 'components'].forEach(function (item) {
if (fs.existsSync(`themes/shokaX/source/js/_app/${item}.js`)) {
text += fs.readFileSync(`themes/shokaX/source/js/_app/${item}.js`).toString()
} else {
text += fs.readFileSync(`node_modules/hexo-theme-shokax/source/js/_app/${item}.js`).toString()
}
const files = findJsFile(path)

files.forEach(function (item) {
text += fs.readFileSync(item).toString()
})
if (!theme.experiments?.noPlayer) {
if (fs.existsSync('themes/shokaX/source/js/_app/player.js')) {
Expand Down
6 changes: 3 additions & 3 deletions scripts/plugin/check.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ hexo.on('generateBefore', function () {
if (!hexo.config.autoprefixer || !hexo.config.markdown) {
findProblem = true
hexo.log.error(`[SXEC 102] Critical rendering plugins are missing or incorrectly configured.
Some features will be disabled or render incorrectly`)
Some features will be disabled or render incorrectly`)
}
if (parseInt(process.version.match(/\d{2,3}/)[0]) < 18) {
findProblem = true
Expand All @@ -28,7 +28,7 @@ hexo.on('generateBefore', function () {
hexo.on('generateAfter', function () {
if (findProblem) {
hexo.log.warn(`The environment check found some problems that can lead to rendering errors, effect errors,
performance degradation, not working correctly, etc`)
hexo.log.warn('ShokaX has output them into console, read them to get more information. You can search error code in docs(For example, SXEC 1)')
performance degradation, not working correctly, etc`)
hexo.log.warn('ShokaX has output them into console, read them to get more information. You can search error code in docs(For example, SXEC 101)')
}
})
File renamed without changes.

0 comments on commit 775961b

Please sign in to comment.