mirror of
https://github.com/squidfunk/mkdocs-material.git
synced 2024-06-14 11:52:32 +03: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:
parent
dcf6c34284
commit
6d713cb8f5
@ -22,12 +22,12 @@
|
|||||||
|
|
||||||
{% if page.meta.redirect %}
|
{% if page.meta.redirect %}
|
||||||
<script>
|
<script>
|
||||||
document.location.replace({{ page.meta.redirect }})
|
// redirect anchors
|
||||||
|
var anchor = window.location.hash.substr(1);
|
||||||
|
location.href = '{{ page.meta.redirect }}' + (anchor?'#'+anchor:'');
|
||||||
</script>
|
</script>
|
||||||
<meta http-equiv="refresh" content="0; url={{ page.meta.redirect }}"/>
|
<!-- no-js fallback -->
|
||||||
<link rel="canonical" href="{{ page.meta.redirect }} " />
|
<meta http-equiv="refresh" content="0; url={{ page.meta.redirect }}">
|
||||||
{% else %}
|
<link rel="canonical" href="{{ page.meta.redirect }}">
|
||||||
|
|
||||||
{% extends "base.html" %}
|
|
||||||
|
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
{% extends "base.html" %}
|
||||||
|
Loading…
Reference in New Issue
Block a user