Improve breadcrumb helper

- Add support for collections
- Add support for crumb links that point to auto-generated archive pages (courtesy of Jekyll Archives plugin) and single page Liquid spaghetti pages
- Improve styling
This commit is contained in:
Michael Rose 2016-03-11 15:54:16 -05:00
parent 3aa50cc5a5
commit a3d251a18e
4 changed files with 41 additions and 14 deletions

View file

@ -7,6 +7,22 @@
========================================================================== */
.breadcrumbs {
@include grid(12,10);
@include prefix(12,1);
@include suffix(12,1);
margin-bottom: 1em;
font-family: $sans-serif;
font-size: 14px;
@include breakpoint($small) {
@include grid(12,11);
@include prefix(12,0.5);
@include suffix(12,0.5);
}
@include breakpoint($x-large) {
@include grid(12,8);
@include prefix(12,2);
@include suffix(12,2)
}
ol {
padding: 0;
list-style: none;

View file

@ -15,7 +15,7 @@ url : "http://localhost:4000" # the base hostname & protoco
baseurl : "/minimal-mistakes" # the subpath of your site, e.g. /blog
email : "your-email@domain.com"
logo : "site-logo.png"
breadcrumbs : false # true / false (default)
breadcrumbs : true # true / false (default)
breadcrumb_home_label : "Home"
breadcrumb_separator : "/"
twitter:
@ -110,13 +110,13 @@ kramdown:
collections:
recipes:
output: true
permalink: /:collection/:categories/:path/
permalink: /:collection/:path/
pets:
output: true
permalink: /:collection/:categories/:path/
permalink: /:collection/:path/
portfolio:
output: true
permalink: /:collection/:categories/:path/
permalink: /:collection/:path/
# Defaults
defaults:
@ -182,8 +182,10 @@ timezone: America/New_York # http://en.wikipedia.org/wiki/List_of_tz_database_ti
# Type
# - GitHub Pages compatible archive pages built with Liquid ~> type: liquid (default)
# - Jekyll Archives plugin archive pages ~> type: jekyll-archives
# Path
# Path (examples)
# - <base_path>/tags/my-awesome-tag/index.html ~> path: /tags/
# - <base_path/categories/my-awesome-category/index.html ~> /categories/
# - <base_path/my-awesome-category/index.html ~> /
categories:
type: liquid
path: /categories/
@ -199,7 +201,7 @@ tags:
# category: archive-taxonomy
# tag: archive-taxonomy
# permalinks:
# category: /categories/:name/
# category: /:name/
# tag: /tags/:name/
# HTML Compression

View file

@ -1,3 +1,17 @@
{% case site.categories.type %}
{% when "liquid" %}
{% assign path_type = "#" %}
{% when "jekyll-archives" %}
{% assign path_type = nil %}
{% endcase %}
{% if page.collection != 'posts' %}
{% assign path_type = nil %}
{% assign crumb_path = '/' %}
{% else %}
{% assign crumb_path = site.categories.path %}
{% endif %}
<nav class="breadcrumbs">
<ol itemscope itemtype="http://schema.org/BreadcrumbList">
{% assign crumbs = page.url | split: '/' %}
@ -15,7 +29,7 @@
{% else %}
{% assign i = i | plus: 1 %}
<li itemprop="itemListElement" itemscope itemtype="http://schema.org/ListItem">
<a href="{{ base_path }}{% assign crumb_limit = forloop.index | plus: 1 %}{% for crumb in crumbs limit: crumb_limit %}{{ crumb | append: '/' }}{% endfor %}" itemprop="item"><span itemprop="name">{{ crumb | replace: '-', ' ' | replace: '%20', ' ' | capitalize }}</span></a>
<a href="{{ base_path }}{{ crumb | prepend: path_type | prepend: crumb_path }}" itemprop="item"><span itemprop="name">{{ crumb | replace: '-', ' ' | replace: '%20', ' ' | capitalize }}</span></a>
<meta itemprop="position" content="{{ i }}" />
</li>
<span class="sep">{{ site.breadcrumb_separator }}</span>

View file

@ -6,12 +6,7 @@ author_profile: false
---
{% include base_path %}
{% include group-by-array collection=site.recipes field='categories' %}
{% for category in group_names %}
{% assign posts = group_items[forloop.index0] %}
<h2 id="{{ category | slugify }}" class="archive__subtitle">{{ category }}</h2>
{% for post in posts %}
{% include archive-list-single.html %}
{% endfor %}
{% for post in site.recipes %}
{% include archive-list-single.html %}
{% endfor %}