fix(layout): no external links on anchor links

This commit is contained in:
ppoffice 2019-12-20 18:33:15 -05:00
parent bdaab0f8fd
commit ca1e73a4cf
7 changed files with 15 additions and 12 deletions

View File

@ -11,8 +11,8 @@
</a>
<p class="is-size-7">
&copy; <%= date(new Date(), 'YYYY') %> <%= author || title %>&nbsp;
Powered by <a href="https://hexo.io/" target="_blank">Hexo</a> & <a
href="https://github.com/ppoffice/hexo-theme-icarus" target="_blank">Icarus</a>
Powered by <a href="https://hexo.io/" target="_blank" rel="noopener">Hexo</a> & <a
href="https://github.com/ppoffice/hexo-theme-icarus" target="_blank" rel="noopener">Icarus</a>
<% if (busuanzi) { %>
<br>
<span id="busuanzi_container_site_uv">
@ -27,7 +27,7 @@
<% for (let name in links) {
let link = links[name]; %>
<p class="control">
<a class="button is-white <%= typeof(link) !== 'string' ? 'is-large' : '' %>" target="_blank" title="<%= name %>" href="<%= url_for(typeof(link) === 'string' ? link : link.url) %>">
<a class="button is-white <%= typeof(link) !== 'string' ? 'is-large' : '' %>" target="_blank" rel="noopener" title="<%= name %>" href="<%= url_for(typeof(link) === 'string' ? link : link.url) %>">
<% if (typeof(link) === 'string') { %>
<%= name %>
<% } else { %>

View File

@ -22,7 +22,7 @@
<% if (Object.keys(links).length) { %>
<% for (let name in links) {
let link = links[name]; %>
<a class="navbar-item" target="_blank" title="<%= name %>" href="<%= url_for(typeof(link) === 'string' ? link : link.url) %>">
<a class="navbar-item" target="_blank" rel="noopener" title="<%= name %>" href="<%= url_for(typeof(link) === 'string' ? link : link.url) %>">
<% if (typeof(link) === 'string') { %>
<%= name %>
<% } else { %>

View File

@ -1,6 +1,6 @@
<% const url = get_config_from_obj(service, 'url');
if (url) { %>
<a class="button is-danger donate" href="<%= url_for(url) %>" target="_blank">
<a class="button is-danger donate" href="<%= url_for(url) %>" target="_blank" rel="noopener">
<span class="icon is-small">
<i class="fab fa-patreon"></i>
</span>

View File

@ -8,7 +8,7 @@
</span>
<span><%= __('donate.' + type) %></span>
</a>
<form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_blank" id="paypal-donate-form">
<form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_blank" rel="noopener" id="paypal-donate-form">
<input type="hidden" name="cmd" value="_donations" />
<input type="hidden" name="business" value="<%= business %>" />
<input type="hidden" name="currency_code" value="<%= currency_code %>" />

View File

@ -7,7 +7,7 @@
<ul class="menu-list">
<% for (let i in links) { %>
<li>
<a class="level is-mobile" href="<%- links[i] %>" target="_blank">
<a class="level is-mobile" href="<%- links[i] %>" target="_blank" rel="noopener">
<span class="level-left">
<span class="level-item"><%= i %></span>
</span>

View File

@ -77,7 +77,7 @@
</nav>
<% if (widget.follow_link) { %>
<div class="level">
<a class="level-item button is-link is-rounded" href="<%= url_for(widget.follow_link) %>" target="_blank">
<a class="level-item button is-link is-rounded" href="<%= url_for(widget.follow_link) %>" target="_blank" rel="noopener">
<%= __('widget.follow') %></a>
</div>
<% } %>
@ -86,7 +86,7 @@
<div class="level is-mobile">
<% for (let name in socialLinks) {
let link = socialLinks[name]; %>
<a class="level-item button is-white is-marginless" target="_blank"
<a class="level-item button is-white is-marginless" target="_blank" rel="noopener"
title="<%= name %>" href="<%= url_for(typeof(link) === 'string' ? link : link.url) %>">
<% if (typeof(link) === 'string') { %>
<%= name %>

View File

@ -140,9 +140,12 @@
typeof (IcarusThemeSettings.site.external_link) !== 'undefined' &&
IcarusThemeSettings.site.external_link.enable) {
$('.article .content a').filter(function (i, link) {
return link.href && link.classList.length === 0 && isExternalLink(link.href,
IcarusThemeSettings.site.url,
IcarusThemeSettings.site.external_link.exclude);
return link.href &&
!$(link).attr('href').startsWith('#') &&
link.classList.length === 0 &&
isExternalLink(link.href,
IcarusThemeSettings.site.url,
IcarusThemeSettings.site.external_link.exclude);
}).each(function (i, link) {
link.relList.add('noopener');
link.target = '_blank';