Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for Authors taxonomy #17

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,11 @@ You can find installation instructions [on the Zola website](https://www.getzola

4. This theme uses the `tags` taxonomy, in your `config.toml` file set `taxonomies = [ { name = "tags" } ]`

5. Copy across the default content from the theme by running `cp themes/simple-dev-blog/content/* ./content -r`
5. This theme uses the `authors` taxonomy, in your `config.toml` file set `taxonomies = [ { name = "authors" } ]`

6. That's it! Now build your site by running the following command, and navigate to `127.0.0.1:111`:
6. Copy across the default content from the theme by running `cp themes/simple-dev-blog/content/* ./content -r`

7. That's it! Now build your site by running the following command, and navigate to `127.0.0.1:111`:

```sh
zola serve
Expand All @@ -61,6 +63,7 @@ The following options should be under the `[extra]` in `config.toml`
- `not_found_message` - the content for your 404 page in markdown
- `profile_large` - the path to a larger vertical version of your profile picture in the content folder
- `profile_small` - the path to a small version of your profile picture in the content folder
- `summary_truncate_length` - the length of a post's summary

### Page

Expand Down
2 changes: 2 additions & 0 deletions config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ taxonomies = [

dark_mode = false

summary_truncate_length = 300

nav = [
{ name = "About", path = "/about/" },
{ name = "Blog", path = "/blog/" }
Expand Down
9 changes: 8 additions & 1 deletion sass/main.scss
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ body {
}

.post-preview {
h3.post-title {
h2.post-title {
margin-bottom: 0;
}

Expand Down Expand Up @@ -108,3 +108,10 @@ table tbody tr:nth-of-type(even) {
table tbody tr:last-of-type {
border-bottom: 2px solid var(--accent-color);
}

hr.gradient-line {
height: 2px;
border: none;
border-radius: 10px;
background-image: linear-gradient(to right, #ffffff, var(--accent-color));
}
8 changes: 7 additions & 1 deletion sass/text.scss
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ a:visited {

main {
max-width: 700px;
padding-top: 8rem;
padding-top: 4rem;
margin: auto;
}

Expand Down Expand Up @@ -110,6 +110,7 @@ header {
margin: auto;
display: flex;
flex-direction: row;
align-items: center;
}

a.profile-icon {
Expand All @@ -123,6 +124,11 @@ a.profile-icon {
}
}

.profile-text {
padding-left: 1rem;
font-size: 1.5rem;
}

nav {
display: flex;
align-items: center;
Expand Down
3 changes: 2 additions & 1 deletion templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@
<title>
{% block title %}
{% if page.title %}
{{ page.title }}
{{ page.title | striptags }} :: {{ config.title }}
{% else %}
{{ config.title }}
{% endif %}
Expand All @@ -127,6 +127,7 @@
<a class="profile-icon" href="/">
<img src="{{ icon.url }}" alt="profile picture">
</a>
<span class="profile-text">{{ config.title }}</span>
<nav>
{% for link in config.extra.nav %}
<a href="{{ link.path }}">{{ link.name }}</a>
Expand Down
12 changes: 10 additions & 2 deletions templates/blog-post.html
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,19 @@
<h1>{{ page.title }}</h1>
<small>
{{ page.date | date(format="%B %d, %Y") }}
{% if page.taxonomies.authors %}
&nbsp;&centerdot;&nbsp; By
<span class="tags">
{% for author in page.taxonomies.authors %}
<a href="{{ get_taxonomy_url(kind="authors", name=author) }}">{{ author }}</a>{% if not loop.last %}, {% endif %}
{% endfor %}
</span>
{% endif %}
{% if page.taxonomies.tags %}
-
&nbsp;&centerdot;&nbsp; Filed under
<span class="tags">
{% for tag in page.taxonomies.tags %}
<a href="{{ get_taxonomy_url(kind="tags", name=tag) }}">{{ tag }}</a>
<a href="{{ get_taxonomy_url(kind="tags", name=tag) }}">{{ tag }}</a>{% if not loop.last %}, {% endif %}
{% endfor %}
</span>
{% endif %}
Expand Down
2 changes: 1 addition & 1 deletion templates/blog.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@
{{ section.content | safe }}

{% for post in section.pages %}
{{ post_macros::post_preview(post=post) }}
{{ post_macros::post_preview(post=post, summary_truncate_length=config.extra.summary_truncate_length) }}
{% endfor %}
{% endblock content %}
13 changes: 7 additions & 6 deletions templates/post-preview.html
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
{% macro post_preview(post) %}
{% macro post_preview(post, summary_truncate_length=300) %}
<div class="post-preview">
<h3 class="post-title"><a href="{{ post.permalink }}">{{ post.title }}</a></h3>
<h2 class="post-title"><a href="{{ post.permalink }}">{{ post.title }}</a></h2>
<small>
{{ post.date| date(format="%B %d, %Y") }} - {{ post.word_count }} words - {{ post.reading_time }} mins
{{ post.date| date(format="%B %d, %Y") }} &nbsp;&centerdot;&nbsp; {{ post.word_count }} words &nbsp;&centerdot;&nbsp; {{ post.reading_time }} mins
</small>
<div class="summary">
{% if post.summary -%}
{{ post.summary }}
{{ post.summary | safe }}
{% else %}
{{ post.content | safe | striptags | truncate(length=300) }}
{{ post.content | truncate(length=summary_truncate_length) | safe }}
{%- endif %}
<a href="{{ post.permalink }}">read more</a>
<p><small><a href="{{ post.permalink }}#continue-reading">continue reading &mldr;</a></small></p>
</div>
<hr class="gradient-line"/>
</div>
{% endmacro input %}
File renamed without changes.
4 changes: 2 additions & 2 deletions templates/tags/single.html → templates/taxonomy_single.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
{% endblock posthead %}

{% block content %}
<h1>{{ term.pages | length }} pages tagged with "{{ term.name }}"</h1>
<h1>{{ term.pages | length }} page{{ term.pages | length | pluralize }} tagged with "{{ term.name }}"</h1>
<div class="taxonomy-container">
{% for post in term.pages %}
{{ post_macros::post_preview(post=post) }}
{{ post_macros::post_preview(post=post, summary_truncate_length=config.extra.summary_truncate_length) }}
{% endfor %}
</div>
{% endblock content %}