Skip to content

Commit

Permalink
Merge pull request #866 from Queen-codes/blog-refactor
Browse files Browse the repository at this point in the history
refactored blog page to align with vocabulary markup
  • Loading branch information
TimidRobot authored Jan 6, 2025
2 parents 640995f + 842d2dd commit e0a33c0
Show file tree
Hide file tree
Showing 6 changed files with 125 additions and 115 deletions.
25 changes: 15 additions & 10 deletions themes/vocabulary_theme/templates/blog-category.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,21 @@

{% block title %}{{ this.name }}{% endblock %}

{% from "macros/categories.html" import render_categories %}

{% block body %}
<div class="all-categories">
<div class="header">
<div class="container">
<h1>All posts categorized "{{ this.name }}"</h1>
<a class="button small margin-top-bigger" href="{{ this.parent|url }}">See all categories</a>
</div>
</div>
<div class="categories-list container">
{{ render_posts(this.children) }}
</div>
<header>
<h1>Category: {{ this.name|capitalize }} </h1>
</header>

<aside class="sidebar">
<nav class="filter-menu" aria-labelledby="categories">
<h2>Categories</h2>
{{ render_categories(this.parent) }}
</nav>
</aside>

<div>
{{ render_posts(this.children) }}
</div>
{% endblock %}
133 changes: 74 additions & 59 deletions themes/vocabulary_theme/templates/blog-post.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,63 +6,78 @@
{% block title %}{{ this.title }}{% endblock %}

{% block body %}
<div class="single-post">
<header class="single-post-header">
<div class="container">
<h4>CC Open Source Blog</h4>
<h2 class="title">{{ this.title }}</h2>
<div class="author columns is-marginless">
{{ render_author_gravatar(this)|trim }}
<p class="padding-small">
{{ render_authors_byline(this)|trim }}
</p>
</div>
{% if this.series|length %}
{% set series = this.parent.parent.children.get('series').children.get(this.series) %}
<div class="series-header">
<span>This blog is part of the series:</span>
<a href="#series">{{ series.name }}</a>
</div>
{% endif %}
</div>
</header>
<div class="single-post-body content container">
{{ this.body }}
</div>
<footer class="single-post-footer container">
<div class="category">
<h4 class="category-title">Categories</h4>
<div class="categories">
{% if this.categories|length %}
{% for category in this.categories %}
{% set current_category = this.parent.parent.children.get('categories').children.get(category) %}
{{ check_file('content' + this.parent.parent.path + '/categories/' + category + '/contents.lr') }}
<a class="button tag" href=" {{ current_category|url }} ">{{ category }}</a>
{% endfor %}
{% else %}
none
{% endif %}
</div>
</div>
{% if this.series|length %}
<div class="series-posts" id="series">
<h5 class="title">Posts in the {{ series.name }} series</h5>
<ul class="posts">
{% for post in series.children.order_by('pub_date') %}
{% if post.path==this.path %}
<li class="has-color-dark-slate-gray">
<i class="icon circle-filled"></i>{{ post.title }}
</li>
{% else %}
<li>
<i class="icon circle-filled"></i><a href="{{ post|url }}">{{ post.title }}</a>
</li>
{% endif %}
{% endfor %}
</ul>
</div>
{% endif %}
<div class="comments">{{ render_disqus_comments() }}</div>
</footer>
</div>
<header>
<h1>{{ this.title }}</h1>
<span class="byline"><a>{{ render_authors_byline(this)|trim }}</a></span>
<span class="categories">
{% if this.categories|length %}
{% for category in this.categories %}
{% set current_category = this.parent.parent.children.get('categories').children.get(category) %}
{{ check_file('content' + this.parent.parent.path + '/categories/' + category + '/contents.lr') }}
<a href="{{ current_category|url }}">{{ category }}</a>
{% endfor %}
{% else %}
none
{% endif %}
</span>
</header>

<!-- TODO: IF EXCERPT IS TO BE INCLUDED, ADD EXCERPT HERE -->
<!--
<aside class="opening">
<p> </p>
</aside>
-->

<div>{{ this.body }}</div>

{% if this.series|length %}
{% set series = this.parent.parent.children.get('series').children.get(this.series) %}
<aside>
<p>This blog is part of the series:</p>
<a href="#series">{{ series.name }}</a>
</aside>

<article class="posts related">
<h2>Related posts</h2>
<ul>
{% for post in series.children.order_by('pub_date') %}
<li>
<article class="post">
<header>
<h3><a href="{{ post|url }}">{{ post.title }}</a></h3>
<span class="byline">{{ render_authors_byline(post)|trim }}</span>
<span class="categories">
{% if post.categories|length %}
{% for category in post.categories %}
{% set current_category = this.parent.parent.children.get('categories').children.get(category) %}
<a href="{{ current_category|url }}">{{ category }}</a>
{% endfor %}
{% else %}
none
{% endif %}
</span>
</header>
</article>
</li>
{% endfor %}
</ul>
</article>
{% endif %}

<article class="tags">
<h2>Tags</h2>
<ul>
{% if this.categories|length %}
{% for category in this.categories %}
{% set current_category = this.parent.parent.children.get('categories').children.get(category) %}
<li><a href="{{ current_category|url }}">{{ category }}</a></li>
{% endfor %}
{% else %}
<li>none</li>
{% endif %}
</ul>
</article>

<div class="comments">{{ render_disqus_comments() }}</div>
{% endblock %}
30 changes: 14 additions & 16 deletions themes/vocabulary_theme/templates/blog.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,18 @@
{% block title %}{{ this.title }}{% endblock %}

{% block body %}
<div class="blog-page">
<div class="header">
<div class="container">
<h1>{{ this.title }}</h1>
<div class="description column is-9 is-paddingless">{{ this.description }}</div>
</div>
</div>
<div class="container blog-page-posts">
{{ render_posts(this.pagination.items) }}
<div class="pagination-wrapper">
{% if this.pagination.pages > 1 %}
{{ render_pagination(this.pagination) }}
{% endif %}
</div>
</div>
</div>
<header>
<h1>{{ this.title }}</h1>
<p>{{ this.description }}</p>
</header>

<article class="posts featured">
<h2>Featured posts</h2>
{{ render_posts(this.pagination.items) }}
</article>

{% if this.pagination.pages > 1 %}
{{ render_pagination(this.pagination) }}
{% endif %}

{% endblock %}
10 changes: 7 additions & 3 deletions themes/vocabulary_theme/templates/macros/categories.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
{% from "macros/posts.html" import render_posts %}

{% macro render_categories(categories) %}
{% for category in site.query(categories.path) %}
<a class="button tag margin-vertical-small margin-horizontal-smaller" href="{{ category|url }}">{{ category.name }}</a>
{% endfor %}
<ul>
{% for category in site.query(categories.path) %}
<li>
<a href="{{ category|url }}">{{ category.name }}</a>
</li>
{% endfor %}
</ul>
{% endmacro %}
38 changes: 13 additions & 25 deletions themes/vocabulary_theme/templates/macros/pagination.html
Original file line number Diff line number Diff line change
@@ -1,27 +1,15 @@
{% macro render_pagination(pagination) %}
<nav class="pagination" role="navigation" aria-label="pagination">
<ul class="pagination-list">
{% if pagination.has_prev %}
<li class="inactive">
<a class="pagination-link inactive-link" href="{{ pagination.prev|url }}" aria-label="Goto previous"><i class="icon chevron-left"></i></a>
</li>
{% endif %}
{% for p in range(pagination.pages) %}
{% if pagination.current|url == pagination.for_page(p+1)|url %}
<li class="common">
<a class="pagination-link is-current common-link" aria-label="Goto page {{p+1}}" aria-current="page" href="{{ pagination.for_page(p+1)|url}}">{{p+1}}</a>
</li>
{% else %}
<li class="inactive">
<a class="pagination-link inactive-link" aria-label="Goto page {{p+1}}" href="{{ pagination.for_page(p+1)|url}}">{{p+1}}</a>
</li>
{% endif %}
{% endfor %}
{% if pagination.has_next %}
<li class="inactive">
<a class="pagination-link inactive-link" href="{{ pagination.next|url }}" aria-label="Goto next"><i class="icon chevron-right"></i></a>
</li>
{% endif %}
</ul>
</nav>
<nav class="pagination">
<ol>
{% if pagination.has_prev %}
<li><a href="{{ pagination.prev|url }}">&lt;</a></li>
{% endif %}
{% for page in range(pagination.pages) %}
<li class="{% if page + 1 == pagination.current %}current{% endif %}"><a href="{{ pagination.for_page(page + 1)|url }}">{{ page + 1 }}</a></li>
{% endfor %}
{% if pagination.has_next %}
<li><a href="{{ pagination.next|url }}">&gt;</a></li>
{% endif %}
</ol>
</nav>
{% endmacro %}
4 changes: 2 additions & 2 deletions themes/vocabulary_theme/templates/macros/posts.html
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ <h3 class="title"><a href="{{ post|url }}">{{ post.title }}</a></h3>
{% endmacro %}

{% macro render_posts(posts) %}
<div class="columns is-multiline blog-entries">
<ul>
{% for post in posts %}
{% set post_loop = loop %}
{{ render_post_summary(post) }}
{% endfor %}
</div>
</ul>
{% endmacro %}

0 comments on commit e0a33c0

Please sign in to comment.