~xdavidwu/xdavidwu.link

3aa50cc5a5c2075795d157d2626e06a3ce6fc9cc — Michael Rose 9 years ago 1ccd5f6
Add support for Jekyll Archives plugin
- Option to select GitHub Pages compatible tag/category page archive or plugin generated archives
M Gemfile => Gemfile +1 -0
@@ 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

M _config.yml => _config.yml +26 -5
@@ 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:

M _data/navigation.yml => _data/navigation.yml +2 -2
@@ 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/

A _includes/category-list.html => _includes/category-list.html +26 -0
@@ 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

M _includes/page__taxonomy.html => _includes/page__taxonomy.html +2 -33
@@ 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

A _includes/tag-list.html => _includes/tag-list.html +26 -0
@@ 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

A _layouts/archive-taxonomy.html => _layouts/archive-taxonomy.html +12 -0
@@ 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

M _pages/category-archive.html => _pages/category-archive.html +1 -1
@@ 1,6 1,6 @@
---
layout: archive
permalink: /category-archive/
permalink: /categories/
title: "Posts by Category"
author_profile: false
---

M _pages/tag-archive.html => _pages/tag-archive.html +1 -1
@@ 1,6 1,6 @@
---
layout: archive
permalink: /tag-archive/
permalink: /tags/
title: "Posts by Tags"
author_profile: false
---