Enable RSS and make sure the links are localized

This commit is contained in:
southerntofu 2020-03-30 02:12:42 +02:00
parent c16eed1a18
commit 0323206585
4 changed files with 20 additions and 2 deletions

View File

@ -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 %}
<a href="{{ widgets:i18n_uri(path = "rss.xml") }}">RSS</a>
```
# 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

View File

@ -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 = [

View File

@ -5,7 +5,7 @@
<head>
<meta charset="utf8">
<title>{{ config.extra.title }}</title>
<link rel="alternate" type="application/rss+xml" href="{{ get_url(path="rss.xml") }}">
<link rel="alternate" type="application/rss+xml" href="{{ widgets::i18n_url(path="rss.xml") }}">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="{{ get_url(path="style.css") }}" type="text/css">
<link rel="stylesheet" href="{{ get_url(path="water.css") }}" type="text/css">

View File

@ -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 -%}