diff --git a/_config.yml b/_config.yml index d804b75..cd65f3b 100644 --- a/_config.yml +++ b/_config.yml @@ -461,6 +461,8 @@ index_with_subtitle: false # Automatically add external URL with Base64 encrypt & decrypt. exturl: false +# If true, an icon will be attached to each external URL +exturl_icon: true # Google Webmaster tools verification. # See: https://developers.google.com/search diff --git a/scripts/filters/post.js b/scripts/filters/post.js index d40cef2..87e7026 100644 --- a/scripts/filters/post.js +++ b/scripts/filters/post.js @@ -13,6 +13,8 @@ hexo.extend.filter.register('after_post_render', data => { } if (theme.exturl) { const siteHost = parse(config.url).hostname || config.url; + // External URL icon + const exturlIcon = theme.exturl_icon ? '' : ''; data.content = data.content.replace(/]* href="([^"]+)"[^>]*>([^<]+)<\/a>/img, (match, href, html) => { // Exit if the href attribute doesn't exists. if (!href) return match; @@ -23,9 +25,9 @@ hexo.extend.filter.register('after_post_render', data => { // Return encrypted URL with title. const title = match.match(/title="([^"]+)"/); - if (title) return `${html}`; + if (title) return `${html}${exturlIcon}`; - return `${html}`; + return `${html}${exturlIcon}`; }); }