Instantly share code, notes, and snippets.
Created
November 1, 2015 02:28
-
Star
(0)
0
You must be signed in to star a gist -
Fork
(0)
0
You must be signed in to fork a gist
-
Save navilan/2ffd57ff3ca5d180d8c6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/layout/blog-list.j2 b/layout/blog-list.j2 | |
index 30175dd..214b0a3 100644 | |
--- a/layout/blog-list.j2 | |
+++ b/layout/blog-list.j2 | |
@@ -1,5 +1,17 @@ | |
{% extends "base.j2" %} | |
+{% 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) %} | |
+ {% do tag_res.append(res) %} | |
+ {% endif %} | |
+ {% endfor %} | |
+ {% do tag_dict.update({meta.name: tag_res}) %} | |
+{% endfor %} | |
+ | |
{% block js %} | |
{{ super() }} | |
@@ -15,8 +27,8 @@ | |
</script> | |
{% endblock %} | |
-{% macro render_blog_listing(walker) %} | |
- {% for res in walker %} | |
+{% macro render_blog_listing() %} | |
+ {% for res in tag_dict[tag.name] %} | |
<div class="container post format-image"> | |
<div class="entry"> | |
<header class="entry-header"> | |
@@ -26,7 +38,7 @@ | |
<small> | |
<i class="fa fa-folder"></i> | |
{% for tag in res.meta.tags %} | |
- <a href="/blog/tags/{{tag}}.html">{{tag}}</a>{% if not loop.last -%},{%- endif %} | |
+ <a href="/{{ resource.meta.language }}/tags/{{tag}}.html">{{tag}}</a>{% if not loop.last -%},{%- endif %} | |
{% endfor %} | |
</small> | |
<a href="{{ site_url }}{{ res.full_url }}#disqus_thread"> | |
@@ -53,7 +65,7 @@ | |
{% block content %} | |
<div class="col-md-9 col-sm-7 posts"> | |
- {{ render_blog_listing(post_list) }} | |
+ {{ render_blog_listing() }} | |
<div class="container pagination-bar text-center"> | |
<ul class="pagination"> | |
@@ -75,17 +87,13 @@ | |
<div class="widget"> | |
<h4>Tags</h4> | |
<ul class="category-list flat"> | |
- {% set tag_dict = {} %} | |
- {% for tag, meta in site.tagger.tags %} | |
- {% do tag_dict.update({meta:meta.resources|count})%} | |
- {% endfor %} | |
- {% for meta, post_count in tag_dict|dictsort(by='value')|reverse %} | |
+ {% for name, resources in tag_dict|dictsort(by='value')|reverse %} | |
<li> | |
<a{% if tag == meta %} class="active"{% endif %} | |
- href="/blog/tags/{{ meta.name }}"> | |
- {{ meta.name }} | |
+ href="/{{ resource.node.name }}/tags/{{ name }}"> | |
+ {{ name }} | |
<span class="text-right pull-right"> | |
- {{(post_count) }} | |
+ {{(resources|count) }} | |
</span> | |
</a> | |
</li> | |
diff --git a/layout/macros.j2 b/layout/macros.j2 | |
index 9de883c..3c1b4ac 100644 | |
--- a/layout/macros.j2 | |
+++ b/layout/macros.j2 | |
@@ -8,7 +8,7 @@ | |
<published>{{ res.meta.created|xmldatetime }}</published> | |
<id>{{ content_url(res.url) }}</id> | |
{% for tag in res.meta.tags %} | |
- <category scheme="{{ content_url('blog/tags') }}" | |
+ <category scheme="{{ content_url(meta.resource.language ~ '/tags/') }}" | |
term="{{tag}}" | |
label="{{ tag|title }}" /> | |
{% endfor %} | |
diff --git a/layout/tag.j2 b/layout/tag.j2 | |
index 332b126..e58a445 100644 | |
--- a/layout/tag.j2 | |
+++ b/layout/tag.j2 | |
@@ -3,7 +3,7 @@ | |
{% extends "blog-list.j2" %} | |
{% block rss %} | |
-<link rel="alternate" type="application/rss+xml" href="/blog/tags/{{tag}}.xml" title="jd:/dev/blog – {{tag}}"> | |
+<link rel="alternate" type="application/rss+xml" href="/blog/{{ resource.meta.language }}/tags/{{tag}}.xml" title="jd:/dev/blog – {{tag}}"> | |
{% endblock %} | |
{% block title %}Posts with tag {{tag}}{% endblock %} | |
diff --git a/site-local.yaml b/site-local.yaml | |
index dbf8896..d3ad62a 100644 | |
--- a/site-local.yaml | |
+++ b/site-local.yaml | |
@@ -64,14 +64,24 @@ sorter: | |
tagger: | |
sorter: time | |
archives: | |
- atom: | |
- source: blog | |
- target: blog/tags | |
+ atom_en: | |
+ source: en/blog | |
+ target: en/tags | |
template: tag.xml.j2 | |
extension: xml | |
- blog: | |
- source: blog | |
- target: blog/tags | |
+ blog_en: | |
+ source: en/blog | |
+ target: en/tags | |
+ template: tag.j2 | |
+ extension: html | |
+ atom_es: | |
+ source: es/blog | |
+ target: es/tags | |
+ template: tag.xml.j2 | |
+ extension: xml | |
+ blog_es: | |
+ source: es/blog | |
+ target: es/tags | |
template: tag.j2 | |
extension: html | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment