mirror of https://github.com/jlelse/GoBlog
Fix blog-relative links
This commit is contained in:
parent
43cd803342
commit
83253f03c4
|
@ -77,6 +77,12 @@ func initRendering() error {
|
||||||
},
|
},
|
||||||
"urlize": urlize,
|
"urlize": urlize,
|
||||||
"sort": sortedStrings,
|
"sort": sortedStrings,
|
||||||
|
"blogRelative": func(blog *configBlog, path string) string {
|
||||||
|
if blog.Path != "/" {
|
||||||
|
return blog.Path + path
|
||||||
|
}
|
||||||
|
return path
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
templates = make(map[string]*template.Template)
|
templates = make(map[string]*template.Template)
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{{ define "header" }}
|
{{ define "header" }}
|
||||||
<header>
|
<header>
|
||||||
<h1><a href="/" rel="home" title="{{ .Blog.Title }}">{{ .Blog.Title }}</a></h1>
|
<h1><a href="{{ blogRelative .Blog "/" }}" rel="home" title="{{ .Blog.Title }}">{{ .Blog.Title }}</a></h1>
|
||||||
{{ with .Blog.Description }}<p><i>{{ . }}</i></p>{{ end }}
|
{{ with .Blog.Description }}<p><i>{{ . }}</i></p>{{ end }}
|
||||||
{{ include "menu" .Blog .Data }}
|
{{ include "menu" .Blog .Data }}
|
||||||
</header>
|
</header>
|
||||||
|
|
|
@ -15,12 +15,13 @@
|
||||||
{{ end }}
|
{{ end }}
|
||||||
</article>
|
</article>
|
||||||
{{ $post := .Data }}
|
{{ $post := .Data }}
|
||||||
{{ range $i, $tax := .Blog.Taxonomies }}
|
{{ $blog := .Blog }}
|
||||||
|
{{ range $i, $tax := $blog.Taxonomies }}
|
||||||
{{ $tvs := ps $post $tax.Name }}
|
{{ $tvs := ps $post $tax.Name }}
|
||||||
{{ if gt (len $tvs) 0 }}
|
{{ if gt (len $tvs) 0 }}
|
||||||
<p>In <b>{{ $tax.Title }}</b>:
|
<p>In <b>{{ $tax.Title }}</b>:
|
||||||
{{ range $j, $tv := $tvs }}
|
{{ range $j, $tv := $tvs }}
|
||||||
<a href="/{{ $tax.Name }}/{{ urlize $tv }}">{{ $tv }}</a>
|
<a href="{{ blogRelative $blog ( printf "/%s/%s" $tax.Name (urlize $tv) ) }}">{{ $tv }}</a>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
</p>
|
</p>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
|
|
@ -7,9 +7,10 @@
|
||||||
{{ with .Data.Taxonomy.Title }}<h1>{{ . }}</h1>{{ end }}
|
{{ with .Data.Taxonomy.Title }}<h1>{{ . }}</h1>{{ end }}
|
||||||
{{ with .Data.Taxonomy.Description }}{{ md . }}{{ end }}
|
{{ with .Data.Taxonomy.Description }}{{ md . }}{{ end }}
|
||||||
<ul>
|
<ul>
|
||||||
|
{{ $blog := .Blog }}
|
||||||
{{ $taxonomy := .Data.Taxonomy.Name }}
|
{{ $taxonomy := .Data.Taxonomy.Name }}
|
||||||
{{ range $i, $value := (sort .Data.TaxonomyValues) }}
|
{{ range $i, $value := (sort .Data.TaxonomyValues) }}
|
||||||
<li><a href="/{{ $taxonomy }}/{{ urlize . }}">{{ . }}</a></li>
|
<li><a href="{{ blogRelative $blog ( printf "/%s/%s" $taxonomy (urlize .) ) }}">{{ . }}</a></li>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
</ul>
|
</ul>
|
||||||
</main>
|
</main>
|
||||||
|
|
Loading…
Reference in New Issue