Remove dead links for custom permalinks

This commit is contained in:
Shaform 2018-07-17 16:11:27 +08:00 committed by Kaushal Modi
parent 3e3aefd04f
commit c1cb3f081c

View File

@ -126,9 +126,13 @@ Taxonomies can be ordered by either alphabetical key or by the number of content
``` ```
<ul> <ul>
{{ $data := .Data }} {{ $type := .Type }}
{{ range $key, $value := .Data.Terms.Alphabetical }} {{ range $key, $value := .Data.Terms.Alphabetical }}
<li><a href="{{ $.Site.LanguagePrefix }}/{{ $data.Plural }}/{{ $value.Name | urlize }}"> {{ $value.Name }} </a> {{ $value.Count }} </li> {{ $name := .Name }}
{{ $count := .Count }}
{{ with $.Site.GetPage (printf "/%s/%s" $type $name) }}
<li><a href="{{ .Permalink }}"> {{ $name }} </a> {{ $count }} </li>
{{ end }}
{{ end }} {{ end }}
</ul> </ul>
``` ```
@ -137,9 +141,13 @@ Taxonomies can be ordered by either alphabetical key or by the number of content
``` ```
<ul> <ul>
{{ $data := .Data }} {{ $type := .Type }}
{{ range $key, $value := .Data.Terms.ByCount }} {{ range $key, $value := .Data.Terms.ByCount }}
<li><a href="{{ $.Site.LanguagePrefix }}/{{ $data.Plural }}/{{ $value.Name | urlize }}"> {{ $value.Name }} </a> {{ $value.Count }} </li> {{ $name := .Name }}
{{ $count := .Count }}
{{ with $.Site.GetPage (printf "/%s/%s" $type $name) }}
<li><a href="{{ .Permalink }}"> {{ $name }} </a> {{ $count }} </li>
{{ end }}
{{ end }} {{ end }}
</ul> </ul>
``` ```
@ -148,9 +156,13 @@ Taxonomies can be ordered by either alphabetical key or by the number of content
``` ```
<ul> <ul>
{{ $data := .Data }} {{ $type := .Type }}
{{ range $key, $value := .Data.Terms.ByCount.Reverse }} {{ range $key, $value := .Data.Terms.ByCount.Reverse }}
<li><a href="{{ $.Site.LanguagePrefix }}/{{ $data.Plural }}/{{ $value.Name | urlize }}"> {{ $value.Name }} </a> {{ $value.Count }} </li> {{ $name := .Name }}
{{ $count := .Count }}
{{ with $.Site.GetPage (printf "/%s/%s" $type $name) }}
<li><a href="{{ .Permalink }}"> {{ $name }} </a> {{ $count }} </li>
{{ end }}
{{ end }} {{ end }}
</ul> </ul>
``` ```
@ -224,7 +236,10 @@ Because we are leveraging the front matter system to define taxonomies for conte
``` ```
<ul id="tags"> <ul id="tags">
{{ range .Params.tags }} {{ range .Params.tags }}
<li><a href="{{ "/tags/" | relLangURL }}{{ . | urlize }}">{{ . }}</a> </li> {{ $name := . }}
{{ with $.Site.GetPage (printf "/tags/%s" $name) }}
<li><a href="{{ .Permalink }}">{{ $name }}</a> </li>
{{ end }}
{{ end }} {{ end }}
</ul> </ul>
``` ```
@ -238,7 +253,12 @@ To list such taxonomies, use the following:
``` ```
{{ if .Params.directors }} {{ if .Params.directors }}
<strong>Director{{ if gt (len .Params.directors) 1 }}s{{ end }}:</strong> <strong>Director{{ if gt (len .Params.directors) 1 }}s{{ end }}:</strong>
{{ range $index, $director := .Params.directors }}{{ if gt $index 0 }}, {{ end }}<a href="{{ "directors/" | relURL }}{{ . | urlize }}">{{ . }}</a>{{ end }} {{ range $index, $director := .Params.directors }}
{{- if gt $index 0 }}, {{ end -}}
{{ with $.Site.GetPage (printf "/directors/%s" $director) -}}
<a href="{{ .Permalink }}">{{ $director }}</a>
{{- end -}}
{{ end -}}
{{ end }} {{ end }}
``` ```
@ -292,7 +312,9 @@ The following example displays all terms in a site's tags taxonomy:
``` ```
<ul id="all-tags"> <ul id="all-tags">
{{ range $name, $taxonomy := .Site.Taxonomies.tags }} {{ range $name, $taxonomy := .Site.Taxonomies.tags }}
<li><a href="{{ "/tags/" | relLangURL }}{{ $name | urlize }}">{{ $name }}</a></li> {{ with $.Site.GetPage (printf "/tags/%s" $name) }}
<li><a href="{{ .Permalink }}">{{ $name }}</a></li>
{{ end }}
{{ end }} {{ end }}
</ul> </ul>
``` ```
@ -305,18 +327,20 @@ This example will list all taxonomies and their terms, as well as all the conten
<section> <section>
<ul id="all-taxonomies"> <ul id="all-taxonomies">
{{ range $taxonomyname, $taxonomy := .Site.Taxonomies }} {{ range $taxonomyname, $taxonomy := .Site.Taxonomies }}
<li><a href="{{ "/" | relLangURL}}{{ $taxonomyname | urlize }}">{{ $taxonomyname }}</a> {{ with $.Site.GetPage (printf "/%s" $taxonomyname) }}
<ul> <li><a href="{{ .Permalink }}">{{ $taxonomyname }}</a>
{{ range $key, $value := $taxonomy }} <ul>
<li> {{ $key }} </li> {{ range $key, $value := $taxonomy }}
<ul> <li> {{ $key }} </li>
{{ range $value.Pages }} <ul>
<li hugo-nav="{{ .RelPermalink}}"><a href="{{ .Permalink}}"> {{ .LinkTitle }} </a> </li> {{ range $value.Pages }}
{{ end }} <li hugo-nav="{{ .RelPermalink}}"><a href="{{ .Permalink}}"> {{ .LinkTitle }} </a> </li>
</ul> {{ end }}
{{ end }} </ul>
</ul> {{ end }}
</li> </ul>
</li>
{{ end }}
{{ end }} {{ end }}
</ul> </ul>
</section> </section>