Fix showing background img with non-empty baseurl (#497)

* Fix showing background img with non-empty baseurl

Also switch globally to relative_url for all baseurl prepends,
which is more robust than custom URL mangling

* More site.baseurl -> relative_url conversion
This commit is contained in:
Abel Cheung 2019-06-08 13:34:33 +08:00 committed by Dean Attali
parent a666a9db52
commit 7b43e4061d
12 changed files with 28 additions and 28 deletions

View file

@ -12,7 +12,7 @@
{% if page.js %}
{% for js in page.js %}
<script src="{{ js | prepend: site.baseurl | replace: '//', '/' }}"></script>
<script src="{{ js | relative_url }}"></script>
{% endfor %}
{% endif %}
@ -22,11 +22,11 @@
{% if js contains 'jquery' %}
<script>
if (typeof jQuery == 'undefined') {
document.write('<script src="{{ js | prepend: site.baseurl | replace: "//", "/" }}"></scr' + 'ipt>');
document.write('<script src="{{ js | relative_url }}"></scr' + 'ipt>');
}
</script>
{% else %}
<script src="{{ js | prepend: site.baseurl | replace: '//', '/' }}"></script>
<script src="{{ js | relative_url }}"></script>
{% endif %}
{% endfor %}
{% endif %}

View file

@ -8,7 +8,7 @@
{%- assign element = site.data.SocialNetworks[curkey] -%}
<li>
{%- if curkey == 'rss' -%}
<a href="{{ '/feed.xml' | prepend: site.baseurl }}" title="{{ element.name }}">
<a href="{{ '/feed.xml' | relative_url }}" title="{{ element.name }}">
{%- elsif curkey == 'yelp' -%}
<a href="https://{{ site.social-network-links[curkey] }}.yelp.com" title="{{ element.name }}">
{%- else -%}

View file

@ -11,7 +11,7 @@
<meta name="description" content="{{ page.subtitle }}">
{% endif %}
<link rel="alternate" type="application/rss+xml" title="{{ site.title }} {{ site.title-separator }} {{ site.description }}" href="{{ site.baseurl }}/feed.xml" />
<link rel="alternate" type="application/rss+xml" title="{{ site.title }} {{ site.title-separator }} {{ site.description }}" href="{{ '/feed.xml' | relative_url }}" />
{% include gtag.html %}
{% include gtm_head.html %}
@ -25,7 +25,7 @@
{% if layout.common-css %}
{% for css in layout.common-css %}
<link rel="stylesheet" href="{{ css | prepend: site.baseurl | replace: '//', '/' }}" />
<link rel="stylesheet" href="{{ css | relative_url }}" />
{% endfor %}
{% endif %}
@ -43,7 +43,7 @@
{% if page.css %}
{% for css in page.css %}
<link rel="stylesheet" href="{{ css | prepend: site.baseurl | replace: '//', '/' }}" />
<link rel="stylesheet" href="{{ css | relative_url }}" />
{% endfor %}
{% endif %}
@ -125,7 +125,7 @@
{% if page.comments and site.staticman.repository and site.staticman.branch %}
<!-- Staticman -->
<link rel="stylesheet" href="{{ "/css/staticman.css" | prepend: site.baseurl }}" />
<link rel="stylesheet" href="{{ "/css/staticman.css" | relative_url }}" />
{% endif %}
</head>

View file

@ -8,10 +8,10 @@
{% assign imgnum = forloop.index %}
{% for imginfo in bigimg %}
{% if imginfo[0] %}
data-img-src-{{ imgnum }}="{{ imginfo[0] | prepend: site.baseurl | replace: '//', '/' }}"
data-img-src-{{ imgnum }}="{{ imginfo[0] | relative_url }}"
data-img-desc-{{ imgnum }}="{{ imginfo[1] }}"
{% else %}
data-img-src-{{ imgnum }}="{{ imginfo | prepend: site.baseurl | replace: '//', '/' }}"
data-img-src-{{ imgnum }}="{{ imginfo | relative_url }}"
{% endif %}
{% endfor %}
{% endfor %}

View file

@ -41,7 +41,7 @@
<div class="avatar-container">
<div class="avatar-img-border">
<a href="{{ site.url }}">
<img class="avatar-img" src="{{ page.image | prepend: site.baseurl | replace: '//', '/' }}" />
<img class="avatar-img" src="{{ page.image | relative_url }}" />
</a>
</div>
</div>
@ -49,7 +49,7 @@
<div class="avatar-container">
<div class="avatar-img-border">
<a href="{{ site.url }}">
<img class="avatar-img" src="{{ site.avatar | prepend: site.baseurl | replace: '//', '/' }}" />
<img class="avatar-img" src="{{ site.avatar | relative_url }}" />
</a>
</div>
</div>

View file

@ -8,7 +8,7 @@
{% endif %}
{% if internal %}
{% capture linkurl %}{{ site.baseurl }}/{{ include.link[1] }}{% endcapture %}
{% capture linkurl %}{{ include.link[1] | relative_url }}{% endcapture %}
{% else %}
{% capture linkurl %}{{ include.link[1] }}{% endcapture %}
{% endif %}

View file

@ -2,7 +2,7 @@
<!-- doing something a bit funky here because I want to be careful not to include JQuery twice! -->
<script>
if (typeof jQuery == 'undefined') {
document.write('<script src="{{ site.baseurl }}/js/jquery-1.11.2.min.js"></scr' + 'ipt>');
document.write('<script src="{{ "/js/jquery-1.11.2.min.js" | relative_url }}"></scr' + 'ipt>');
}
</script>
<script>