Improve URL handling for internally and externally linked pages

This commit is contained in:
Michael Rose 2016-04-14 10:46:33 -04:00
parent e2f06fbfc0
commit 84e85c0f14
2 changed files with 15 additions and 2 deletions

View file

@ -9,6 +9,13 @@
<div class="feature__wrapper">
{% for f in feature_row %}
{% if f.url contains "http" %}
{% capture f_url %}{{ f.url }}{% endcapture %}
{% else %}
{% capture f_url %}{{ f.url | prepend: base_path }}{% endcapture %}
{% endif %}
<div class="feature__item{% if include.type %}--{{ include.type }}{% endif %}">
<div class="archive__item">
{% if f.image_path %}
@ -35,7 +42,7 @@
{% endif %}
{% if f.url %}
<p><a href="{{ f.url }}" class="btn {{ f.btn_class }}">{{ f.btn_label | default: site.data.ui-text[site.locale].more_label }}</a></p>
<p><a href="{{ f_url }}" class="btn {{ f.btn_class }}">{{ f.btn_label | default: site.data.ui-text[site.locale].more_label }}</a></p>
{% endif %}
</div>
</div>

View file

@ -4,6 +4,12 @@
{% capture img_path %}{{ page.header.image | prepend: "/images/" | prepend: base_path }}{% endcapture %}
{% endif %}
{% if page.header.cta_url contains "http" %}
{% capture cta_path %}{{ page.header.cta_url }}{% endcapture %}
{% else %}
{% capture cta_path %}{{ page.header.cta_url | prepend: base_path }}{% endcapture %}
{% endif %}
{% if page.header.overlay_image contains "http" %}
{% capture overlay_img_path %}{{ page.header.overlay_image }}{% endcapture %}
{% elsif page.header.overlay_image %}
@ -29,7 +35,7 @@
<p class="page__meta"><i class="fa fa-clock-o" aria-hidden="true"></i> {% include read-time.html %}</p>
{% endif %}
{% if page.header.cta_url %}
<p><a href="{{ page.header.cta_url }}" class="btn btn--light-outline btn--large">{{ page.header.cta_label | default: site.data.ui-text[site.locale].more_label }}</a></p>
<p><a href="{{ cta_path }}" class="btn btn--light-outline btn--large">{{ page.header.cta_label | default: site.data.ui-text[site.locale].more_label }}</a></p>
{% endif %}
</div>
{% else %}