nfreear / nfreear-blog

My (re-developed) personal blog. A work-in-progress! —
https://nick.freear.org.uk
MIT License
0 stars 1 forks source link

Redirection via Javascript ... #27

Open nfreear opened 7 years ago

nfreear commented 7 years ago

YAML front matter in page:

---
# ...

x-redirect-url: /2017/05/22/sign-machine.html
x-hash: '#id-sign-machine'
x-nav-class: sr-only
---

Top of the page -- includes/head.html:

{% if page.x-redirect-url %}

  <script>
  setTimeout(function () {
    var x_redirect_url = '{{ page.x-redirect-url }}' + ( location.search || '?' ) + '&utm_source=redirect' + '{{ page.x-hash }}';
    window.location = x_redirect_url;
  }, 2000 );
  </script>

  <p role="alert" class="big_me redirect"> Redirecting ... </p>

{% endif %}

Bottom of page -- _layout/default.html:

{% unless page.x-redirect-url %}

    {% include footer.html %}
    {% include footer-javascript.html %}

{% endunless %}

To make it accessible: