From 62eec7be80352f745faf54c6cbd95bf05a57482a Mon Sep 17 00:00:00 2001 From: Emil Miler Date: Tue, 19 Jan 2021 23:14:37 +0100 Subject: [PATCH] Change content structure In order to be able to create simple pages, the structure has been redesigned. All blog posts are in their separate section. The sacrifice for this is that pagination of posts does not work on index. This could have been fixed with `transparent=true` in the posts section, but index would then paginate all other pages as well (for instance about.md) and include them with the other posts. A new macro `posts_latest` has been implemented to print last n posts as specified in `config.toml`. --- config.toml | 5 ++++- content/_index.md | 3 --- content/about.md | 4 ++++ content/about/_index.md | 5 ----- content/machines/_index.md | 3 +++ content/posts/_index.md | 5 +++++ templates/index.html | 5 +---- templates/macros.html | 10 ++++++++++ 8 files changed, 27 insertions(+), 13 deletions(-) create mode 100644 content/about.md delete mode 100644 content/about/_index.md create mode 100644 content/machines/_index.md create mode 100644 content/posts/_index.md diff --git a/config.toml b/config.toml index dc5fefc..23b968b 100644 --- a/config.toml +++ b/config.toml @@ -15,7 +15,10 @@ taxonomies = [ [extra] nav = [ {title = "Index", path = "/"}, - {title = "About", path = "/about/"} + {title = "About", path = "/about/"}, + {title = "All posts", path = "/posts/"}, + {title = "Machines", path = "/machines/"} ] categories_title = "Categories" tags_title = "Tags" +latest_posts_count = 4 diff --git a/content/_index.md b/content/_index.md index 96d1f14..ac36e06 100644 --- a/content/_index.md +++ b/content/_index.md @@ -1,5 +1,2 @@ +++ -sort_by = "date" -paginate_by = 4 +++ - diff --git a/content/about.md b/content/about.md new file mode 100644 index 0000000..57f88e0 --- /dev/null +++ b/content/about.md @@ -0,0 +1,4 @@ ++++ +title = "About" ++++ + diff --git a/content/about/_index.md b/content/about/_index.md deleted file mode 100644 index e6ee84b..0000000 --- a/content/about/_index.md +++ /dev/null @@ -1,5 +0,0 @@ -+++ -title = "About" -template = "section.html" -+++ - diff --git a/content/machines/_index.md b/content/machines/_index.md new file mode 100644 index 0000000..b3f542f --- /dev/null +++ b/content/machines/_index.md @@ -0,0 +1,3 @@ ++++ ++++ + diff --git a/content/posts/_index.md b/content/posts/_index.md new file mode 100644 index 0000000..7386385 --- /dev/null +++ b/content/posts/_index.md @@ -0,0 +1,5 @@ ++++ +orger_by = "date" +paginate_by = 5 ++++ + diff --git a/templates/index.html b/templates/index.html index 3f5a0b6..1b0e1c8 100644 --- a/templates/index.html +++ b/templates/index.html @@ -25,10 +25,7 @@
{% block content %} - {% for page in paginator.pages %} - {{ macros::list_article(page=page) }} - {% endfor %} - {{ macros::pagination(paginator=paginator) }} + {{ macros::posts_latest(section="posts", count=config.extra.latest_posts_count) }} {% endblock content %}
diff --git a/templates/macros.html b/templates/macros.html index ee45ef9..0489659 100644 --- a/templates/macros.html +++ b/templates/macros.html @@ -1,3 +1,13 @@ +{% macro posts_latest(section, count) %} + {% set section = get_section(path=section~"/_index.md") %} + {% for page in section.pages %} + {% if loop.index > count %} + {% break %} + {% endif %} + {{ macros::list_article(page=page) }} + {% endfor %} +{% endmacro posts_latest %} + {% macro list_taxonomy(title, kind) %} {{ title }}