Merge branch 'kcgthb-master'

This commit is contained in:
squidfunk 2018-12-28 15:09:40 +01:00
commit 976d67e5f2
4 changed files with 40 additions and 2 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

@ -48,6 +48,21 @@ see on the current page when you scroll to the top. It's as simple as:
``` markdown ``` markdown
hero: Metadata enables hero teaser texts hero: Metadata enables hero teaser texts
``` ```
### Redirects
It's sometimes necessary to move documents around in the navigation tree and
redirect user from the old URL to the new one. The `redirect:` meta-tag allows
to create a redirection from the current document to the address specified in
the tag.
For instance, if your document contains:
``` markdown
redirect: /new/url
```
accessing that document's URL will automatically redirect to `/new/url`.
### Linking sources ### Linking sources

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 %}