From 0323206585cba5305f93045076c199a1326c8273 Mon Sep 17 00:00:00 2001 From: southerntofu Date: Mon, 30 Mar 2020 02:12:42 +0200 Subject: [PATCH] Enable RSS and make sure the links are localized --- README.md | 12 +++++++++++- config.toml | 2 ++ templates/index.html | 2 +- templates/widgets.html | 6 ++++++ 4 files changed, 20 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index cce300f..c27c2c3 100644 --- a/README.md +++ b/README.md @@ -101,6 +101,15 @@ If you wish to directly extract the contents of a localized page, without any re {{ widgets::i18n_content(path="@/blog/_index.md") }} ``` +### Localized URL + +If you need to get the localized URI for path on the website, you can use the i18n_url macro which acts as a wrapper around the [get_url](https://www.getzola.org/documentation/templates/overview/#get-url) function, passing it the relevant lang context: + +``` +{% import "widgets.html" as widgets %} +RSS +``` + # TODO If something is missing for you, please open an issue. @@ -113,9 +122,10 @@ If something is missing for you, please open an issue. - [x] pages - [x] blogposts - [x] other strings in the templates + - [x] localized RSS links - [ ] links to navigate between languages - [ ] other - [ ] ASCII banner does not overflow - [ ] write setup/configuration guide - [ ] reference water.css semantic styling - - [ ] RSS links + - [x] RSS links diff --git a/config.toml b/config.toml index 69192d0..d8b4c18 100644 --- a/config.toml +++ b/config.toml @@ -11,6 +11,8 @@ highlight_code = false # Whether to build a search index to be used later on by a JavaScript library build_search_index = false +generate_rss = true + default_language = "en" languages = [ diff --git a/templates/index.html b/templates/index.html index 7bcbed7..3577eee 100644 --- a/templates/index.html +++ b/templates/index.html @@ -5,7 +5,7 @@ {{ config.extra.title }} - + diff --git a/templates/widgets.html b/templates/widgets.html index a6f43f8..adedb85 100644 --- a/templates/widgets.html +++ b/templates/widgets.html @@ -42,3 +42,9 @@ a submenu. A submenu is an actual list {%- macro i18n_content(path) -%} {{ get_page(path=self::i18n_path(path=path)) | get(key="content") }} {%- endmacro i18n_content -%} + +{%- macro i18n_url(path) -%} +{%- if lang == config.default_language -%}{{ get_url(path=path) }} +{%- else -%} + {%- set p = lang ~ "/" ~ path -%}{{ get_url(path=p) }}{%- endif -%} +{%- endmacro i18n_url -%}