Skip to content

Commit

Permalink
revise
Browse files Browse the repository at this point in the history
  • Loading branch information
ReverseSacle committed Oct 2, 2023
1 parent c782098 commit e3934eb
Show file tree
Hide file tree
Showing 10 changed files with 101 additions and 54 deletions.
86 changes: 66 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,28 +106,74 @@
enable: true
template: "themes/shoka/layout/_alternate/json.ejs"
output: "feed.json"

minify:
html:
enable: true
exclude: # 排除 hexo-feed 用到的模板文件
- '**/json.ejs'
- '**/atom.ejs'
- '**/rss.ejs'
css:
enable: true
exclude:
- '**/*.min.css'
js:
enable: true
mangle:
toplevel: true
output:
compress:
exclude:
- '**/*.min.js'
```
(**Optional**)Using Gulp for cleaning Js, CSS and HTML.
```bash
# install gulp
npm install gulp --save-dev

# install gulp plugins
npm install gulp-clean-css gulp-html-minifier-terser gulp-htmlclean gulp-terser --save-dev
```

Move to your hexo root dir, and create a new file named `gulp.js`,add following content.

```javascript
// Dependience
var gulp = require('gulp');
var cleanCSS = require('gulp-clean-css');
var htmlmin = require('gulp-html-minifier-terser');
var htmlclean = require('gulp-htmlclean');
var terser = require('gulp-terser');

// Compress js
gulp.task('compress', () =>
gulp.src(['./public/**/*.js', '!./public/**/*.min.js'])
.pipe(terser())
.pipe(gulp.dest('./public'))
);

// Compress css
gulp.task('minify-css', () => {
return gulp.src(['./public/**/*.css'])
.pipe(cleanCSS({
compatibility: 'ie11'
}))
.pipe(gulp.dest('./public'));
});

// Compress html
gulp.task('minify-html', () => {
return gulp.src('./public/**/*.html','!./public/**/json.ejs','!./public/**/atom.ejs','!./public/**/rss.ejs')
.pipe(htmlclean())
.pipe(htmlmin({
removeComments: true, // Delete html comments
collapseWhitespace: true, // Compress html
collapseBooleanAttributes: true,
// Ignore the value of bool type,
// example:<input checked="true"/> ==> <input />
removeEmptyAttributes: true,
// Delete all the space value of attribute,
// example:<input id="" /> ==> <input />
removeScriptTypeAttributes: true,
// Delete the attribute type="text/javascript" in lable <script>
removeStyleLinkTypeAttributes: true,
// Delete the attribute type="text/css" in <style> and <link>
minifyJS: true, // Compress JS
minifyCSS: true, // Compress CSS
minifyURLs: true // Compress URL
}))
.pipe(gulp.dest('./public'))
});

// Task command for using gulp command
gulp.task('default', gulp.parallel(
'compress', 'minify-css', 'minify-html'
));
```

## Modification

+ Delete `SEO` setting
Expand Down
11 changes: 4 additions & 7 deletions _config.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Alternate site name
alternate: Yume Shoka
alternate: Hexo Shoka

open_graph:
#twitter_id:
Expand Down Expand Up @@ -29,12 +29,12 @@ darkmode: false

# By default the page will automatically scroll to the last viewed position
# if `false`, automatic positioning will be turned off
auto_scroll: true
auto_scroll: false

# Whether to show the loading cat
loader:
start: true # When entering the page
switch: true # When switching to another page
switch: false # When switching to another page

font:
enable: true
Expand Down Expand Up @@ -144,7 +144,7 @@ post:
# Reward (Donate)
reward:
# If true, reward will be displayed in every article by default.
enable: true
enable: false
account:
wechatpay: /wechatpay.png
alipay: /alipay.png
Expand Down Expand Up @@ -215,9 +215,6 @@ search:
hits:
per_page: 10

# Dependencies: https://github.com/amehime/hexo-renderer-multi-markdown-it
pangu: false

# Quicklink Support
# For more information: https://github.com/GoogleChromeLabs/quicklink
quicklink:
Expand Down
19 changes: 14 additions & 5 deletions _images.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
- 6833939bly1giciryrr3rj20zk0m8nhk.jpg
- 6833939bly1gicis081o9j20zk0m8dmr.jpg
- 6833939bly1gicis3attqj20zk0m8k7l.jpg
- 6833939bly1giciszlczyj20zk0m816d.jpg
- 6833939bly1gicit31ffoj20zk0m8naf.jpg
- https://cdn.jsdelivr.net/gh/ReverseSacle/Gallery@latest/covers/acg01.webp
- https://cdn.jsdelivr.net/gh/ReverseSacle/Gallery@latest/covers/acg02.webp
- https://cdn.jsdelivr.net/gh/ReverseSacle/Gallery@latest/covers/acg03.webp
- https://cdn.jsdelivr.net/gh/ReverseSacle/Gallery@latest/covers/acg04.webp
- https://cdn.jsdelivr.net/gh/ReverseSacle/Gallery@latest/covers/acg05.webp
- https://cdn.jsdelivr.net/gh/ReverseSacle/Gallery@latest/covers/acg06.webp
- https://cdn.jsdelivr.net/gh/ReverseSacle/Gallery@latest/covers/acg07.webp
- https://cdn.jsdelivr.net/gh/ReverseSacle/Gallery@latest/covers/acg08.webp
- https://cdn.jsdelivr.net/gh/ReverseSacle/Gallery@latest/covers/acg09.webp
- https://cdn.jsdelivr.net/gh/ReverseSacle/Gallery@latest/covers/acg10.webp
- https://cdn.jsdelivr.net/gh/ReverseSacle/Gallery@latest/covers/acg11.webp
- https://cdn.jsdelivr.net/gh/ReverseSacle/Gallery@latest/covers/acg12.webp
- https://cdn.jsdelivr.net/gh/ReverseSacle/Gallery@latest/covers/acg13.webp
- https://cdn.jsdelivr.net/gh/ReverseSacle/Gallery@latest/covers/acg14.webp
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "hexo-theme-shoka",
"version": "0.2.5",
"version": "0.3.0",
"description": "",
"author": "Ruri Shimotsuki && ReverseSacle",
"license": "MIT",
Expand Down
16 changes: 7 additions & 9 deletions scripts/filters/locals.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,13 @@ hexo.extend.filter.register('template_locals', function(locals) {
const { __, theme } = locals;
const { i18n } = hexo.theme;

var pangu = theme.pangu ? require('pangu') : {
// data => {}
spacing: function(data) { return data; }
};

// data => {}
var pangu = { spacing: function(data) { return data; } };
// Language & Config
locals.alternate = theme.alternate;

locals.title = pangu.spacing(__('title') !== 'title' ? __('title') : config.title);
locals.subtitle = pangu.spacing(__('subtitle') !== 'subtitle' ? __('subtitle') : config.subtitle);
locals.subtitle = pangu.spacing(__('subtitle') !== 'subtitle' ? __('subtitle') : config.subtitle);
locals.author = __('author') !== 'author' ? __('author') : config.author;
locals.description = pangu.spacing(__('description') !== 'description' ? __('description') : config.description);
locals.languages = [...i18n.languages];
Expand All @@ -42,9 +40,9 @@ hexo.extend.filter.register('template_locals', function(locals) {
if (locals.page.categories) {
// (cat) => {}
locals.page.categories.map(function(cat) {
if(cat.name) {
cat.name = locals.page.lastcat = pangu.spacing(cat.name);
}
if(cat.name) {
cat.name = locals.page.lastcat = pangu.spacing(cat.name);
}
return cat;
})
}
Expand Down
4 changes: 2 additions & 2 deletions scripts/helpers/engine.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
const { htmlTag, url_for } = require('hexo-util');
const url = require('url');
const crypto = require('crypto');
const fs = require('fs');
const path = require('path');
//const fs = require('fs');
//const path = require('path');

const randomServer = parseInt(Math.random()*4,10)+1;

Expand Down
7 changes: 2 additions & 5 deletions scripts/helpers/list_categories.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,8 @@ hexo.extend.helper.register('_categories', function() {
let categories = hexo.site.categories;
if (!categories || !categories.length) return '';

var pangu = hexo.theme.pangu ? require('pangu') : {
// data => {}
spacing: function(data) { return data; }
};

// data => {}
var pangu = { spacing: function(data) { return data; } };
let result = {};

// (cat, i) => {}
Expand Down
8 changes: 4 additions & 4 deletions scripts/renderer/njk.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,8 @@
const nunjucks = require('nunjucks');
const path = require('path');

const pangu = require('pangu') || {
// data => {}
spacing: function(data) { return data; }
};
// data => {}
const pangu = { spacing: function(data) { return data; } };

function njkCompile(data) {
const templateDir = path.dirname(data.path);
Expand All @@ -23,13 +21,15 @@ function njkCompile(data) {
}
return '""';
});

// dictionary => {}
env.addFilter('pangu', function(dictionary) {
if (typeof dictionary !== 'undefined' && dictionary !== null) {
return pangu.spacing(dictionary);
}
return '""';
});

return nunjucks.compile(data.text, env, data.path);
}

Expand Down
Binary file modified source/images/avatar.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion source/js/_app/pjax.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,4 +127,4 @@ const siteInit = function() {

window.addEventListener('DOMContentLoaded', siteInit);

console.log('%c Theme.Shoka v' + CONFIG.version + ' %c https://shoka.lostyu.me/ ', 'color: white; background: #e9546b; padding:5px 0;', 'padding:4px;border:1px solid #e9546b;');
console.log('%c Theme.Shoka.Derived v' + CONFIG.version + ' ', 'color: white; background: #e9546b; padding:5px 0;');

0 comments on commit e3934eb

Please sign in to comment.