From c71992e1c488ea29d6ecdee13a912e7fe1aae201 Mon Sep 17 00:00:00 2001 From: Michael Rose Date: Wed, 24 Feb 2016 22:08:59 -0500 Subject: [PATCH] Add archives for pages and posts by [category, year, tags] --- _layouts/archive.html | 20 +------------------- _pages/category-archive.md | 24 ++++++++++++++++++++++++ _pages/page-archive.md | 16 ++++++++++++++++ _pages/posts.md | 6 ------ _pages/tag-archive.md | 23 +++++++++++++++++++++++ _pages/year-archive.html | 22 ++++++++++++++++++++++ 6 files changed, 86 insertions(+), 25 deletions(-) create mode 100644 _pages/category-archive.md create mode 100644 _pages/page-archive.md delete mode 100644 _pages/posts.md create mode 100644 _pages/tag-archive.md create mode 100644 _pages/year-archive.html diff --git a/_layouts/archive.html b/_layouts/archive.html index 1bbfeecc..9f03103f 100644 --- a/_layouts/archive.html +++ b/_layouts/archive.html @@ -1,25 +1,7 @@ --- layout: default --- - -{% include absolute-url.liquid %} -

{{ page.title }}

- {% capture written_year %}'None'{% endcapture %} - {% for post in site.posts %} - {% capture year %}{{ post.date | date: '%Y' }}{% endcapture %} - {% if year != written_year %} -

{{ year }}

- {% capture written_year %}{{ year }}{% endcapture %} - {% endif %} -
- {% if post.link %} -

{{ post.title }}

- {% else %} -

{{ post.title }}

-

{{ post.excerpt | markdownify | strip_html | strip_newlines | escape_once }}

- {% endif %} -
- {% endfor %} + {{ content }}
\ No newline at end of file diff --git a/_pages/category-archive.md b/_pages/category-archive.md new file mode 100644 index 00000000..58ac70ac --- /dev/null +++ b/_pages/category-archive.md @@ -0,0 +1,24 @@ +--- +layout: archive +permalink: /category-archive/ +title: "Posts by Category" +--- + +{% include absolute-url.liquid %} +{% capture site_categories %}{% for category in site.categories %}{{ category | first }}{% unless forloop.last %},{% endunless %}{% endfor %}{% endcapture %} +{% assign category_list = site_categories | split:',' | sort %} + +{% for item in (0..site.categories.size) %}{% unless forloop.last %} +{% capture category_name %}{{ category_list[item] | strip_newlines }}{% endcapture %} +

{{ category_name }}

+ {% for post in site.categories[category_name] %}{% if post.title != null %} +
+ {% if post.link %} +

{{ post.title }}

+ {% else %} +

{{ post.title }}

+

{{ post.excerpt | markdownify | strip_html | strip_newlines | escape_once }}

+ {% endif %} +
+ {% endif %}{% endfor %} +{% endunless %}{% endfor %} \ No newline at end of file diff --git a/_pages/page-archive.md b/_pages/page-archive.md new file mode 100644 index 00000000..5ff806a1 --- /dev/null +++ b/_pages/page-archive.md @@ -0,0 +1,16 @@ +--- +layout: archive +title: "Page Archive" +permalink: /page-archive/ +--- +{% include absolute-url.liquid %} +{% for post in site.pages %} +
+{% if post.link %} +

{{ post.title }}

+{% else %} +

{{ post.title }}

+ {% if post.excerpt %}

{{ post.excerpt | markdownify | strip_html | strip_newlines | escape_once }}

{% endif %} +{% endif %} +
+{% endfor %} \ No newline at end of file diff --git a/_pages/posts.md b/_pages/posts.md deleted file mode 100644 index 678cd240..00000000 --- a/_pages/posts.md +++ /dev/null @@ -1,6 +0,0 @@ ---- -layout: archive -permalink: /posts/ -title: "All Posts" -excerpt: "A List of Posts" ---- \ No newline at end of file diff --git a/_pages/tag-archive.md b/_pages/tag-archive.md new file mode 100644 index 00000000..006d69b9 --- /dev/null +++ b/_pages/tag-archive.md @@ -0,0 +1,23 @@ +--- +layout: archive +permalink: /tag-archive/ +title: "Posts by Tags" +--- +{% include absolute-url.liquid %} +{% capture site_tags %}{% for tag in site.tags %}{{ tag | first }}{% unless forloop.last %},{% endunless %}{% endfor %}{% endcapture %} +{% assign tag_list = site_tags | split:',' | sort %} + +{% for item in (0..site.tags.size) %}{% unless forloop.last %} +{% capture tag_name %}{{ tag_list[item] | strip_newlines }}{% endcapture %} +

{{ tag_name }}

+ {% for post in site.tags[tag_name] %}{% if post.title != null %} +
+ {% if post.link %} +

{{ post.title }}

+ {% else %} +

{{ post.title }}

+

{{ post.excerpt | markdownify | strip_html | strip_newlines | escape_once }}

+ {% endif %} +
+ {% endif %}{% endfor %} +{% endunless %}{% endfor %} \ No newline at end of file diff --git a/_pages/year-archive.html b/_pages/year-archive.html new file mode 100644 index 00000000..ebf708cd --- /dev/null +++ b/_pages/year-archive.html @@ -0,0 +1,22 @@ +--- +layout: archive +permalink: /year-archive/ +title: "Posts by Year" +--- +{% include absolute-url.liquid %} +{% capture written_year %}'None'{% endcapture %} +{% for post in site.posts %} + {% capture year %}{{ post.date | date: '%Y' }}{% endcapture %} + {% if year != written_year %} +

{{ year }}

+ {% capture written_year %}{{ year }}{% endcapture %} + {% endif %} +
+ {% if post.link %} +

{{ post.title }}

+ {% else %} +

{{ post.title }}

+

{{ post.excerpt | markdownify | strip_html | strip_newlines | escape_once }}

+ {% endif %} +
+{% endfor %} \ No newline at end of file