-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update to breadcrumbs.html to use va-breadcrumbs (#2254)
* Update to breadcrumbs.html to use va-breadcrumbs * Improvements to breadcrumbs.html filter Added missing "home" crumb * Fix to link capitalization when there's a "custom" title * Fix to capitalization processing * Updates to liquid filter unit tests * Adding some light type annotations to try and kick off another review instance deploy
- Loading branch information
Showing
3 changed files
with
151 additions
and
53 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
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
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,56 +1,20 @@ | ||
{% if gatePage === true %} | ||
{% assign gatePageClassName = 'va-nav-breadcrumbs--gate' %} | ||
{% endif %} | ||
<div class="vads-u-padding-x--1p5" data-template="includes/breadcrumbs"> | ||
{% if gatePage === true %} | ||
{% assign gatePageClassName = 'va-nav-breadcrumbs--gate' %} | ||
{% endif %} | ||
|
||
<nav aria-label="Breadcrumb" aria-live="polite" class="va-nav-breadcrumbs {{gatePageClassName}} {% if newGrid %}new-grid{% endif %}" id="va-breadcrumbs"> | ||
<ul class="row va-nav-breadcrumbs-list columns" id="va-breadcrumbs-list"> | ||
<li> | ||
<a href="/" onClick="recordEvent({ event: 'nav-breadcrumb', 'nav-breadcrumb-section': 'home' });"> | ||
Home | ||
</a> | ||
</li> | ||
{% assign crumbs = breadcrumb_path %} | ||
{% if breadcrumbs_override %} | ||
{% assign crumbs = breadcrumbs_override %} | ||
{% endif %} | ||
{% assign crumbs = crumbs | formatForBreadcrumbsHTML %} | ||
|
||
{% assign crumbs = breadcrumb_path %} | ||
<va-breadcrumbs class="row {{gatePageClassName}} {% if newGrid %}new-grid{% endif %}" wrapping /> | ||
|
||
{% if breadcrumbs_override %} | ||
{% assign crumbs = breadcrumbs_override %} | ||
{% endif %} | ||
|
||
{% assign current_page = crumbs | last %} | ||
|
||
{% for crumb in crumbs %} | ||
<!-- Adding back in the last link as aria-current="page" --> | ||
{% comment %} | ||
Each breadcrumb item has a child object. | ||
One of the properties of that object is `file` which loads the front matter metadata from the corresponding Markdown input file. | ||
Below, we’ve assigned that object to a variable named 'crumb_child_meta'. | ||
If these templates are still using tinyliquid, you can dump the properties of this object using {{ crumb | keys }}. | ||
{% endcomment %} | ||
{% assign crumb_child_meta = crumb.children.0.file %} | ||
|
||
<li> | ||
{% if current_page.name != crumb.name %} | ||
<a href="/{{ crumb.path }}"> | ||
{% if crumb_child_meta.display_title %} | ||
{{ crumb_child_meta.display_title }} | ||
{% elsif crumb_child_meta.title %} | ||
{{ crumb_child_meta.title }} | ||
{% else %} | ||
{{ crumb.name | replace: '-', ' ' | capitalize }} | ||
{% endif %} | ||
</a> | ||
{% else %} | ||
<a aria-current="page" href="/{{ crumb.path }}"> | ||
{% if crumb_child_meta.display_title %} | ||
{{ crumb_child_meta.display_title }} | ||
{% elsif crumb_child_meta.title %} | ||
{{ crumb_child_meta.title }} | ||
{% else %} | ||
{{ crumb.name | replace: '-', ' ' | capitalize }} | ||
{% endif %} | ||
</a> | ||
{% endif %} | ||
</li> | ||
{% endfor %} | ||
</ul> | ||
</nav> | ||
<script> | ||
const bcComponent = document.querySelector('va-breadcrumbs'); | ||
if (bcComponent) { | ||
bcComponent.setAttribute('breadcrumb-list', {{ crumbs }}); | ||
} | ||
</script> | ||
</div> |