'use strict'; const { url_for } = require('hexo-util'); function autodiscoveryInject(data) { const { config } = this; const { feed } = config; const { path, type } = feed; let autodiscoveryTag = ''; if (data.match(/type=['|"]?application\/(atom|rss)\+xml['|"]?/i) || feed.autodiscovery === false) return; if (typeof type === 'string') { autodiscoveryTag += `\n`; } else { type.forEach((feedType, i) => { autodiscoveryTag += `\n`; }); } return data.replace(/(?!<\/head>).+?<\/head>/s, str => str.replace('', `${autodiscoveryTag}`)); } module.exports = autodiscoveryInject;