diff options
author | Chen Xianmin <xianmin12@gmail.com> | 2018-07-18 12:11:32 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-07-18 12:11:32 +0300 |
commit | 625d45952508b90453aef37bce9a11b46f89e756 (patch) | |
tree | a20f9c90778ad2a705dbf31e92d89f2448fcc30a | |
parent | b2548bd81d7e8de3cad43487d4312681e8bb727f (diff) | |
parent | 9f89349669069f655a75380a5ca5fb306eea6cb2 (diff) |
Merge pull request #83 from shaform/hardcoded
remove hardcoded URLs for tags/categories
-rw-r--r-- | dev-config.toml | 1 | ||||
-rw-r--r-- | exampleSite/config.toml | 1 | ||||
-rw-r--r-- | layouts/_default/terms.html | 21 | ||||
-rw-r--r-- | layouts/post/single.html | 10 | ||||
-rw-r--r-- | layouts/post/summary.html | 5 |
5 files changed, 26 insertions, 12 deletions
diff --git a/dev-config.toml b/dev-config.toml index d6b4961..76a5e85 100644 --- a/dev-config.toml +++ b/dev-config.toml @@ -108,7 +108,6 @@ defaultContentLanguage = "en" # Default language to use (if you setup multiling [params] debug = false # If true, load `eruda.min.js`. See https://github.com/liriliri/eruda - # uglyURLs = true # You must set true after use uglyURLs in site (above). because $.Site.UglyURLs can not import. since = "2017" # Site creation time # 站点建立时间 homeFullContent = false # if false, show post summaries on home page. Othewise show full content. rssFullContent = true # if false, Rss feed instead of the summary diff --git a/exampleSite/config.toml b/exampleSite/config.toml index b89d9c5..8621214 100644 --- a/exampleSite/config.toml +++ b/exampleSite/config.toml @@ -59,7 +59,6 @@ defaultContentLanguage = "en" # Default language to use [params] debug = false # If true, load `eruda.min.js`. See https://github.com/liriliri/eruda - # uglyURLs = true # You must set true after use uglyURLs in site (above). because $.Site.UglyURLs can not import. since = "2017" # Site creation time # 站点建立时间 homeFullContent = false # if false, show post summaries on home page. Othewise show full content. rssFullContent = true # if false, Rss feed instead of the summary diff --git a/layouts/_default/terms.html b/layouts/_default/terms.html index ee18a72..dd0de30 100644 --- a/layouts/_default/terms.html +++ b/layouts/_default/terms.html @@ -4,22 +4,26 @@ {{ $termName := .Data.Plural }} {{ $terms := .Data.Terms.ByCount }} {{ $length := len $terms }} + {{ $type := .Type }} <!-- Categories Page --> {{ if and $.Site.Taxonomies.categories (eq $termName "categories") }} - {{ range $key, $value := $terms }} + {{ range $terms }} + {{ $term := .Term }} + {{ $pages := .Pages }} + {{ with $.Site.GetPage "taxonomy" $type $term }} <section id="archive" class="archive"> <div class="archive-title"> </div> <div class="collection-title"> <h2 class="archive-year"> - <a href="{{ $termName | urlize | relLangURL }}/{{ $value.Term | urlize }}{{if $.Site.Params.uglyURLs}}.html{{else}}/{{end}}"> - {{ i18n "category" }}{{ $value.Term }} + <a href="{{ .Permalink }}"> + {{ i18n "category" }}{{ $term }} </a> </h2> </div> - {{ range first 5 $value.Pages }} + {{ range first 5 $pages }} <div class="archive-post"> <span class="archive-post-time"> {{ .Date.Format "2006-01-02" }} @@ -31,13 +35,14 @@ </span> </div> {{ end }} - {{ if gt (len $value.Pages) 5 }} + {{ if gt (len $pages) 5 }} <div class="more-post"> - <a href="{{ $termName | urlize | relLangURL }}/{{ $value.Term | urlize }}{{if $.Site.Params.uglyURLs}}.html{{else}}/{{end}}" class="more-post-link">{{ i18n "morePost" }}</a> + <a href="{{ .Permalink }}" class="more-post-link">{{ i18n "morePost" }}</a> </div> {{ end }} </section> {{ end }} + {{ end }} <!-- Tag cloud Page --> {{ else if and $.Site.Taxonomies.tags (eq $termName "tags") }} @@ -61,9 +66,11 @@ {{ $count := len $taxonomy.Pages }} {{ $weigth := div (sub (math.Log $count) (math.Log $min)) (sub (math.Log $max) (math.Log $min)) }} {{ $currentFontSize := (add $smallestFontSize (mul (sub $largestFontSize $smallestFontSize) $weigth) ) }} + {{ with $.Site.GetPage "taxonomy" $type $tagName }} <!--Current font size: {{$currentFontSize}}--> - <a href="{{ $termName | urlize | relLangURL }}/{{ $tagName | urlize }}{{if $.Site.Params.uglyURLs}}.html{{else}}/{{end}}" + <a href="{{ .Permalink }}" style="font-size:{{$currentFontSize}}{{$fontUnit}}">{{ $tagName }}</a> + {{ end }} {{ end }} </div> </div> diff --git a/layouts/post/single.html b/layouts/post/single.html index a6fdb5d..ae7d01b 100644 --- a/layouts/post/single.html +++ b/layouts/post/single.html @@ -10,7 +10,10 @@ {{ with .Params.categories -}} <div class="post-category"> {{ range . }} - <a href="{{ "categories" | relLangURL }}/{{ . | urlize }}{{if $.Site.Params.uglyURLs}}.html{{else}}/{{end}}"> {{ . }} </a> + {{- $name := . -}} + {{- with $.Site.GetPage "taxonomy" "categories" $name | default ($.Site.GetPage "taxonomy" "categories" ($name | urlize)) -}} + <a href="{{ .Permalink }}"> {{ $name }} </a> + {{ end -}} {{ end }} </div> {{- end }} @@ -39,7 +42,10 @@ {{ with .Params.tags -}} <div class="post-tags"> {{ range . }} - <a href="{{ "tags" | relLangURL }}/{{ . | urlize }}{{if $.Site.Params.uglyURLs}}.html{{else}}/{{end}}">{{ . }}</a> + {{- $name := . -}} + {{- with $.Site.GetPage "taxonomy" "tags" $name | default ($.Site.GetPage "taxonomy" "tags" ($name | urlize)) -}} + <a href="{{ .Permalink }}">{{ $name }}</a> + {{ end -}} {{ end }} </div> {{- end }} diff --git a/layouts/post/summary.html b/layouts/post/summary.html index bf2cfd9..6876a48 100644 --- a/layouts/post/summary.html +++ b/layouts/post/summary.html @@ -7,7 +7,10 @@ {{ with .Params.categories -}} <div class="post-category"> {{ range . }} - <a href="{{ "categories" | relLangURL }}/{{ . | urlize }}{{if $.Site.Params.uglyURLs}}.html{{else}}/{{end}}"> {{ . }} </a> + {{- $name := . -}} + {{- with $.Site.GetPage "taxonomy" "categories" $name | default ($.Site.GetPage "taxonomy" "categories" ($name | urlize)) -}} + <a href="{{ .Permalink }}"> {{ $name }} </a> + {{ end -}} {{ end }} </div> {{- end }} |