1.0.4 • Published 6 years ago
hexo-deployer-aliyun-incr v1.0.4
hexo-deployer-aliyun-incr
Aliyun OSS incremental deployer plugin for Hexo.
Compare with the origin plugin,this one changes limit upload thread to 3.
Different with the origin one
The origin plugin , often occurs errors on uploading.
So i study it and make two change:
- After a lot of research,I think it is that one has no concurrent limit .So I add a limit of 3 to it.
- I add a md5 hash check function to verify if the file needed to upload again.
Installation
$ npm install hexo-deployer-aliyun-incr --save
Options
You can configure this plugin in _config.yml
.
# You can use this:
deploy:
type: aliyun
bucket: <yourBucketName>
region: <yourOSSregion>
accessKeyId: <yourAccessKeyId>
accessKeySecret: <yourAccessKeySecret>
Reset Md5Hash To UPLOAD ALL FILES
Just delete the alioss.old.uploaded.info
file to UPLOAD ALL FILES.
This file auto produced after upload.
Known Issues
Aliyun only finds index.html
in root. This is detail
So you must set full url in your hexo blog codes like /archives/index.html
except the root path.
An auto add /index.html method:
- First Create a oss_parse.js file under folder themes\next\source\js\src\
/**
* 增加,为处理在oss中 ,不自动调用相应目录的index.html问题
*/
$(function(){
$("a").each(function(index, element) {
var currHref = $(element).attr("href");
//console.log("href: "+currHref);
if(typeof(currHref) === "undefined"){//排除无链接的a标签
return true;
}else if(currHref.substring(0,7) === "http://" || currHref.substring(0,8) === "https://"){//排除已有完整路径的链接
return true;
}else if(currHref.substring(0, 1) === "#"){//排除页内导航链接
return true;
}
var preHref = "", endHref = "";
if(currHref.indexOf("#", 0) !== -1){//对有“#”的链接,将前后部分分别提取出来
preHref = currHref.split("#")[0];
endHref = "#" + currHref.split("#")[1];
}else{//处理没“#”的链接
preHref = currHref;
}
if(preHref.indexOf("/", 0) !== -1){//排除已指向站内具体文件的链接
var tmpHref = preHref.split("/");
if(tmpHref.length > 1 && tmpHref[tmpHref.length - 1].indexOf(".", 0) !== -1){
return true;
}
}
if(preHref.substr(preHref.length-1,1) !== "/"){//末尾先添上“/”
preHref = preHref + "/";
}
$(element).attr("href", preHref + "index.html" + endHref);
//console.log("modified: " + preHref + "index.html" + endHref);
});
});
- Modify the file at themes\next\layout_layout.swig,add code at the end of file ,before
</body>
{#
增加 为处理oss调用index.html问题
#}
<script src="{{ url_for(theme.js) }}/src/oss_parse.js?v={{ theme.version }}"></script>