-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from FoxerLee/v0.9.1
V0.9.1 public
- Loading branch information
Showing
13 changed files
with
422 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,4 +21,9 @@ before_script: | |
|
||
script: | ||
- cd ../../ | ||
- hexo g | ||
- hexo g | ||
|
||
|
||
branches: | ||
only: | ||
- master |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -70,4 +70,8 @@ | |
</li> | ||
<% } %> | ||
</ul> | ||
|
||
<% if (theme.gitalk.enable) { %> | ||
<%- partial('_partials/gitalk') %> | ||
<% } %> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<div id="gitalk-container"></div> | ||
|
||
<script src="https://unpkg.com/gitalk/dist/gitalk.min.js"></script> | ||
<script src="/js/md5.js"></script> | ||
<script type="text/javascript"> | ||
var gitalk = new Gitalk({ | ||
clientID: '<%= theme.gitalk.ClientID %>', | ||
clientSecret: '<%= theme.gitalk.ClientSecret %>', | ||
repo: '<%= theme.gitalk.repo %>', | ||
owner: '<%= theme.gitalk.owner %>', | ||
admin: '<%= theme.gitalk.adminUser %>', | ||
id: md5(<%= theme.gitalk.ID %>), | ||
labels: '<%= theme.gitalk.labels %>'.split(',').filter(l => l), | ||
perPage: <%= theme.gitalk.perPage %>, | ||
pagerDirection: '<%= theme.gitalk.pagerDirection %>', | ||
createIssueManually: <%= theme.gitalk.createIssueManually %>, | ||
distractionFreeMode: <%= theme.gitalk.distractionFreeMode %> | ||
}) | ||
gitalk.render('gitalk-container') | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
|
||
hexo.on('generateBefore', function () { | ||
require('./replace').replace(hexo); | ||
require('./lazyLoad').lazyload(hexo); | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
'use strict'; | ||
|
||
module.exports.lazyload = function (hexo) { | ||
if (!hexo.theme.config.lazyload || !hexo.theme.config.lazyload.enable) { | ||
return; | ||
} | ||
if (hexo.theme.config.lazyload.onlypost) { | ||
hexo.extend.filter.register('after_post_render', require('./lazyProcess').processPost); | ||
} else { | ||
hexo.extend.filter.register('after_render:html', require('./lazyProcess').processSite); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
'use strict'; | ||
|
||
function lazyProcess(htmlContent) { | ||
let loadingImage = this.theme.config.lazyload.loadingImage; | ||
let className = 'lazyload'; | ||
return htmlContent.replace(/<img([^>]*)src="([^"]*)"([^>]*)>/gim, function (match, attrBegin, src, attrEnd) { | ||
if (!src || /class="(.*?)"/gi.test(match)) { | ||
return match; | ||
} | ||
return `<img ${attrBegin} class="${className}" data-src="${src}" src="${loadingImage}" ${attrEnd}>`; | ||
}); | ||
} | ||
|
||
module.exports.processPost = function(data) { | ||
data.content = lazyProcess.call(this, data.content); | ||
return data; | ||
}; | ||
|
||
module.exports.processSite = function (htmlContent) { | ||
return lazyProcess.call(this, htmlContent); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
/** | ||
* Note: configs in _data/temp.yml will replace configs in hexo.theme.config. | ||
*/ | ||
hexo.on('generateBefore', function () { | ||
if (hexo.locals.get) { | ||
var data = hexo.locals.get('data') // 获取_data文件夹下的内容 | ||
data && data.temp && (hexo.theme.config = data.temp) // 如果temp.yml 存在,就把内容替换掉主题的config | ||
} | ||
}) | ||
module.exports.replace = function (hexo) { | ||
if (hexo.locals.get) { | ||
var data = hexo.locals.get('data') // 获取_data文件夹下的内容 | ||
data && data.temp && (hexo.theme.config = data.temp) // 如果temp.yml 存在,就把内容替换掉主题的config | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
document.addEventListener("DOMContentLoaded", function() { | ||
var lazyloadImages = document.querySelectorAll("img.lazyload"); | ||
var lazyloadThrottleTimeout; | ||
|
||
function lazyload () { | ||
if(lazyloadThrottleTimeout) { | ||
clearTimeout(lazyloadThrottleTimeout); | ||
} | ||
|
||
lazyloadThrottleTimeout = setTimeout(function() { | ||
var scrollTop = window.pageYOffset; | ||
lazyloadImages.forEach(function(img) { | ||
if(img.offsetTop < (window.innerHeight + scrollTop)) { | ||
img.setAttribute('src', img.getAttribute('data-src')); | ||
img.classList.remove('lazyload'); | ||
} | ||
}); | ||
if(lazyloadImages.length == 0) { | ||
document.removeEventListener("scroll", lazyload); | ||
window.removeEventListener("resize", lazyload); | ||
window.removeEventListener("orientationChange", lazyload); | ||
} | ||
}, 20); | ||
} | ||
|
||
document.addEventListener("scroll", lazyload); | ||
window.addEventListener("resize", lazyload); | ||
window.addEventListener("orientationChange", lazyload); | ||
}); |
Oops, something went wrong.