Add posts, categories, category, tags, tag, and collection layouts
Replace sample pages with hard coded HTML and Liquid in favor of a layout that does all the heavy lifting. Assign the appropriate `layout` via YAML Front Matter and away you go.
This commit is contained in:
48
_layouts/categories.html
Normal file
48
_layouts/categories.html
Normal file
@@ -0,0 +1,48 @@
|
||||
---
|
||||
layout: archive
|
||||
---
|
||||
|
||||
{{ content }}
|
||||
|
||||
<ul class="taxonomy-index">
|
||||
{% assign categories_max = 0 %}
|
||||
{% for category in site.categories %}
|
||||
{% if category[1].size > categories_max %}
|
||||
{% assign categories_max = category[1].size %}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{% for i in (1..categories_max) reversed %}
|
||||
{% for category in site.categories %}
|
||||
{% if category[1].size == i %}
|
||||
<li>
|
||||
<a href="#{{ category[0] | slugify }}">
|
||||
<strong>{{ category[0] }}</strong> <span class="taxonomy-count">{{ i }}</span>
|
||||
</a>
|
||||
</li>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{% endfor %}
|
||||
</ul>
|
||||
|
||||
{% assign categories_max = 0 %}
|
||||
{% for category in site.categories %}
|
||||
{% if category[1].size > categories_max %}
|
||||
{% assign categories_max = category[1].size %}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
|
||||
{% for i in (1..categories_max) reversed %}
|
||||
{% for category in site.categories %}
|
||||
{% if category[1].size == i %}
|
||||
<section id="{{ category[0] | slugify | downcase }}" class="taxonomy-section">
|
||||
<h2 class="archive__subtitle">{{ category[0] }}</h2>
|
||||
<div class="entries-{{ page.entries_layout | default: 'list' }}">
|
||||
{% for post in category.last %}
|
||||
{% include archive-single.html %}
|
||||
{% endfor %}
|
||||
</div>
|
||||
<a href="#page-title" class="back-to-top">{{ site.data.text[site.locale].back_to_top | default: 'Back to Top' }} ↑</a>
|
||||
</section>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{% endfor %}
|
||||
9
_layouts/category.html
Normal file
9
_layouts/category.html
Normal file
@@ -0,0 +1,9 @@
|
||||
---
|
||||
layout: archive
|
||||
---
|
||||
|
||||
{{ content }}
|
||||
|
||||
<div class="entries-{{ page.entries_layout | default: 'list' }}">
|
||||
{% include posts-category.html taxonomy=page.taxonomy %}
|
||||
</div>
|
||||
9
_layouts/collection.html
Normal file
9
_layouts/collection.html
Normal file
@@ -0,0 +1,9 @@
|
||||
---
|
||||
layout: archive
|
||||
---
|
||||
|
||||
{{ content }}
|
||||
|
||||
<div class="entries-{{ page.entries_layout | default: 'list' }}">
|
||||
{% include documents-collection.html collection=page.collection sort_by=page.sort_by sort_order=page.sort_order %}
|
||||
</div>
|
||||
29
_layouts/posts.html
Normal file
29
_layouts/posts.html
Normal file
@@ -0,0 +1,29 @@
|
||||
---
|
||||
layout: archive
|
||||
---
|
||||
|
||||
{{ content }}
|
||||
|
||||
<ul class="taxonomy-index">
|
||||
{% assign postsInYear = site.posts | group_by_exp: 'post', 'post.date | date: "%Y"' %}
|
||||
{% for year in postsInYear %}
|
||||
<li>
|
||||
<a href="#{{ year.name }}">
|
||||
<strong>{{ year.name }}</strong> <span class="taxonomy-count">{{ year.items | size }}</span>
|
||||
</a>
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
|
||||
{% assign postsByYear = site.posts | group_by_exp: 'post', 'post.date | date: "%Y"' %}
|
||||
{% for year in postsByYear %}
|
||||
<section id="{{ year.name }}" class="taxonomy-section">
|
||||
<h2 class="archive__subtitle">{{ year.name }}</h2>
|
||||
<div class="entries-{{ page.entries_layout | default: 'list' }}">
|
||||
{% for post in year.items %}
|
||||
{% include archive-single.html %}
|
||||
{% endfor %}
|
||||
</div>
|
||||
<a href="#page-title" class="back-to-top">{{ site.data.text[site.locale].back_to_top | default: 'Back to Top' }} ↑</a>
|
||||
</section>
|
||||
{% endfor %}
|
||||
9
_layouts/tag.html
Normal file
9
_layouts/tag.html
Normal file
@@ -0,0 +1,9 @@
|
||||
---
|
||||
layout: archive
|
||||
---
|
||||
|
||||
{{ content }}
|
||||
|
||||
<div class="entries-{{ page.entries_layout | default: 'list' }}">
|
||||
{% include posts-tag.html taxonomy=page.taxonomy %}
|
||||
</div>
|
||||
48
_layouts/tags.html
Normal file
48
_layouts/tags.html
Normal file
@@ -0,0 +1,48 @@
|
||||
---
|
||||
layout: archive
|
||||
---
|
||||
|
||||
{{ content }}
|
||||
|
||||
<ul class="taxonomy-index">
|
||||
{% assign tags_max = 0 %}
|
||||
{% for tag in site.tags %}
|
||||
{% if tag[1].size > tags_max %}
|
||||
{% assign tags_max = tag[1].size %}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{% for i in (1..tags_max) reversed %}
|
||||
{% for tag in site.tags %}
|
||||
{% if tag[1].size == i %}
|
||||
<li>
|
||||
<a href="#{{ tag[0] | slugify }}">
|
||||
<strong>{{ tag[0] }}</strong> <span class="taxonomy-count">{{ i }}</span>
|
||||
</a>
|
||||
</li>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{% endfor %}
|
||||
</ul>
|
||||
|
||||
{% assign tags_max = 0 %}
|
||||
{% for tag in site.tags %}
|
||||
{% if tag[1].size > tags_max %}
|
||||
{% assign tags_max = tag[1].size %}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
|
||||
{% for i in (1..tags_max) reversed %}
|
||||
{% for tag in site.tags %}
|
||||
{% if tag[1].size == i %}
|
||||
<section id="{{ tag[0] | slugify | downcase }}" class="taxonomy-section">
|
||||
<h2 class="archive__subtitle">{{ tag[0] }}</h2>
|
||||
<div class="entries-{{ page.entries_layout | default: 'list' }}">
|
||||
{% for post in tag.last %}
|
||||
{% include archive-single.html %}
|
||||
{% endfor %}
|
||||
</div>
|
||||
<a href="#page-title" class="back-to-top">{{ site.data.text[site.locale].back_to_top | default: 'Back to Top' }} ↑</a>
|
||||
</section>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{% endfor %}
|
||||
Reference in New Issue
Block a user