소스 검색

Use slug for category and tag anchor name.

zhouji 11 년 전
부모
커밋
9900b07340
5개의 변경된 파일10개의 추가작업 그리고 10개의 파일을 삭제
  1. 2 2
      templates/article.html
  2. 2 2
      templates/categories.html
  3. 2 2
      templates/feeds_categories.html
  4. 2 2
      templates/feeds_tags.html
  5. 2 2
      templates/tags.html

+ 2 - 2
templates/article.html

@@ -90,13 +90,13 @@
             {% endif %}
             {% if article.category %}
             <h4>Category</h4>
-            <a class="category-link" href="{{ SITEURL }}/categories.html#{{ category|replace(' ', '-')|e }}-ref">{{ article.category }}</a> 
+            <a class="category-link" href="{{ SITEURL }}/categories.html#{{ category.slug }}-ref">{{ article.category }}</a> 
             {% endif %}
             {% if article.tags %}
             <h4>Tags</h4>
             <ul class="list-of-tags tags-in-article"> 
                 {% for tag in article.tags|sort %}
-                <li><a href="{{ SITEURL }}/tags.html#{{ tag|replace(' ', '-')|e }}-ref">{{ tag }}
+                <li><a href="{{ SITEURL }}/tags.html#{{ tag.slug }}-ref">{{ tag }}
                     {% for aTag, tagged_articles in tags if aTag == tag %}
                     <span>{{ tagged_articles|count }}</span>
                     {% endfor %}</a></li>

+ 2 - 2
templates/categories.html

@@ -27,12 +27,12 @@ All categories of the {{ SITENAME|striptags }} blog.
             {% for category, articles in categories %}
             <div class="accordion-group">
                 <div class="accordion-heading">
-                    <a class="accordion-toggle list-of-categories" data-toggle="collapse" data-parent="#accordion2" href="#{{ category|replace(' ', '-')|e }}-ref">
+                    <a class="accordion-toggle list-of-categories" data-toggle="collapse" data-parent="#accordion2" href="#{{ category.slug }}-ref">
                         {% set num = articles|count %}
                         {{ category }}<span>{{ num }}</span>
                     </a>
                 </div>
-                <div id="{{ category|replace(' ', '-')|e }}-ref" class="accordion-body collapse">
+                <div id="{{ category.slug }}-ref" class="accordion-body collapse">
                     <div class="accordion-inner">
                         <ul class="list-articles-category">
                             {% for article in articles %} 

+ 2 - 2
templates/feeds_categories.html

@@ -1,12 +1,12 @@
 {% if CATEGORY_FEED_ATOM %}
     {% for category in categories %}
-    {% set cat_name = category[0]|replace(' ', '-') %}
+    {% set cat_name = category[0].slug %}
         <link href="{{ FEED_DOMAIN }}/{{ CATEGORY_FEED_ATOM|format(cat_name) }}" type="application/atom+xml" rel="alternate" title="{{ SITENAME|striptags }} - {{category[0]}} Category Atom Feed" />
     {% endfor %}
 {% endif %}
 {% if CATEGORY_FEED_RSS %}
     {% for category in categories %}
-    {% set cat_name = category[0]|replace(' ', '-') %}
+    {% set cat_name = category[0].slug %}
         <link href="{{ FEED_DOMAIN }}/{{ CATEGORY_FEED_RSS|format(cat_name) }}" type="application/atom+xml" rel="alternate" title="{{ SITENAME|striptags }} - {{category[0]}} Category RSS Feed" />
     {% endfor %}
 {% endif %}

+ 2 - 2
templates/feeds_tags.html

@@ -1,12 +1,12 @@
 {% if TAG_FEED_ATOM %}
     {% for tag in tags %}
-    {% set tag_name = tag[0]|replace(' ', '-') %}
+    {% set tag_name = tag[0].slug %}
         <link href="{{ FEED_DOMAIN }}/{{ TAG_FEED_ATOM|format(tag_name) }}" type="application/atom+xml" rel="alternate" title="{{ SITENAME|striptags }} - {{tag[0]}} Tag Atom Feed" />
     {% endfor %}
 {% endif %}
 {% if TAG_FEED_RSS %}
     {% for tag in tags %}
-    {% set tag_name = tag[0]|replace(' ', '-') %}
+    {% set tag_name = tag[0].slug %}
         <link href="{{ FEED_DOMAIN }}/{{ TAG_FEED_RSS|format(tag_name) }}" type="application/atom+xml" rel="alternate" title="{{ SITENAME|striptags }} - {{tag[0]}} Tag RSS Feed" />
     {% endfor %}
 {% endif %}

+ 2 - 2
templates/tags.html

@@ -29,7 +29,7 @@ All tags used in the {{ SITENAME|striptags }} blog.
             {% for tag, articles in tags|sort %}
             <li>
             {% set num = articles|count %}
-            <a href="{{ SITEURL }}/tags.html#{{ tag|replace(' ', '-')|e }}-ref">{{ tag }}<span>{{ num }}</span></a>
+            <a href="{{ SITEURL }}/tags.html#{{ tag.slug }}-ref">{{ tag }}<span>{{ num }}</span></a>
             </li>
             {% endfor %}
         </ul>
@@ -39,7 +39,7 @@ All tags used in the {{ SITENAME|striptags }} blog.
 <div class="row-fluid">
     <div class="span8 offset2">
         {% for tag, articles in tags|sort %}
-        <h2 id="{{ tag|replace(' ', '-')|e }}-ref" class="tag-title">{{ tag }}</h2>
+        <h2 id="{{ tag.slug }}-ref" class="tag-title">{{ tag }}</h2>
         <ul class="articles-in-tag">
             {% for article in articles|sort(reverse = true, attribute = 'date') %}
             <li><a href="{{ SITEURL }}/{{ article.url }}">{{ article.title }} {%if article.subtitle %} <small> {{ article.subtitle }} </small> {% endif %} </a></li>