pages/_layouts/default.liquid
Andrew Boyer ae0c1a62cf
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`
2024-02-04 17:27:10 -03:00

73 lines
2.4 KiB
Plaintext

<!doctype html>
<html lang="{{ site.lang }}">
<!-- Head -->
<head>
{% if page.redirect %}
{% 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>
<!-- Body -->
<body class="{% if site.navbar_fixed %}fixed-top-nav{% endif %} {% unless site.footer_fixed %}sticky-bottom-footer{% endunless %}">
<!-- Header -->
{% include header.liquid %}
<!-- Content -->
<div class="container mt-5" role="main">
{% if page.toc and page.toc.sidebar %}
{% if page.toc.sidebar == 'right' %}
<div class="row">
<!-- main content area -->
<div class="col-sm-9">{{ content }}</div>
<!-- sidebar, which will move to the top on a small screen -->
<div class="col-sm-3">
<nav id="toc-sidebar" class="sticky-top"></nav>
</div>
</div>
{% else %}
<div class="row">
<!-- sidebar, which will move to the top on a small screen -->
<div class="col-sm-3">
<nav id="toc-sidebar" class="sticky-top"></nav>
</div>
<!-- main content area -->
<div class="col-sm-9">{{ content }}</div>
</div>
{% endif %}
{% else %}
{{ content }}
{% endif %}
</div>
<!-- Footer -->
{% include footer.liquid %}
<!-- JavaScripts -->
{% include scripts/jquery.liquid %}
{% include scripts/bootstrap.liquid %}
{% include scripts/masonry.liquid %}
{% include scripts/mermaid.liquid %}
{% include scripts/diff2html.liquid %}
{% include scripts/leaflet.liquid %}
{% include scripts/chartjs.liquid %}
{% include scripts/echarts.liquid %}
{% include scripts/vega.liquid %}
{% include scripts/tikzjax.liquid %}
{% include scripts/misc.liquid %}
{% include scripts/badges.liquid %}
{% include scripts/mathjax.liquid %}
{% include scripts/analytics.liquid %}
{% include scripts/progressBar.liquid %}
{% include scripts/wechatModal.liquid %}
{% include scripts/imageLayouts.liquid %}
</body>
</html>