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