mirror of
https://github.com/squidfunk/mkdocs-material.git
synced 2024-11-24 07:30:12 +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:
parent
dcf6c34284
commit
6d713cb8f5
@ -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" %}
|
||||
|
Loading…
Reference in New Issue
Block a user