Browse Source

Add support for `uglyURLs = true`

Close #464
George Cushen 7 years ago
parent
commit
9fa9d56eb3

+ 1 - 1
layouts/partials/article_metadata.html

@@ -34,7 +34,7 @@
   <span class="article-categories">
     <i class="fa fa-folder"></i>
     {{ range $k, $v := $.Params.categories }}
-    <a href="{{ "/categories/" | relLangURL }}{{ . | urlize | lower }}">{{ . }}</a
+    <a href="{{ ($.Site.GetPage "taxonomyTerm" "categories" (. | urlize | lower)).Permalink }}">{{ . }}</a
     >{{ if lt $k (sub $categoriesLen 1) }}, {{ end }}
     {{ end }}
   </span>

+ 1 - 1
layouts/partials/header_image.html

@@ -4,7 +4,7 @@
   {{ if $img_src.Scheme }}
     <img src="{{ .Params.header.image }}" class="article-banner" itemprop="image">
   {{ else }}
-    <img src="{{ "/img/" | relURL }}{{ .Params.header.image }}" class="article-banner" itemprop="image">
+    <img src="{{ (printf "/img/%s" .Params.header.image) | relURL }}" class="article-banner" itemprop="image">
   {{ end }}
 
   {{ with .Params.header.caption }}<span class="article-header-caption">{{ . | markdownify | emojify }}</span>{{ end }}

+ 1 - 1
layouts/partials/publication_links.html

@@ -31,7 +31,7 @@
 {{ end }}
 {{ if $.Params.projects }}
 {{ range $.Params.projects }}
-<a class="btn btn-primary btn-outline{{ if $is_list }} btn-xs{{end}}" href="{{ printf "project/%s/" . | relLangURL }}">
+<a class="btn btn-primary btn-outline{{ if $is_list }} btn-xs{{end}}" href="{{ ($.Site.GetPage "page" "project" .).Permalink }}">
   {{ i18n "btn_project" }}
 </a>
 {{ end }}

+ 1 - 1
layouts/partials/tags.html

@@ -3,7 +3,7 @@
 {{ if gt $tagsLen 0 }}
 <div class="article-tags">
   {{ range $k, $v := $.Params.tags }}
-  <a class="btn btn-primary btn-outline" href="{{ "/tags/" | relLangURL }}{{ . | urlize | lower }}">{{ . }}</a>
+  <a class="btn btn-primary btn-outline" href="{{ ($.Site.GetPage "taxonomyTerm" "tags" (. | urlize | lower)).Permalink }}">{{ . }}</a>
   {{ end }}
 </div>
 {{ end }}

+ 1 - 1
layouts/partials/talk_links.html

@@ -22,7 +22,7 @@
 </a>
 {{ end }}
 {{ range $.Params.projects }}
-<a class="btn btn-primary btn-outline{{ if $is_list }} btn-xs{{end}}" href="{{ printf "project/%s/" . | relLangURL }}">
+<a class="btn btn-primary btn-outline{{ if $is_list }} btn-xs{{end}}" href="{{ ($.Site.GetPage "page" "project" .).Permalink }}">
   {{ i18n "btn_project" }}
 </a>
 {{ end }}

+ 2 - 2
layouts/partials/widgets/about.html

@@ -10,8 +10,8 @@
       <div class="portrait" style="background-image: url('https://s.gravatar.com/avatar/{{ md5 $.Site.Params.email }}?s=200');"></div>
       <meta itemprop="image" content="https://s.gravatar.com/avatar/{{ md5 $.Site.Params.email }}?s=200">
       {{ else if $.Site.Params.avatar }}
-      <div class="portrait" style="background-image: url('{{ $.Site.BaseURL }}img/{{ $.Site.Params.avatar }}');"></div>
-      <meta itemprop="image" content="{{ $.Site.BaseURL }}img/{{ $.Site.Params.avatar }}">
+      <div class="portrait" style="background-image: url('{{ (printf "/img/%s" $.Site.Params.avatar) | relURL }}');"></div>
+      <meta itemprop="image" content="{{ (printf "/img/%s" $.Site.Params.avatar) | absURL }}">
       {{ end }}
 
       <div class="portrait-title">

+ 1 - 1
layouts/partials/widgets/posts.html

@@ -10,7 +10,7 @@
     {{ with $page.Params.subtitle }}<p>{{ . | markdownify }}</p>{{ end }}
     {{ if gt $posts_len $page.Params.count }}
     <p class="view-all">
-      <a href="{{ "/post/" | relLangURL }}">
+      <a href="{{ ($.Site.GetPage "section" "post").Permalink }}">
         {{ i18n "more_posts" | markdownify }}
         <i class="fa fa-angle-double-right"></i>
       </a>

+ 1 - 1
layouts/partials/widgets/publications.html

@@ -9,7 +9,7 @@
     {{ with $page.Params.subtitle }}<p>{{ . | markdownify }}</p>{{ end }}
     {{ if gt $pubs_len $page.Params.count }}
     <p class="view-all">
-      <a href="{{ "/publication/" | relLangURL }}">
+      <a href="{{ ($.Site.GetPage "section" "publication").Permalink }}">
         {{ i18n "more_publications" | markdownify }}
         <i class="fa fa-angle-double-right"></i>
       </a>

+ 2 - 3
layouts/partials/widgets/tag_cloud.html

@@ -24,9 +24,8 @@
           {{ $tagCount := len $taxonomy.Pages }}
           {{ $weight := div (sub (math.Log $tagCount) (math.Log $min)) (sub (math.Log $max) (math.Log $min)) }}
           {{ $fontSize := add $fontSmall (mul (sub $fontBig $fontSmall) $weight) }}
-          {{ $urlPart1 := relLangURL "/tags/" }}
-          {{ $urlPart2 := urlize $name  }}
-          <a href="{{ delimit (slice $urlPart1 $urlPart2) "" }}" style="font-size:{{ $fontSize }}rem">{{ $name }}</a>
+          {{ $urlPart := urlize $name }}
+          <a href="{{ ($.Site.GetPage "taxonomyTerm" "tags" $urlPart).Permalink }}" style="font-size:{{ $fontSize }}rem">{{ $name }}</a>
         {{ end }}
       </div>
     {{ end }}

+ 1 - 1
layouts/partials/widgets/talks.html

@@ -9,7 +9,7 @@
     {{ with $page.Params.subtitle }}<p>{{ . | markdownify }}</p>{{ end }}
     {{ if gt $talks_len $page.Params.count }}
     <p class="view-all">
-      <a href="{{ "/talk/" | relLangURL }}">
+      <a href="{{ ($.Site.GetPage "section" "talk").Permalink }}">
         {{ i18n "more_talks" | markdownify }}
         <i class="fa fa-angle-double-right"></i>
       </a>

+ 1 - 1
layouts/publication/single.html

@@ -32,7 +32,7 @@
           <div class="col-xs-12 col-sm-3 pub-row-heading">{{ i18n "publication_type" }}</div>
           <div class="col-xs-12 col-sm-9">
             {{ range $index, $pubtype := .Params.publication_types }}
-            <a href="{{ "/publication/" | relLangURL }}#{{ . | urlize }}">
+            <a href="{{ ($.Site.GetPage "section" "publication").Permalink }}#{{ . | urlize }}">
               {{ index $.Site.Params.publication_types (int .) }}
             </a>
             {{ end }}