diff --git a/lib/extend/injector.ts b/lib/extend/injector.ts index edb4a45094..0f341f519b 100644 --- a/lib/extend/injector.ts +++ b/lib/extend/injector.ts @@ -66,7 +66,14 @@ class Injector { } _injector(input: string, pattern: string | RegExp, flag: Entry, isBegin = true, currentType: string): string { - if (input.includes(`hexo injector ${flag}`)) return input; + if ( + (flag==='head_begin' && /\s*/.test(input)) || + (flag==='body_begin' && /\s*/.test(input)) || + (flag==='head_end' && /\s*<\/head>/.test(input)) || + (flag==='body_end' && /\s*<\/body>/.test(input)) + ) { + return input; + } const code = this.cache.apply(`${flag}-${currentType}-code`, () => { const content = currentType === 'default' ? this.getText(flag, 'default') : this.getText(flag, currentType) + this.getText(flag, 'default'); diff --git a/package.json b/package.json index 49e5ea44de..d481a697a9 100644 --- a/package.json +++ b/package.json @@ -66,16 +66,16 @@ "warehouse": "^5.0.1" }, "devDependencies": { - "0x": "^5.1.2", "@types/abbrev": "^1.1.3", "@types/bluebird": "^3.5.37", "@types/chai": "^4.3.11", "@types/js-yaml": "^4.0.9", - "@types/mocha": "^10.0.6", - "@types/node": "^20.16.10", + "@types/mocha": "^10.0.9", + "@types/node": "^20.17.6", "@types/nunjucks": "^3.2.2", "@types/sinon": "^17.0.3", "@types/text-table": "^0.2.4", + "0x": "^5.1.2", "c8": "^9.0.0", "chai": "^4.3.6", "cheerio": "0.22.0",