Skip to content

Commit

Permalink
feat: return before data.replace if no inject
Browse files Browse the repository at this point in the history
  • Loading branch information
SukkaW committed Jan 5, 2020
1 parent 044dad5 commit f44cdfd
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions lib/plugins/filter/after_render/injector.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,12 @@ function injectFilter(data, locals = { page: {} }) {
};

function injector(data, pattern, flag, isBegin = true) {
return data.replace(pattern, str => {
if (data.includes(`hexo injector ${flag}`)) return str;
const arr = _Injector.get(flag).filter(i => is(i.to)).map(i => i.value);

const arr = _Injector.get(flag).filter(i => is(i.to)).map(i => i.value);
if (arr.length) {
return data.replace(pattern, str => {
if (data.includes(`hexo injector ${flag}`)) return str;

if (arr.length) {
const code = arr.reduce((a, c) => a + c, '');

if (isBegin) {
Expand All @@ -59,10 +59,10 @@ function injectFilter(data, locals = { page: {} }) {
+ code
+ '<!-- hexo injector ' + flag + ' end -->'
+ str;
}
});
}

return str;
});
return data;
}

// Inject head_begin
Expand Down

0 comments on commit f44cdfd

Please sign in to comment.