From 3aa50cc5a5c2075795d157d2626e06a3ce6fc9cc Mon Sep 17 00:00:00 2001 From: Michael Rose <est.michael@gmail.com> Date: Fri, 11 Mar 2016 09:39:20 -0500 Subject: [PATCH] Add support for Jekyll Archives plugin - Option to select GitHub Pages compatible tag/category page archive or plugin generated archives --- Gemfile | 1 + _config.yml | 31 +++++++++++++++++++++++++----- _data/navigation.yml | 4 ++-- _includes/category-list.html | 26 +++++++++++++++++++++++++ _includes/page__taxonomy.html | 35 ++-------------------------------- _includes/tag-list.html | 26 +++++++++++++++++++++++++ _layouts/archive-taxonomy.html | 12 ++++++++++++ _pages/category-archive.html | 2 +- _pages/tag-archive.html | 2 +- 9 files changed, 97 insertions(+), 42 deletions(-) create mode 100644 _includes/category-list.html create mode 100644 _includes/tag-list.html create mode 100644 _layouts/archive-taxonomy.html diff --git a/Gemfile b/Gemfile index a7743bf..62e0820 100644 --- a/Gemfile +++ b/Gemfile @@ -1,4 +1,5 @@ source "https://rubygems.org" gem "github-pages" +# gem "jekyll-archives" gem "wdm", "~> 0.1.0" if Gem.win_platform? \ No newline at end of file diff --git a/_config.yml b/_config.yml index b7ecdea..3e3ca0a 100644 --- a/_config.yml +++ b/_config.yml @@ -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: diff --git a/_data/navigation.yml b/_data/navigation.yml index cc56170..2514253 100644 --- a/_data/navigation.yml +++ b/_data/navigation.yml @@ -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/ diff --git a/_includes/category-list.html b/_includes/category-list.html new file mode 100644 index 0000000..3f8a485 --- /dev/null +++ b/_includes/category-list.html @@ -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 %} \ No newline at end of file diff --git a/_includes/page__taxonomy.html b/_includes/page__taxonomy.html index f99ce08..a77f1d0 100644 --- a/_includes/page__taxonomy.html +++ b/_includes/page__taxonomy.html @@ -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 %} \ No newline at end of file diff --git a/_includes/tag-list.html b/_includes/tag-list.html new file mode 100644 index 0000000..b721131 --- /dev/null +++ b/_includes/tag-list.html @@ -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 %} \ No newline at end of file diff --git a/_layouts/archive-taxonomy.html b/_layouts/archive-taxonomy.html new file mode 100644 index 0000000..6b677ca --- /dev/null +++ b/_layouts/archive-taxonomy.html @@ -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 --> \ No newline at end of file diff --git a/_pages/category-archive.html b/_pages/category-archive.html index 350b534..b9dc962 100644 --- a/_pages/category-archive.html +++ b/_pages/category-archive.html @@ -1,6 +1,6 @@ --- layout: archive -permalink: /category-archive/ +permalink: /categories/ title: "Posts by Category" author_profile: false --- diff --git a/_pages/tag-archive.html b/_pages/tag-archive.html index 1240330..221cc66 100644 --- a/_pages/tag-archive.html +++ b/_pages/tag-archive.html @@ -1,6 +1,6 @@ --- layout: archive -permalink: /tag-archive/ +permalink: /tags/ title: "Posts by Tags" author_profile: false --- -- 2.45.2