1
0
mirror of https://github.com/squidfunk/mkdocs-material.git synced 2024-12-18 02:15:56 +01:00

Moved redirect code into main template

This commit is contained in:
squidfunk 2018-12-28 15:09:11 +01:00
parent afd2787fea
commit 59ce603ed8
4 changed files with 25 additions and 13 deletions

View File

@ -1,3 +1,8 @@
mkdocs-material-3.2.0 (2018-12-28)
* Added support for redirects using metadata refresh
* Fixed #921: Load Google Analytics snippet asynchronously
mkdocs-material-3.1.0 (2018-11-17) mkdocs-material-3.1.0 (2018-11-17)
* Added support for Progressive Web App Manifest * Added support for Progressive Web App Manifest

View File

@ -14,7 +14,12 @@
{% elif config.site_description %} {% elif config.site_description %}
<meta name="description" content="{{ config.site_description }}"> <meta name="description" content="{{ config.site_description }}">
{% endif %} {% endif %}
{% if page.canonical_url %} {% if page and page.meta and page.meta.redirect %}
<script>var anchor=window.location.hash.substr(1);location.href="{{ page.meta.redirect }}"+(anchor?"#"+anchor:"")</script>
<meta http-equiv="refresh" content="0; url={{ page.meta.redirect }}">
<meta name="robots" content="noindex">
<link rel="canonical" href="{{ page.meta.redirect }}">
{% elif page.canonical_url %}
<link rel="canonical" href="{{ page.canonical_url }}"> <link rel="canonical" href="{{ page.canonical_url }}">
{% endif %} {% endif %}
{% if page and page.meta and page.meta.author %} {% if page and page.meta and page.meta.author %}

View File

@ -47,8 +47,21 @@
<meta name="description" content="{{ config.site_description }}" /> <meta name="description" content="{{ config.site_description }}" />
{% endif %} {% endif %}
<!-- Redirect -->
{% if page and page.meta and page.meta.redirect %}
<script>
var anchor = window.location.hash.substr(1)
location.href = '{{ page.meta.redirect }}' +
(anchor ? '#' + anchor : '')
</script>
<!-- no-js fallback -->
<meta http-equiv="refresh" content="0; url={{ page.meta.redirect }}" />
<meta name="robots" content="noindex" />
<link rel="canonical" href="{{ page.meta.redirect }}" />
<!-- Canonical --> <!-- Canonical -->
{% if page.canonical_url %} {% elif page.canonical_url %}
<link rel="canonical" href="{{ page.canonical_url }}" /> <link rel="canonical" href="{{ page.canonical_url }}" />
{% endif %} {% endif %}

View File

@ -20,15 +20,4 @@
IN THE SOFTWARE. IN THE SOFTWARE.
--> -->
{% if page.meta.redirect %}
<script>
// redirect anchors
var anchor = window.location.hash.substr(1);
location.href = '{{ page.meta.redirect }}' + (anchor?'#'+anchor:'');
</script>
<!-- no-js fallback -->
<meta http-equiv="refresh" content="0; url={{ page.meta.redirect }}">
<link rel="canonical" href="{{ page.meta.redirect }}">
<meta name="robots" content="noindex">
{% endif %}
{% extends "base.html" %} {% extends "base.html" %}