Instantly share code, notes, and snippets.
Created
October 31, 2015 18:06
-
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/f1b78ebd6a0f67367ea2 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..926434e 100644 | |
--- a/layout/blog-list.j2 | |
+++ b/layout/blog-list.j2 | |
@@ -1,5 +1,16 @@ | |
{% extends "base.j2" %} | |
+{% set tag_dict = {} %} | |
+{% for tag, meta in site.tagger.tags %} | |
+ {% set tag_res = [] %} | |
+ {% for res in meta.resources %} | |
+ {% if resource.node.name == res.meta.language %} | |
+ {% do tag_res.append(res) %} | |
+ {% endif %} | |
+ {% endfor %} | |
+ {% do tag_dict.update({meta.name: tag_res}) %} | |
+{% endfor %} | |
+ | |
{% block js %} | |
{{ super() }} | |
@@ -15,8 +26,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 +37,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="/blog/tags/{{ resource.meta.language }}/{{tag}}.html">{{tag}}</a>{% if not loop.last -%},{%- endif %} | |
{% endfor %} | |
</small> | |
<a href="{{ site_url }}{{ res.full_url }}#disqus_thread"> | |
@@ -53,7 +64,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 +86,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="/blog/tags/{{ resource.node.name }}/{{ 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..9035311 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('blog/tags/' ~ meta.resource.language) }}" | |
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..e997b77 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: blog/en | |
+ target: blog/tags/en | |
template: tag.xml.j2 | |
extension: xml | |
- blog: | |
- source: blog | |
- target: blog/tags | |
+ blog_en: | |
+ source: blog/en | |
+ target: blog/tags/en | |
+ template: tag.j2 | |
+ extension: html | |
+ atom_es: | |
+ source: blog/es | |
+ target: blog/tags/es | |
+ template: tag.xml.j2 | |
+ extension: xml | |
+ blog_es: | |
+ source: blog/es | |
+ target: blog/tags/es | |
template: tag.j2 | |
extension: html | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment