[av:~/hyde-test/hydesite]$ patch -p1 < mltags.diff
patching file content/en/blog/index.html
patching file layout/blog-list.j2
Hunk #5 FAILED at 90.
1 out of 5 hunks FAILED -- saving rejects to file layout/blog-list.j2.rej
patching file layout/macros.j2
patching file layout/tag.j2
patching file site-local.yaml
The file layout/blog-list.j2.rej is here [1].
I thought that the error might be due to the line break on line 106 [2], so I edited your gist to remove that CRLF but I get the same error.
I managed to merge the errors manually and so far it seems to work fine. However I have a question:
This code within the patch does something?
{% set lang = 'en' %}
{% set previous = None %}
{% set current = None %}
{% set n = resource.node %}
{% set cont = False %}
{% for _ in range(1, 100) if cont %}
{% if n.source_folder == site.content.source_folder %}
{% set cont = True %}
{% else %}
{% set previous = current %}
{% set current = n %}
{% set n = n.parent %}
{% endif %}
{% endfor %}
{% if previous %}
{% endif %}
It has a debug code smell (not sure though), furthermore "lang" is never used afterwards. Currently is merged within the code, but if it is not useful I will remove it.
I'm trying to fix two more things:
First: The next and previous post at the bottom. They are linked to the next and previous by date, where they should be by date but within a namespace (language). To do so I thought about using a similar pattern [pattern-tags] you used to build a list of tags, except that I thought of building a list of posts within the current language sorted by date, something similar has been done also by [3]. I will probably end up by removing the next/previous post feature, it looks too difficult.
[pattern-tags] Code:
{% set tag_dict = {} %}
{% for tag, meta in site.tagger.tags %}
{% set tag_res = [] %}
{% for res in meta.resources %}
{% set lang_root = site.content.source_folder.child_folder(res.meta.language) %}
{% if resource.node.source_folder.is_descendant_of(lang_root) or resource.node.source_folder == lang_root %}
{% do tag_res.append(res) %}
{% endif %}
{% endfor %}
{% do tag_dict.update({
meta.name: tag_res}) %}
{% endfor %}
Second: I noticed that it would be nice to translate the Tags themselves also. To tackle this I checked the Vincent Bernat code and I noticed this part which looks interesting [3]. So I tried to include something like [4] to show the {{ tag|attr("descr_" + lang)|e }}{{ tag.descr|e }} attribute, however I don't fully understand that code. I guess "|e" is some sort of exception handler. Anyway that code doesn't work and I'm clueless. Do you know what am I doing wrong?
Thank you very much.
[3]:
https://github.com/vincentbernat/www.luffy.cx/blob/58f1e71301757d86ccd72c0df0b812d692700500/layout/macros.j2#L4-L24