Skip to content

Commit

Permalink
Merge pull request #1 from hexojs/master
Browse files Browse the repository at this point in the history
update
  • Loading branch information
shen-yu authored Aug 6, 2020
2 parents 3cf6b77 + c790e2c commit 05ed811
Show file tree
Hide file tree
Showing 197 changed files with 5,272 additions and 299 deletions.
8 changes: 5 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"version": "0.0.0",
"private": true,
"hexo": {
"version": "4.1.0"
"version": "4.2.0"
},
"scripts": {
"build": "hexo generate",
Expand All @@ -14,20 +14,22 @@
"hexo": "hexojs/hexo",
"hexo-clean-css": "^1.0.0",
"hexo-filter-nofollow": "^2.0.2",
"hexo-fs": "^3.1.0",
"hexo-generator-archive": "^1.0.0",
"hexo-generator-feed": "^2.0.0",
"hexo-generator-sitemap": "^2.0.0",
"hexo-renderer-marked": "^2.0.0",
"hexo-renderer-marked": "^3.0.0",
"hexo-renderer-pug": "^1.0.0",
"hexo-renderer-stylus": "^1.0.0",
"hexo-renderer-swig": "^1.1.0",
"hexo-server": "^1.0.0",
"hexo-uglify": "^1.0.0",
"image-size": "^0.8.3",
"lunr": "2.3.8",
"sharp": "^0.25.2"
},
"devDependencies": {
"eslint": "^6.0.1",
"eslint": "^7.0.0",
"eslint-config-hexo": "^4.0.0",
"husky": "^4.0.7",
"imagemin-lint-staged": "^0.4.0",
Expand Down
16 changes: 3 additions & 13 deletions scripts/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,19 +133,9 @@ hexo.extend.helper.register('lunr_index', data => {
this.field('name', {boost: 10});
this.field('tags', {boost: 50});
this.field('description');
this.ref('id');

data.concat().sort((a, b) => {
if (a.name > b.name) {
return 1;
} else if (b.name > a.name) {
return -1;
}
return 0;
}).forEach((item, i) => {
const object = Object.assign({}, { id: i }, item);
this.add(object);
});
this.ref('name');

data.forEach(this.add, this);
});

return JSON.stringify(index);
Expand Down
38 changes: 38 additions & 0 deletions scripts/validate.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/* global hexo */

'use strict';

const { join } = require('path');

const { listDir } = require('hexo-fs');
const { log } = hexo;
const sizeOf = require('image-size');

async function validateThemeThumbnail() {
let isValidationPassed = true;
const screenshotsPath = join(hexo.source_dir, 'themes/screenshots');
const screenshots = await listDir(screenshotsPath);

screenshots.forEach(filename => {
if (!filename.endsWith('.png')) {
log.fatal(`The theme thumbnail "${filename}" is not a png image.`);
isValidationPassed = false;
}

const screenshot = join(screenshotsPath, filename);

const { width, height } = sizeOf(screenshot);
if (width !== 800 || height !== 500) {
log.fatal(`The theme thumbnail "${filename}" is not sized in 800x500 (got ${width}x${height}).`);
isValidationPassed = false;
}
});

if (!isValidationPassed) {
throw new Error('Theme thumbnails validation failed');
} else {
log.info('Theme thumbnails validation completed');
}
}

hexo.extend.filter.register('before_exit', validateThemeThumbnail);
Loading

0 comments on commit 05ed811

Please sign in to comment.