Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use relative_url and absolute_url where possible #2387

Merged
merged 5 commits into from
Mar 6, 2020
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 1 addition & 7 deletions _includes/archive-single.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,7 @@
<article class="archive__item" itemscope itemtype="https://schema.org/CreativeWork">
{% if include.type == "grid" and teaser %}
<div class="archive__item-teaser">
<img src=
{% if teaser contains "://" %}
"{{ teaser }}"
{% else %}
"{{ teaser | relative_url }}"
{% endif %}
alt="">
<img src="{{ teaser | relative_url }}" alt="">
</div>
{% endif %}
<h2 class="archive__item-title" itemprop="headline">
Expand Down
15 changes: 3 additions & 12 deletions _includes/author-profile.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,10 @@

{% if author.avatar %}
<div class="author__avatar">
{% if author.avatar contains "://" %}
{% assign author_src = author.avatar %}
{% else %}
{% assign author_src = author.avatar | relative_url %}
{% endif %}
{% assign author_src = author.avatar | relative_url %}
iBug marked this conversation as resolved.
Show resolved Hide resolved

{% if author.home %}
{% if author.home contains "://" %}
{% assign author_link = author.home %}
{% else %}
{% assign author_link = author.home | relative_url %}
{% endif %}
<a href="{{ author_link }}">
<a href="{{ author.home | relative_url }}">
<img src="{{ author_src }}" alt="{{ author.name }}" itemprop="image">
iBug marked this conversation as resolved.
Show resolved Hide resolved
</a>
{% else %}
Expand Down Expand Up @@ -208,7 +199,7 @@ <h3 class="author__name" itemprop="name">{{ author.name }}</h3>
<i class="fab fa-fw fa-youtube" aria-hidden="true"></i> YouTube
</a>
</li>
{% else author.youtube %}
mmistakes marked this conversation as resolved.
Show resolved Hide resolved
{% elsif author.youtube %}
<li>
<a href="https://www.youtube.com/user/{{ author.youtube }}" itemprop="sameAs" rel="nofollow noopener noreferrer">
<i class="fab fa-fw fa-youtube" aria-hidden="true"></i> YouTube
Expand Down
20 changes: 4 additions & 16 deletions _includes/feature_row
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,12 @@
<div class="feature__wrapper">

{% for f in feature_row %}

{% if f.url contains "://" %}
{% capture f_url %}{{ f.url }}{% endcapture %}
{% else %}
{% capture f_url %}{{ f.url | relative_url }}{% endcapture %}
{% endif %}

<div class="feature__item{% if include.type %}--{{ include.type }}{% endif %}">
<div class="archive__item">
{% if f.image_path %}
<div class="archive__item-teaser">
<img src=
{% if f.image_path contains "://" %}
"{{ f.image_path }}"
{% else %}
"{{ f.image_path | relative_url }}"
{% endif %}
alt="{% if f.alt %}{{ f.alt }}{% endif %}">
<img src="{{ f.image_path | relative_url }}"
alt="{% if f.alt %}{{ f.alt }}{% endif %}">
{% if f.image_caption %}
<span class="archive__item-caption">{{ f.image_caption | markdownify | remove: "<p>" | remove: "</p>" }}</span>
{% endif %}
Expand All @@ -43,11 +31,11 @@
{% 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 | default: "Learn More" }}</a></p>
<p><a href="{{ f.url | relative_url }}" class="btn {{ f.btn_class }}">{{ f.btn_label | default: site.data.ui-text[site.locale].more_label | default: "Learn More" }}</a></p>
{% endif %}
</div>
</div>
</div>
{% endfor %}

</div>
</div>
13 changes: 5 additions & 8 deletions _includes/figure
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
<figure class="{{ include.class }}">
<img src=
{% if include.image_path contains "://" %}
"{{ include.image_path }}"
{% else %}
"{{ include.image_path | relative_url }}"
{% endif %}
alt="{% if include.alt %}{{ include.alt }}{% endif %}">
<img src="{{ include.image_path | relative_url }}"
alt="{% if include.alt %}{{ include.alt }}{% endif %}">
{% if include.caption %}
<figcaption>
{{ include.caption | markdownify | remove: "<p>" | remove: "</p>" }}
</figcaption>{% endif %}</figure>
</figcaption>
{% endif %}
</figure>
30 changes: 7 additions & 23 deletions _includes/gallery
Original file line number Diff line number Diff line change
Expand Up @@ -19,33 +19,17 @@
<figure class="{{ gallery_layout }} {{ include.class }}">
{% for img in gallery %}
{% if img.url %}
<a href=
{% if img.url contains "://" %}
"{{ img.url }}"
{% else %}
"{{ img.url | relative_url }}"
{% endif %}
{% if img.title %}title="{{ img.title }}"{% endif %}
>
<img src=
{% if img.image_path contains "://" %}
"{{ img.image_path }}"
{% else %}
"{{ img.image_path | relative_url }}"
{% endif %}
alt="{% if img.alt %}{{ img.alt }}{% endif %}">
<a href="{{ img.url | relative_url }}"
{% if img.title %}title="{{ img.title }}"{% endif %}>
<img src="{{ img.image_path | relative_url }}"
alt="{% if img.alt %}{{ img.alt }}{% endif %}">
</a>
{% else %}
<img src=
{% if img.image_path contains "://" %}
"{{ img.image_path }}"
{% else %}
"{{ img.image_path | relative_url }}"
{% endif %}
alt="{% if img.alt %}{{ img.alt }}{% endif %}">
<img src="{{ img.image_path | relative_url }}"
alt="{% if img.alt %}{{ img.alt }}{% endif %}">
{% endif %}
{% endfor %}
{% if include.caption %}
<figcaption>{{ include.caption | markdownify | remove: "<p>" | remove: "</p>" }}</figcaption>
{% endif %}
</figure>
</figure>
7 changes: 1 addition & 6 deletions _includes/head.html
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,6 @@

{% if site.head_scripts %}
{% for script in site.head_scripts %}
{% if script contains "://" %}
{% capture script_path %}{{ script }}{% endcapture %}
{% else %}
{% capture script_path %}{{ script | relative_url }}{% endcapture %}
{% endif %}
<script src="{{ script_path }}"></script>
<script src="{{ script | relative_url }}"></script>
{% endfor %}
{% endif %}
7 changes: 1 addition & 6 deletions _includes/masthead.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,8 @@
</a>
<ul class="visible-links">
{%- for link in site.data.navigation.main -%}
{%- if link.url contains '://' -%}
{%- assign url = link.url -%}
{%- else -%}
{%- assign url = link.url | relative_url -%}
{%- endif -%}
<li class="masthead__menu-item">
<a href="{{ url }}" {% if link.description %}title="{{ link.description }}"{% endif %}>{{ link.title }}</a>
<a href="{{ link.url | relative_url }}"{% if link.description %} title="{{ link.description }}"{% endif %}>{{ link.title }}</a>
</li>
{%- endfor -%}
</ul>
Expand Down
14 changes: 3 additions & 11 deletions _includes/nav_list
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,7 @@
<li>
{% if nav.url %}
{% comment %} internal/external URL check {% endcomment %}
iBug marked this conversation as resolved.
Show resolved Hide resolved
{% if nav.url contains "://" %}
{% assign nav_url = nav.url %}
{% else %}
{% assign nav_url = nav.url | relative_url %}
{% endif %}
{% assign nav_url = nav.url | relative_url %}

<a href="{{ nav_url }}"><span class="nav__sub-title">{{ nav.title }}</span></a>
{% else %}
Expand All @@ -24,11 +20,7 @@
<ul>
{% for child in nav.children %}
{% comment %} internal/external URL check {% endcomment %}
{% if child.url contains "://" %}
{% assign child_url = child.url %}
{% else %}
{% assign child_url = child.url | relative_url %}
{% endif %}
{% assign child_url = child.url | relative_url %}

{% comment %} set "active" class on current page {% endcomment %}
{% if child.url == page.url %}
Expand All @@ -44,4 +36,4 @@
</li>
{% endfor %}
</ul>
</nav>
</nav>
27 changes: 4 additions & 23 deletions _includes/page__hero.html
Original file line number Diff line number Diff line change
@@ -1,20 +1,6 @@
{% if page.header.image contains "://" %}
{% capture img_path %}{{ page.header.image }}{% endcapture %}
{% else %}
{% capture img_path %}{{ page.header.image | relative_url }}{% endcapture %}
{% endif %}

{% if page.header.cta_url contains "://" %}
{% capture cta_path %}{{ page.header.cta_url }}{% endcapture %}
{% else %}
{% capture cta_path %}{{ page.header.cta_url | relative_url }}{% endcapture %}
{% endif %}

{% if page.header.overlay_image contains "://" %}
{% capture overlay_img_path %}{{ page.header.overlay_image }}{% endcapture %}
{% elsif page.header.overlay_image %}
{% capture overlay_img_path %}{{ page.header.overlay_image | relative_url }}{% endcapture %}
{% endif %}
{% capture img_path %}{{ page.header.image | relative_url }}{% endcapture %}
mmistakes marked this conversation as resolved.
Show resolved Hide resolved
{% capture cta_path %}{{ page.header.cta_url | relative_url }}{% endcapture %}
{% capture overlay_img_path %}{{ page.header.overlay_image | relative_url }}{% endcapture %}

{% if page.header.overlay_filter contains "rgba" %}
{% capture overlay_filter %}{{ page.header.overlay_filter }}{% endcapture %}
Expand Down Expand Up @@ -56,12 +42,7 @@ <h1 id="page-title" class="page__title" itemprop="headline">
{% if page.header.actions %}
<p>
{% for action in page.header.actions %}
{% if action.url contains "://" %}
{% assign url = action.url %}
{% else %}
{% assign url = action.url | relative_url %}
{% endif %}
<a href="{{ url }}" class="btn btn--light-outline btn--large">{{ action.label | default: site.data.ui-text[site.locale].more_label | default: "Learn More" }}</a>
<a href="{{ action.url | relative_url }}" class="btn btn--light-outline btn--large">{{ action.label | default: site.data.ui-text[site.locale].more_label | default: "Learn More" }}</a>
{% endfor %}
{% endif %}
</div>
Expand Down
14 changes: 2 additions & 12 deletions _includes/scripts.html
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
{% if site.footer_scripts %}
{% for script in site.footer_scripts %}
{% if script contains "://" %}
{% capture script_path %}{{ script }}{% endcapture %}
{% else %}
{% capture script_path %}{{ script | relative_url }}{% endcapture %}
{% endif %}
<script src="{{ script_path }}"></script>
<script src="{{ script | relative_url }}"></script>
{% endfor %}
{% else %}
<script src="{{ '/assets/js/main.min.js' | relative_url }}"></script>
Expand All @@ -29,11 +24,6 @@

{% if site.after_footer_scripts %}
{% for script in site.after_footer_scripts %}
{% if script contains "://" %}
{% capture script_path %}{{ script }}{% endcapture %}
{% else %}
{% capture script_path %}{{ script | relative_url }}{% endcapture %}
{% endif %}
<script src="{{ script_path }}"></script>
<script src="{{ script | relative_url }}"></script>
{% endfor %}
{% endif %}
15 changes: 3 additions & 12 deletions _includes/seo.html
Original file line number Diff line number Diff line change
Expand Up @@ -32,22 +32,13 @@
{%- assign author_twitter = author.twitter | replace: "@", "" -%}
{%- endif -%}

{%- assign page_large_image = page.header.og_image | default: page.header.overlay_image | default: page.header.image -%}
{%- unless page_large_image contains '://' -%}
{%- assign page_large_image = page_large_image | absolute_url -%}
{%- endunless -%}
{%- assign page_large_image = page.header.og_image | default: page.header.overlay_image | default: page.header.image | absolute_url -%}
{%- assign page_large_image = page_large_image | escape -%}

{%- assign page_teaser_image = page.header.teaser | default: site.og_image -%}
{%- unless page_teaser_image contains '://' -%}
{%- assign page_teaser_image = page_teaser_image | absolute_url -%}
{%- endunless -%}
{%- assign page_teaser_image = page.header.teaser | default: site.og_image | absolute_url -%}
{%- assign page_teaser_image = page_teaser_image | escape -%}

{%- assign site_og_image = site.og_image -%}
{%- unless site_og_image contains '://' -%}
{%- assign site_og_image = site_og_image | absolute_url -%}
{%- endunless -%}
{%- assign site_og_image = site.og_image | absolute_url -%}
{%- assign site_og_image = site_og_image | escape -%}

{%- if page.date -%}
Expand Down
11 changes: 3 additions & 8 deletions _includes/sidebar.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,8 @@
{% if page.sidebar %}
{% for s in page.sidebar %}
{% if s.image %}
<img src=
{% if s.image contains "://" %}
"{{ s.image }}"
{% else %}
"{{ s.image | relative_url }}"
{% endif %}
alt="{% if s.image_alt %}{{ s.image_alt }}{% endif %}">
<img src="{{ s.image | relative_url }}"
alt="{% if s.image_alt %}{{ s.image_alt }}{% endif %}">
{% endif %}
{% if s.title %}<h3>{{ s.title }}</h3>{% endif %}
{% if s.text %}{{ s.text | markdownify }}{% endif %}
Expand All @@ -21,4 +16,4 @@
{% endif %}
{% endif %}
</div>
{% endif %}
{% endif %}
7 changes: 1 addition & 6 deletions assets/js/lunr/lunr-store.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,7 @@ var store = [
"categories": {{ doc.categories | jsonify }},
"tags": {{ doc.tags | jsonify }},
"url": {{ doc.url | absolute_url | jsonify }},
"teaser":
{%- if teaser contains "://" -%}
{{ teaser | jsonify }}
{%- else -%}
{{ teaser | absolute_url | jsonify }}
{%- endif -%}
"teaser": {{ teaser | absolute_url | jsonify }}
}{%- unless forloop.last and l -%},{%- endunless -%}
{%- endfor -%}
{%- endfor -%}]