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:
parent
3aa50cc5a5
commit
a3d251a18e
4 changed files with 41 additions and 14 deletions
|
@ -7,6 +7,22 @@
|
||||||
========================================================================== */
|
========================================================================== */
|
||||||
|
|
||||||
.breadcrumbs {
|
.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 {
|
ol {
|
||||||
padding: 0;
|
padding: 0;
|
||||||
list-style: none;
|
list-style: none;
|
||||||
|
|
14
_config.yml
14
_config.yml
|
@ -15,7 +15,7 @@ url : "http://localhost:4000" # the base hostname & protoco
|
||||||
baseurl : "/minimal-mistakes" # the subpath of your site, e.g. /blog
|
baseurl : "/minimal-mistakes" # the subpath of your site, e.g. /blog
|
||||||
email : "your-email@domain.com"
|
email : "your-email@domain.com"
|
||||||
logo : "site-logo.png"
|
logo : "site-logo.png"
|
||||||
breadcrumbs : false # true / false (default)
|
breadcrumbs : true # true / false (default)
|
||||||
breadcrumb_home_label : "Home"
|
breadcrumb_home_label : "Home"
|
||||||
breadcrumb_separator : "/"
|
breadcrumb_separator : "/"
|
||||||
twitter:
|
twitter:
|
||||||
|
@ -110,13 +110,13 @@ kramdown:
|
||||||
collections:
|
collections:
|
||||||
recipes:
|
recipes:
|
||||||
output: true
|
output: true
|
||||||
permalink: /:collection/:categories/:path/
|
permalink: /:collection/:path/
|
||||||
pets:
|
pets:
|
||||||
output: true
|
output: true
|
||||||
permalink: /:collection/:categories/:path/
|
permalink: /:collection/:path/
|
||||||
portfolio:
|
portfolio:
|
||||||
output: true
|
output: true
|
||||||
permalink: /:collection/:categories/:path/
|
permalink: /:collection/:path/
|
||||||
|
|
||||||
# Defaults
|
# Defaults
|
||||||
defaults:
|
defaults:
|
||||||
|
@ -182,8 +182,10 @@ timezone: America/New_York # http://en.wikipedia.org/wiki/List_of_tz_database_ti
|
||||||
# Type
|
# Type
|
||||||
# - GitHub Pages compatible archive pages built with Liquid ~> type: liquid (default)
|
# - GitHub Pages compatible archive pages built with Liquid ~> type: liquid (default)
|
||||||
# - Jekyll Archives plugin archive pages ~> type: jekyll-archives
|
# - Jekyll Archives plugin archive pages ~> type: jekyll-archives
|
||||||
# Path
|
# Path (examples)
|
||||||
# - <base_path>/tags/my-awesome-tag/index.html ~> path: /tags/
|
# - <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:
|
categories:
|
||||||
type: liquid
|
type: liquid
|
||||||
path: /categories/
|
path: /categories/
|
||||||
|
@ -199,7 +201,7 @@ tags:
|
||||||
# category: archive-taxonomy
|
# category: archive-taxonomy
|
||||||
# tag: archive-taxonomy
|
# tag: archive-taxonomy
|
||||||
# permalinks:
|
# permalinks:
|
||||||
# category: /categories/:name/
|
# category: /:name/
|
||||||
# tag: /tags/:name/
|
# tag: /tags/:name/
|
||||||
|
|
||||||
# HTML Compression
|
# HTML Compression
|
||||||
|
|
|
@ -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">
|
<nav class="breadcrumbs">
|
||||||
<ol itemscope itemtype="http://schema.org/BreadcrumbList">
|
<ol itemscope itemtype="http://schema.org/BreadcrumbList">
|
||||||
{% assign crumbs = page.url | split: '/' %}
|
{% assign crumbs = page.url | split: '/' %}
|
||||||
|
@ -15,7 +29,7 @@
|
||||||
{% else %}
|
{% else %}
|
||||||
{% assign i = i | plus: 1 %}
|
{% assign i = i | plus: 1 %}
|
||||||
<li itemprop="itemListElement" itemscope itemtype="http://schema.org/ListItem">
|
<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 }}" />
|
<meta itemprop="position" content="{{ i }}" />
|
||||||
</li>
|
</li>
|
||||||
<span class="sep">{{ site.breadcrumb_separator }}</span>
|
<span class="sep">{{ site.breadcrumb_separator }}</span>
|
||||||
|
|
|
@ -6,12 +6,7 @@ author_profile: false
|
||||||
---
|
---
|
||||||
|
|
||||||
{% include base_path %}
|
{% include base_path %}
|
||||||
{% include group-by-array collection=site.recipes field='categories' %}
|
|
||||||
|
|
||||||
{% for category in group_names %}
|
{% for post in site.recipes %}
|
||||||
{% assign posts = group_items[forloop.index0] %}
|
{% include archive-list-single.html %}
|
||||||
<h2 id="{{ category | slugify }}" class="archive__subtitle">{{ category }}</h2>
|
|
||||||
{% for post in posts %}
|
|
||||||
{% include archive-list-single.html %}
|
|
||||||
{% endfor %}
|
|
||||||
{% endfor %}
|
{% endfor %}
|
Loading…
Add table
Reference in a new issue