1
0
mirror of https://github.com/squidfunk/mkdocs-material.git synced 2024-11-28 09:20:52 +01:00

redirect: add support to redirect anchors

eg. if url.md contains: "redirect: newurl/"
       //domain.tld/url#foo redirects to //domain.tld/newurl#foo
This commit is contained in:
Kilian Cavalotti 2018-11-26 15:22:35 -08:00
parent dcf6c34284
commit 6d713cb8f5

View File

@ -22,12 +22,12 @@
{% if page.meta.redirect %}
<script>
document.location.replace({{ page.meta.redirect }})
// redirect anchors
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 }}"/>
<link rel="canonical" href="{{ page.meta.redirect }} " />
{% else %}
{% extends "base.html" %}
<!-- no-js fallback -->
<meta http-equiv="refresh" content="0; url={{ page.meta.redirect }}">
<link rel="canonical" href="{{ page.meta.redirect }}">
{% endif %}
{% extends "base.html" %}