Skip to content

Commit c6ec03d

Browse files
authored
Merge pull request creativecommons#301 from creativecommons/add_breadcrumb
Integrate breadcrumb component.
2 parents bcd4f54 + 99f57d0 commit c6ec03d

File tree

2 files changed

+61
-9
lines changed

2 files changed

+61
-9
lines changed

themes/vocabulary_theme/templates/layout.html

+48-9
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@
4040

4141
<body>
4242
<div class="ga-script">{{ generate_google_analytics() }}</div>
43+
44+
<!-- Header -->
4345
<header class="container">
4446
<nav class="navbar">
4547
<div class="navbar-brand">
@@ -132,18 +134,55 @@
132134
</div>
133135
</nav>
134136
</header>
135-
<div class="container-fluid page-content">
136-
<div class="row justify-content-md-center">
137-
<div class="col-lg-9 col-md-9 col-sm-12 content-wrap">
138-
<div class="page py-3">
139-
<h1 class="page-title pb-3 mb-4">{% block header %}{{ this.title }}{% endblock %}</h1>
140-
{% block body %}{% endblock %}
141-
<a id="back-to-top" href="#top" class="btn btn-dark btn-sm" role="button">Back to top</a>
142-
</div>
143-
</div>
137+
138+
<!-- Breadcrumb -->
139+
{% if this._path != '/'%}
140+
<div class="breadcrumb-container">
141+
<nav class="container breadcrumb caption bold" aria-label="breadcrumbs">
142+
<ul>
143+
{% set crumbs = [] %}
144+
{% set current = {'crumb': this} %}
145+
<!-- Extracting the slugs of URL -->
146+
{% for i in this._path.split("/") %}
147+
{% if current.crumb is not none %}
148+
{% if crumbs.insert(0, current.crumb._slug) %}{% endif %}
149+
{% if current.update({"crumb": current.crumb.parent}) %}{% endif %}
150+
{% endif %}
151+
{% endfor %}
152+
{% for crumb in crumbs %}
153+
<!-- Active link -->
154+
{% if this._slug == crumb %}
155+
<li class="is-active"><a aria-current="page displayed">{{ crumb | title | replace('-', ' ') }}</a></li>
156+
{% else %}
157+
<!-- Forming the URL using extracted slugs -->
158+
{% set i = loop.index %}
159+
{% set ns = namespace (link = '') %}
160+
{% for j in range(i) %}
161+
{% set ns.link = ns.link + crumbs[j] + '/' %}
162+
{% endfor %}
163+
<li><a class="link" href="{{ ns.link|url }}">
164+
{% if crumb != '' %}
165+
{{ crumb | title | replace('-', ' ') }}
166+
{% else %}
167+
Home
168+
{% endif %}
169+
</a></li>
170+
{% endif %}
171+
{% endfor %}
172+
</ul>
173+
</nav>
144174
</div>
175+
<<<<<<< HEAD
176+
{% endif %}
177+
178+
<!-- Body -->
179+
{% block body %}{% endblock %}
180+
181+
<!-- Footer -->
182+
=======
145183
</div>
146184

185+
>>>>>>> bcd4f549329a5712d949d18fe9e317b18c2ac1a9
147186
<footer class="main-footer">
148187
<div class="container">
149188
<div class="columns">

webpack/sass/main.scss

+13
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,16 @@ a {
2222
}
2323
}
2424
}
25+
26+
.breadcrumb-container {
27+
border-top: 4px solid $color-forest-green;
28+
background-color: $color-lighter-gray;
29+
30+
.breadcrumb {
31+
@extend .padding-bigger;
32+
33+
.link {
34+
@extend .has-color-forest-green;
35+
}
36+
}
37+
}

0 commit comments

Comments
 (0)