Closed luyuhuang closed 1 year ago
并且,为什么不直接使用注入器呢?这样就不需要用正则替换了。
And, why not just use the injector? This way you don't need to use regex.
const url_for = hexo.extend.helper.get('url_for').bind(hexo);
hexo.extend.injector.register('head_end', function() {
return `<link rel="sitemap" type="application/xml" title="Sitemap" href="${url_for(config.path)}">`;
});
new PR is pushing
according to https://github.com/hexojs/hexo/commits/master/lib/extend/injector.js, injector
was brought up in 2020.
related code of these two plugins was written in 2019.
thanks
参照 hexojs/hexo-generator-feed 的做法
Refer to hexojs/hexo-generator-feed
https://github.com/hexojs/hexo-generator-feed/blob/71913f027b4f9f8d030b0e29e8dea39e741a5b83/lib/autodiscovery.js#L23
这一行
this line
https://github.com/hexojs/hexo-generator-sitemap/blob/ff13ae65bd7c9191e62b6211b0134462af532820/lib/rel.js#L12
应该是这样才对:
should be written like this: