Skip to content

Commit

Permalink
Supported Stylus and change cache validation
Browse files Browse the repository at this point in the history
  • Loading branch information
tea3 authored Nov 2, 2017
1 parent 3aa40ff commit 5032e13
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 3 deletions.
1 change: 1 addition & 0 deletions lib/cache.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ function createCacheFile(inPath, hexoConfig, inPostPath , inDate , inEyeCatchIma
//---------------------------------------
module.exports.getCache = function(post, hexoConfig){
var result = null;

if( existsOption(hexoConfig) && fs.existsSync(getCachePath(hexoConfig)) && !hexoConfig.generator_amp.isCacheUpdate ){
if(!read_cacheData){
// console.log("\u001b[31mrefreshed cache: \u001b[0m" + post.path);
Expand Down
1 change: 0 additions & 1 deletion lib/filter/write-cache.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ var cache = require('../cache.js');
module.exports.write_cache = function(result){
if(result.tempData.isCacheUse)return Promise.resolve(result);
return new Promise(function(resolve , reject){

cache.saveCache_amp(result.post, result.data , result.config);

// process.stdout.write('[hexo-generator-amp] Plugin is currently writing the cache now ... \r');
Expand Down
3 changes: 1 addition & 2 deletions lib/settingsUpdate.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ module.exports.chkUpdate = function(config) {
settingsStr += tmplPath;
}
if(fs.existsSync( pobj.cssFilePath )){
var cssStr = fs.readFileSync( pobj.cssFilePath , "utf-8");
settingsStr += cssStr;
settingsStr += pobj.cssTxt;
}
var shash = hasha(settingsStr , {algorithm: 'md5'} );
return shash;
Expand Down
12 changes: 12 additions & 0 deletions lib/templatePath.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
'use strict';
var fs = require('fs');
var sass = require('node-sass');
var stylus = require('stylus');
var nib = require('nib');
var lg = require('./log.js');
var compiler = require('./compileTemplate');
var pathFn = require('path');
Expand Down Expand Up @@ -58,6 +60,13 @@ module.exports.getPath = function(inConfig){
})
.css
.toString();
} else if( isStylusPath(cssFilePath)){
var stylusData = fs.readFileSync(cssFilePath, 'utf8');
cssTxt = stylus(stylusData)
.use(nib())
.set('include css', true)
.set('filename', cssFilePath)
.render();
} else {
cssTxt = fs.readFileSync(cssFilePath, 'utf8');
}
Expand Down Expand Up @@ -153,3 +162,6 @@ module.exports.getPath = function(inConfig){
function isScssPath (path) {
return /\.scss$/.test(path);
}
function isStylusPath (path) {
return /\.styl$/.test(path);
}

0 comments on commit 5032e13

Please sign in to comment.