From 3aa50cc5a5c2075795d157d2626e06a3ce6fc9cc Mon Sep 17 00:00:00 2001 From: Michael Rose 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 a7743bf4..62e0820d 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 b7ecdea5..3e3ca0ab 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: /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 +# - /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 cc561708..2514253b 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 00000000..3f8a4857 --- /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 %} + + + {% 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) %} + +

{{ site.data.ui-text[site.locale].categories_label }} + {% for hash in category_hashes %} + {% assign keyValue = hash | split: '#' %} + {% capture category_word %}{{ keyValue[1] | strip_newlines }}{% endcapture %} + {% unless forloop.last %}, {% endunless %} + {% endfor %} + +

+{% endif %} \ No newline at end of file diff --git a/_includes/page__taxonomy.html b/_includes/page__taxonomy.html index f99ce089..a77f1d0f 100644 --- a/_includes/page__taxonomy.html +++ b/_includes/page__taxonomy.html @@ -1,38 +1,7 @@ -{% include base_path %} - -{% comment %} - - -{% 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) %} - -

{{ site.data.ui-text[site.locale].tags_label }} - {% for hash in tag_hashes %} - {% assign keyValue = hash | split: '#' %} - {% capture tag_word %}{{ keyValue[1] | strip_newlines }}{% endcapture %} - {% unless forloop.last %}, {% endunless %} - {% endfor %} - -

- {% 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) %} - -

{{ site.data.ui-text[site.locale].categories_label }} - {% for hash in category_hashes %} - {% assign keyValue = hash | split: '#' %} - {% capture category_word %}{{ keyValue[1] | strip_newlines }}{% endcapture %} - {% unless forloop.last %}, {% endunless %} - {% endfor %} - -

- {% 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 00000000..b721131c --- /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 %} + + + {% 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) %} + +

{{ site.data.ui-text[site.locale].tags_label }} + {% for hash in tag_hashes %} + {% assign keyValue = hash | split: '#' %} + {% capture tag_word %}{{ keyValue[1] | strip_newlines }}{% endcapture %} + {% unless forloop.last %}, {% endunless %} + {% endfor %} + +

+{% endif %} \ No newline at end of file diff --git a/_layouts/archive-taxonomy.html b/_layouts/archive-taxonomy.html new file mode 100644 index 00000000..6b677ca4 --- /dev/null +++ b/_layouts/archive-taxonomy.html @@ -0,0 +1,12 @@ +--- +layout: default +author_profile: false +--- + +
+

{{ page.title }}

+ {% include base_path %} + {% for post in page.posts %} + {% include archive-list-single.html %} + {% endfor %} +
\ No newline at end of file diff --git a/_pages/category-archive.html b/_pages/category-archive.html index 350b534d..b9dc962f 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 1240330d..221cc661 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 ---