improved redirect mapping (#2157)

In reference to issue:
https://github.com/alshedivat/al-folio/discussions/1818

Redirect cases were only happening on the surface level, essentially
just affecting the links on [blog
index](https://alshedivat.github.io/al-folio/blog/page/4/index.htm) and
[year tag](https://alshedivat.github.io/al-folio/blog/2022/). However,
from the actual
[site](https://alshedivat.github.io/al-folio/blog/2022/redirect/), it
would automatically redirect to the `base_url` rather than the actual
`redirect`.

In my update, if `redirect: true`, like it is in `404.md`, redirect
behavior is the same, redirecting to the `base_url`. If it is an
external link, then the redirect is external. And finally if it is an
internal redirect, like it is in
https://alshedivat.github.io/al-folio/blog/2022/redirect/, than the
redirect is `page.redirect | relative_url`
This commit is contained in:
Andrew Boyer 2024-02-04 15:27:10 -05:00 committed by GitHub
parent 18f7307e07
commit ae0c1a62cf
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 8 additions and 1 deletions

View File

@ -3,7 +3,14 @@
<!-- Head -->
<head>
{% if page.redirect %}
<meta http-equiv="refresh" content="3; url={{ site.baseurl }}/">
{% if page.redirect == true %}
{% assign redirect = site.baseurl | append: '/' %}
{% elsif page.redirect contains '://' %}
{% assign redirect = page.redirect %}
{% else %}
{% assign redirect = page.redirect | relative_url %}
{% endif %}
<meta http-equiv="refresh" content="3; url={{ redirect }}">
{% endif %}
{% include head.liquid %}
</head>