-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Avoid hardcoding breakcrumb links, automatically use link to deepest …
…page that exists
- Loading branch information
1 parent
d2fd551
commit ac9f77a
Showing
1 changed file
with
31 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,36 @@ | ||
<div class="breadcrumbs"> | ||
{%- if page.categories.first == "News" -%} | ||
{%- assign url = "/news/" -%} | ||
{%- elsif page.categories.first == "Newsletters" -%} | ||
{%- assign url = "/news/newsletter/" -%} | ||
{%- elsif page.categories.first == "Mappy Hours" -%} | ||
{%- assign url = "/events/mappy-hours/" -%} | ||
{%- elsif page.categories.first == "Out & About" -%} | ||
{%- assign url = "/news/appearances/" -%} | ||
{%- else -%} | ||
{%- assign path_parts = page.url | remove: "index" | split: "/" -%} | ||
{%- if path_parts.size > 2 -%} | ||
{% assign prior_index = path_parts.size | minus: 2 %} | ||
{% assign prior_parts_size = path_parts.size | minus: 1 %} | ||
{% assign part = path_parts | slice: prior_index, prior_index | first %} | ||
{% assign url = path_parts | slice: 0, prior_parts_size | join: "/" | append: "/" %} | ||
{%- endif -%} | ||
{%- endif -%} | ||
{%- if url -%} | ||
<a href="{{url | absolute_url}}"> | ||
<svg class="iconsvg"><use xlink:href="#arrow-left"></use></svg> | ||
{% assign part_page=site.documents | find: "url", url -%} | ||
{%- if part_page.title -%} | ||
{{part_page.title}} | ||
{%- else -%} | ||
{% assign derived_label=part | replace: "-", " " | url_decode %} | ||
{% assign derived_label_as_num=derived_label | plus: 0 %} | ||
{% if derived_label.size==2 and derived_label_as_num<=12 %} | ||
{{ page.date | date: "%B" }} | ||
{%- assign path_parts = page.url | split: "/" -%} | ||
{%- if path_parts.size > 2 -%} | ||
{%- assign urlsString = "" -%} | ||
{%- assign composite_url = "" -%} | ||
{%- for part in path_parts -%} | ||
{%- assign composite_url = composite_url | append: part | append: "/" -%} | ||
{%- assign urlsString = urlsString | append: composite_url | append: ";" -%} | ||
{%- endfor -%} | ||
{%- assign urls = urlsString | split: ";" | reverse | slice: 1, 100 -%} | ||
{%- for url in urls -%} | ||
{%- assign part_page = site.documents | find: "url", url -%} | ||
{%- unless part_page -%} | ||
{%- continue -%} | ||
{%- endunless -%} | ||
{%- if part_page.layout == "redirect" and part_page.redirect == page.url -%} | ||
{%- continue -%} | ||
{%- endif -%} | ||
<a href="{{url | absolute_url}}"> | ||
<svg class="iconsvg"><use xlink:href="#arrow-left"></use></svg> | ||
{% if part_page.title -%} | ||
{{ part_page.title }} | ||
{%- else -%} | ||
{{derived_label}} | ||
{% assign derived_label=part | replace: "-", " " | url_decode %} | ||
{% assign derived_label_as_num=derived_label | plus: 0 %} | ||
{% if derived_label.size==2 and derived_label_as_num<=12 %} | ||
{{ page.date | date: "%B" }} | ||
{%- else -%} | ||
{{ derived_label }} | ||
{%- endif -%} | ||
{%- endif -%} | ||
{%- endif -%} | ||
</a> | ||
</a> | ||
{%- break -%} | ||
{%- endfor -%} | ||
{%- endif -%} | ||
</div> |