pages for each category and tag!

This commit is contained in:
Lynne Megido 2020-04-06 15:03:07 +10:00
parent 9bb15c97d7
commit 1e6538ac5a
Signed by: lynnesbian
GPG key ID: F0A184B5213D9F90
6 changed files with 70 additions and 37 deletions

View file

@ -13,6 +13,25 @@ pagination:
sort_field: 'date' sort_field: 'date'
sort_reverse: true sort_reverse: true
autopages:
enabled: true
categories:
layouts:
- pagination.html
title: "Category: :cat"
permalink: /categories/:cat
tags:
layouts:
- pagination.html
title: "Posts tagged with :tag"
permalink: /tags/:tag
collections:
enabled: false
defaults: defaults:
- scope: - scope:
path: "" path: ""

View file

@ -3,9 +3,9 @@
<img id='header-logo' src='/favicon.png' alt=''> <img id='header-logo' src='/favicon.png' alt=''>
<h1><a href='/'>Bune City Blog</a></h1> <h1><a href='/'>Bune City Blog</a></h1>
<nav> <nav>
<a href='/'>Categories</a> <a href='/categories.html'>Categories</a>
<a href='/'>Tags</a> <a href='/tags.html'>Tags</a>
<a href='/'>lynnesbian.space</a> <a href='https://lynnesbian.space'>lynnesbian.space</a>
</nav> </nav>
</div> </div>
</header> </header>

36
_layouts/pagination.html Normal file
View file

@ -0,0 +1,36 @@
---
layout: default
---
{% include header.html %}
<h1 id='logo'>{{ site.title }}</h1>
{%- if page.autopages %}
<div id='subheading'>Posts in category "{{ page.autopages.display_name }}"</div>
{% endif -%}
<main>
<div id='posts'>
{% for post in paginator.posts %}
<div class='post'>
<h2><a href='{{ post.url }}'>{{ post.title }}</a></h2>
<div id='post-info'>
<i class='material-icons'>access_time</i> {{ post.date | date_to_string: "ordinal" }}
<i class='material-icons'>group_work</i>
{{ " " }}{%- for category in post.categories -%}
<a href='/categories/{{ category | downcase }}'>{{ category }}</a>
{%- unless category == post.categories.last %}, {% endunless %}
{%- endfor %} <br>
</div>
<div class='post-excerpt'>
<p>{{ post.summary | default: post.excerpt }}</p>
</div>
</div>
{% endfor %}
{%- if paginator.total_pages > 1 %}
<div id='pagination'>
<a {%- if paginator.previous_page %} href='{{ paginator.previous_page_path | absolute_url }}' {%- endif %}>Newer</a>
Page {{ paginator.page }} of {{ paginator.total_pages }}
<a {%- if paginator.next_page %} href='{{ paginator.next_page_path | absolute_url }}' {%- endif %}>Older</a>
</div>
{%- endif %}
</div>
</main>

View file

@ -9,12 +9,12 @@ layout: default
<i class='material-icons'>access_time</i> Published {{ page.date | date_to_long_string: "ordinal" }} <br> <i class='material-icons'>access_time</i> Published {{ page.date | date_to_long_string: "ordinal" }} <br>
<i class='material-icons'>group_work</i> Categories: <i class='material-icons'>group_work</i> Categories:
{{ " " }}{%- for category in page.categories -%} {{ " " }}{%- for category in page.categories -%}
<a href='/categories/{{ category }}'>{{ category }}</a> <a href='/categories/{{ category | downcase }}'>{{ category }}</a>
{%- unless category == page.categories.last %}, {% endunless %} {%- unless category == page.categories.last %}, {% endunless %}
{%- endfor %} <br> {%- endfor %} <br>
<i class='material-icons'>label</i> Tags: <i class='material-icons'>label</i> Tags:
{{ " " }}{%- for tag in page.tags -%} {{ " " }}{%- for tag in page.tags -%}
<a href='/tags/{{ category }}'>{{ tag }}</a> <a href='/tags/{{ tag | downcase }}'>{{ tag }}</a>
{%- unless tag == page.tags.last %}, {% endunless %} {%- unless tag == page.tags.last %}, {% endunless %}
{%- endfor %} {%- endfor %}
</section> </section>
@ -43,7 +43,8 @@ layout: default
{%- unless summary %} {%- unless summary %}
{%- assign summary = page.excerpt | summarise | truncate: 150 %} {%- assign summary = page.excerpt | summarise | truncate: 150 %}
{%- endunless %} {%- endunless %}
<a class='post-share mastodon' target='_blank' href='/mastodon-share.html#Bune City Blog - {{ page.title }}%0A%0A{{ summary }}%0A{{ page.url | absolute_url }}%0A%23BuneCityBlog'></a> {%- assign summary = summary | escape %}
<a class='post-share mastodon' target='_blank' href='/mastodon-share.html#Bune City Blog - {{ page.title }}%0A%0A{{ summary }}%0A%0A{{ page.url | absolute_url }} %23BuneCityBlog'></a>
<a class='post-share email' target='_blank' href="mailto:?subject={{ page.title }} - Bune City Blog&amp;body=An interesting article I read on the Bune City Blog: {{ summary }} Read more: {{ page.url }}"></a> <a class='post-share email' target='_blank' href="mailto:?subject={{ page.title }} - Bune City Blog&amp;body=An interesting article I read on the Bune City Blog: {{ summary }} Read more: {{ page.url }}"></a>
</section> </section>
<section id='post-comments'> <section id='post-comments'>

View file

@ -13,6 +13,13 @@ h1#logo {
font-family: "Playfair Display", serif; font-family: "Playfair Display", serif;
} }
#subheading {
text-align: center;
font-family: serif;
font-size: 1.3em;
margin-top: -20px;
}
header { header {
font-family: sans-serif; font-family: sans-serif;
background: #fafafa; background: #fafafa;

View file

@ -1,36 +1,6 @@
--- ---
layout: default layout: pagination
title: "bune.city - Home" title: "bune.city - Home"
pagination: pagination:
enabled: true enabled: true
--- ---
{% include header.html %}
<h1 id='logo'>{{ site.title }}</h1>
<main>
<div id='posts'>
{% for post in paginator.posts %}
<div class='post'>
<h2><a href='{{ post.url }}'>{{ post.title }}</a></h2>
<div id='post-info'>
<i class='material-icons'>access_time</i> {{ post.date | date_to_string: "ordinal" }}
<i class='material-icons'>group_work</i>
{{ " " }}{%- for category in post.categories -%}
<a href='/categories/{{ category }}'>{{ category }}</a>
{%- unless category == post.categories.last %}, {% endunless %}
{%- endfor %} <br>
</div>
<div class='post-excerpt'>
<p>{{ post.summary | default: post.excerpt }}</p>
</div>
</div>
{% endfor %}
{%- if paginator.total_pages > 1 %}
<div id='pagination'>
<a {%- if paginator.previous_page %} href='{{ paginator.previous_page_path | absolute_url }}' {%- endif %}>Newer</a>
Page {{ paginator.page }} of {{ paginator.total_pages }}
<a {%- if paginator.next_page %} href='{{ paginator.next_page_path | absolute_url }}' {%- endif %}>Older</a>
</div>
{%- endif %}
</div>
</main>