Add support for Jekyll Archives plugin

- Option to select GitHub Pages compatible tag/category page archive or plugin generated archives
This commit is contained in:
Michael Rose 2016-03-11 09:39:20 -05:00
parent 1ccd5f6bf0
commit 3aa50cc5a5
9 changed files with 97 additions and 42 deletions

View file

@ -1,4 +1,5 @@
source "https://rubygems.org"
gem "github-pages"
# gem "jekyll-archives"
gem "wdm", "~> 0.1.0" if Gem.win_platform?

View file

@ -47,7 +47,7 @@ google_ad_client :
google_ad_slot :
# For specifying social profiles.
# https://developers.google.com/structured-data/customize/social-profiles
# - https://developers.google.com/structured-data/customize/social-profiles
social:
type : # Person or Organization (defaults to Person)
name : # If the user or organization name differs from the site's name
@ -170,6 +170,7 @@ gems:
- jekyll-sitemap
- jekyll-gist
- jekyll-feed
# - jekyll-archives
# Outputting
permalink: /:categories/:title/
@ -177,12 +178,32 @@ paginate: 5 # amount of posts to show
paginate_path: /page:num/
timezone: America/New_York # http://en.wikipedia.org/wiki/List_of_tz_database_time_zones
# Archive Page Filenames (example: <base_path>/archive-filename/ ~> "archive-filename")
tags_archive_filename : "tag-archive"
categories_archive_filename : "category-archive"
# Archives
# Type
# - GitHub Pages compatible archive pages built with Liquid ~> type: liquid (default)
# - Jekyll Archives plugin archive pages ~> type: jekyll-archives
# Path
# - <base_path>/tags/my-awesome-tag/index.html ~> path: /tags/
categories:
type: liquid
path: /categories/
tags:
type: liquid
path: /tags/
# https://github.com/jekyll/jekyll-archives
# jekyll-archives:
# enabled:
# - categories
# - tags
# layouts:
# category: archive-taxonomy
# tag: archive-taxonomy
# permalinks:
# category: /categories/:name/
# tag: /tags/:name/
# HTML Compression
# http://jch.penibelst.de/
# - http://jch.penibelst.de/
compress_html:
clippings: all
ignore:

View file

@ -7,10 +7,10 @@
url: /year-archive/
- title: "Categories"
url: /category-archive/
url: /categories/
- title: "Tags"
url: /tag-archive/
url: /tags/
- title: "Pages"
url: /page-archive/

View file

@ -0,0 +1,26 @@
{% include base_path %}
{% case site.categories.type %}
{% when "liquid" %}
{% assign path_type = "#" %}
{% when "jekyll-archives" %}
{% assign path_type = nil %}
{% endcase %}
{% if site.categories.path %}
{% comment %}
<!-- Sort alphabetically regardless of case e.g. a B c d E -->
<!-- modified from http://www.codeofclimber.ru/2015/sorting-site-tags-in-jekyll/ -->
{% endcomment %}
{% capture page_categories %}{% for category in page.categories %}{{ category | downcase }}#{{ category }}{% unless forloop.last %},{% endunless %}{% endfor %}{% endcapture %}
{% assign category_hashes = (page_categories | split: ',' | sort:0) %}
<p class="page__taxonomy"><strong>{{ site.data.ui-text[site.locale].categories_label }}</strong> <span itemprop="keywords">
{% for hash in category_hashes %}
{% assign keyValue = hash | split: '#' %}
{% capture category_word %}{{ keyValue[1] | strip_newlines }}{% endcapture %}
<a href="{{ base_path }}{{ category_word | slugify | prepend: path_type | prepend: site.categories.path }}" class="page__taxonomy-item" rel="tag">{{ category_word }}</a>{% unless forloop.last %}, {% endunless %}
{% endfor %}
</span>
</p>
{% endif %}

View file

@ -1,38 +1,7 @@
{% include base_path %}
{% comment %}
<!-- Sort page.tags alphabetically regardless of case e.g. a B c d E -->
<!-- modified from http://www.codeofclimber.ru/2015/sorting-site-tags-in-jekyll/ -->
{% endcomment %}
{% if page.tags[0] %}
{% if site.tags_archive_filename %}
{% capture page_tags %}{% for tag in page.tags %}{{ tag | downcase }}#{{ tag }}{% unless forloop.last %},{% endunless %}{% endfor %}{% endcapture %}
{% assign tag_hashes = (page_tags | split: ',' | sort:0) %}
<p class="page__taxonomy"><strong>{{ site.data.ui-text[site.locale].tags_label }}</strong> <span itemprop="keywords">
{% for hash in tag_hashes %}
{% assign keyValue = hash | split: '#' %}
{% capture tag_word %}{{ keyValue[1] | strip_newlines }}{% endcapture %}
<a href="{{ base_path }}{{ tag_word | slugify | prepend: '/#' | prepend: site.tags_archive_filename | prepend: "/" }}" class="page__taxonomy-item" rel="tag">{{ tag_word }}</a>{% unless forloop.last %}, {% endunless %}
{% endfor %}
</span>
</p>
{% endif %}
{% include tag-list.html %}
{% endif %}
{% if page.categories[0] %}
{% if site.categories_archive_filename %}
{% capture page_categories %}{% for category in page.categories %}{{ category | downcase }}#{{ category }}{% unless forloop.last %},{% endunless %}{% endfor %}{% endcapture %}
{% assign category_hashes = (page_categories | split: ',' | sort:0) %}
<p class="page__taxonomy"><strong>{{ site.data.ui-text[site.locale].categories_label }}</strong> <span itemprop="keywords">
{% for hash in category_hashes %}
{% assign keyValue = hash | split: '#' %}
{% capture category_word %}{{ keyValue[1] | strip_newlines }}{% endcapture %}
<a href="{{ base_path }}{{ category_word | slugify | prepend: '/#' | prepend: site.categories_archive_filename | prepend: "/" }}" class="page__taxonomy-item" rel="tag">{{ category_word }}</a>{% unless forloop.last %}, {% endunless %}
{% endfor %}
</span>
</p>
{% endif %}
{% include category-list.html %}
{% endif %}

26
_includes/tag-list.html Normal file
View file

@ -0,0 +1,26 @@
{% include base_path %}
{% case site.tags.type %}
{% when "liquid" %}
{% assign path_type = "#" %}
{% when "jekyll-archives" %}
{% assign path_type = nil %}
{% endcase %}
{% if site.tags.path %}
{% comment %}
<!-- Sort alphabetically regardless of case e.g. a B c d E -->
<!-- modified from http://www.codeofclimber.ru/2015/sorting-site-tags-in-jekyll/ -->
{% endcomment %}
{% capture page_tags %}{% for tag in page.tags %}{{ tag | downcase }}#{{ tag }}{% unless forloop.last %},{% endunless %}{% endfor %}{% endcapture %}
{% assign tag_hashes = (page_tags | split: ',' | sort:0) %}
<p class="page__taxonomy"><strong>{{ site.data.ui-text[site.locale].tags_label }}</strong> <span itemprop="keywords">
{% for hash in tag_hashes %}
{% assign keyValue = hash | split: '#' %}
{% capture tag_word %}{{ keyValue[1] | strip_newlines }}{% endcapture %}
<a href="{{ base_path }}{{ tag_word | slugify | prepend: path_type | prepend: site.tags.path }}" class="page__taxonomy-item" rel="tag">{{ tag_word }}</a>{% unless forloop.last %}, {% endunless %}
{% endfor %}
</span>
</p>
{% endif %}

View file

@ -0,0 +1,12 @@
---
layout: default
author_profile: false
---
<div class="archive">
<h1 class="page__title">{{ page.title }}</h1>
{% include base_path %}
{% for post in page.posts %}
{% include archive-list-single.html %}
{% endfor %}
</div><!-- /.archive -->

View file

@ -1,6 +1,6 @@
---
layout: archive
permalink: /category-archive/
permalink: /categories/
title: "Posts by Category"
author_profile: false
---

View file

@ -1,6 +1,6 @@
---
layout: archive
permalink: /tag-archive/
permalink: /tags/
title: "Posts by Tags"
author_profile: false
---