From 7daa254c0b2be4055a40ef320f44e7d066dca753 Mon Sep 17 00:00:00 2001 From: Ahmed M Alaa Date: Mon, 5 Dec 2022 14:48:27 +0200 Subject: [PATCH] added: default taxonomies templates, custom nav links --- README.md | 33 ++++++++++++++++++++++++++++++++ config.toml | 15 ++++++++++++++- sass/style.scss | 4 +++- templates/base.html | 14 ++++++++++++++ templates/categories/list.html | 16 ++++++++++++++++ templates/categories/single.html | 26 +++++++++++++++++++++++++ templates/contexts/list.html | 14 ++++++++++++++ templates/contexts/single.html | 26 +++++++++++++++++++++++++ templates/index.html | 2 +- templates/page.html | 18 ++++++++++++++++- templates/tags/list.html | 14 ++++++++++++++ templates/tags/single.html | 26 +++++++++++++++++++++++++ templates/taxonomy_list.html | 1 - templates/taxonomy_single.html | 3 +-- 14 files changed, 205 insertions(+), 7 deletions(-) create mode 100644 templates/categories/list.html create mode 100644 templates/categories/single.html create mode 100644 templates/contexts/list.html create mode 100644 templates/contexts/single.html create mode 100644 templates/tags/list.html create mode 100644 templates/tags/single.html diff --git a/README.md b/README.md index e3b69c3..8039ca2 100644 --- a/README.md +++ b/README.md @@ -22,6 +22,19 @@ theme = "no-style-please" ## Options +### Default taxonomies + +Special templates for `tags`, `categories`, and `contexts` taxonomies are provided. However, generic templates exist for custom taxonomies. + +To use taxonomies, in a page metadata add + +```toml +[taxonomies] +tags = [ 'tag1', 'tag2' ] +categories = [ 'category A', 'B class' ] +genre = [ 'rock', 'alternative' ] # custom taxonomy +``` + ### Pages list in homepage To enable listing of pages in homepage add the following in `config.toml` @@ -31,6 +44,26 @@ To enable listing of pages in homepage add the following in `config.toml` list_pages = false ``` +### Header and footer nav links + +Also in the `extra` section in `config.toml` + +```toml +[extra] + +header_nav = [ + { name = "~home", url = "/" }, + { name = "#tags", url = "/tags" }, + { name = "+categories", url = "/categories" }, + { name = "@contexts", url = "/contexts" }, +] +footer_nav = [ + { name = "< previous", url = "#" }, + { name = "webring", url = "#" }, + { name = "next >", url = "#" }, +] +``` + ### Add TOC to pages In a page frontmatter, set `extra.add_toc` to `true` diff --git a/config.toml b/config.toml index 41c9b64..c112134 100644 --- a/config.toml +++ b/config.toml @@ -6,7 +6,9 @@ compile_sass = true generate_feed = true taxonomies = [ + { name = "tags" }, { name = "categories" }, + { name = "contexts" }, ] [markdown] @@ -14,4 +16,15 @@ highlight_code = true [extra] author = "Ahmed Alaa" -logo = "images/logo.png" \ No newline at end of file +logo = "images/logo.png" +header_nav = [ + { name = "~home", url = "/" }, + { name = "#tags", url = "/tags" }, + { name = "+categories", url = "/categories" }, + { name = "@contexts", url = "/contexts" }, +] +footer_nav = [ + { name = "< previous", url = "#" }, + { name = "webring", url = "#" }, + { name = "next >", url = "#" }, +] \ No newline at end of file diff --git a/sass/style.scss b/sass/style.scss index c1b9fc9..a4e6e49 100644 --- a/sass/style.scss +++ b/sass/style.scss @@ -102,4 +102,6 @@ img { p { display: inline; } -} \ No newline at end of file +} + +nav, .taxonomies { text-align: center; } \ No newline at end of file diff --git a/templates/base.html b/templates/base.html index e00a202..9e3965f 100644 --- a/templates/base.html +++ b/templates/base.html @@ -95,6 +95,13 @@
+ {% if config.extra.header_nav %} + + {% endif %} {% block header %}{% if title %}

{{ config.title }}

{% endif %}{% endblock header %}
@@ -102,6 +109,13 @@
{% block footer %}{% endblock footer %} + {% if config.extra.footer_nav %} + + {% endif %}
diff --git a/templates/categories/list.html b/templates/categories/list.html new file mode 100644 index 0000000..83b74fb --- /dev/null +++ b/templates/categories/list.html @@ -0,0 +1,16 @@ +{% extends "base.html" %} + +{% block header %} +

..{{ current_path }}

+

{{ taxonomy.name }}

+{% endblock header %} + +{% block content %} + +{% endblock content %} \ No newline at end of file diff --git a/templates/categories/single.html b/templates/categories/single.html new file mode 100644 index 0000000..7a3ab44 --- /dev/null +++ b/templates/categories/single.html @@ -0,0 +1,26 @@ +{% extends "base.html" %} + +{% block header %} +

../{{ term.slug }}/

+

{{ term.name }}

+{% endblock header %} + +{% block content %} +{% if paginator %} +{% set pages = paginator.pages %} +{% else %} +{% set pages = term.pages %} +{% endif %} + +{% if paginator %} +

{% if paginator.previous %}<< First < Previous{% endif %} [{{ paginator.current_index }}/{{ paginator.number_pagers }}] {% if paginator.next %}Next > Last >>{% endif %}

+{% endif %} +{% endblock content %} \ No newline at end of file diff --git a/templates/contexts/list.html b/templates/contexts/list.html new file mode 100644 index 0000000..c6a529b --- /dev/null +++ b/templates/contexts/list.html @@ -0,0 +1,14 @@ +{% extends "base.html" %} + +{% block header %} +

..{{ current_path }}

+

{{ taxonomy.name }}

+{% endblock header %} + +{% block content %} +

+{% for term in terms %} +@{{ term.name }} +{% endfor %} +

+{% endblock content %} \ No newline at end of file diff --git a/templates/contexts/single.html b/templates/contexts/single.html new file mode 100644 index 0000000..7a3ab44 --- /dev/null +++ b/templates/contexts/single.html @@ -0,0 +1,26 @@ +{% extends "base.html" %} + +{% block header %} +

../{{ term.slug }}/

+

{{ term.name }}

+{% endblock header %} + +{% block content %} +{% if paginator %} +{% set pages = paginator.pages %} +{% else %} +{% set pages = term.pages %} +{% endif %} + +{% if paginator %} +

{% if paginator.previous %}<< First < Previous{% endif %} [{{ paginator.current_index }}/{{ paginator.number_pagers }}] {% if paginator.next %}Next > Last >>{% endif %}

+{% endif %} +{% endblock content %} \ No newline at end of file diff --git a/templates/index.html b/templates/index.html index 40487bc..dafb0e4 100644 --- a/templates/index.html +++ b/templates/index.html @@ -12,7 +12,7 @@