refactor categories+tags section into a dedicated partial, add jump links for menu and metadata to the footer ; update 'back to tpo' jump links to jump to the toc instead of the very top of the page to save screen readers having to skip forward after jumping back

This commit is contained in:
KemoNine 2023-03-21 08:55:54 -04:00
parent 34f9d69660
commit 10bc92116f
5 changed files with 29 additions and 13 deletions

View file

@ -0,0 +1,10 @@
<a id="categories_tags" />
<p class="terms">
{{ range $i := (slice "categories" "tags") }}
{{ with ($.Param $i) }}
{{ $i | title }}: {{ range $k := . }}<a href="{{ relURL (print "/" $i "/" $k | urlize) }}">{{$k}}</a> {{ end }}
{{ end }}
<br />
{{ end }}
</p>

View file

@ -3,6 +3,8 @@
{{ with .Site.Params.footer }} {{ with .Site.Params.footer }}
<hr/> <hr/>
<a class="back_to_top" href="#top">Back to top</a> <a class="back_to_top" href="#top">Back to top</a>
&nbsp;|&nbsp;<a class="back_to_top" href="#categories_tags">Back to categories and tags</a>
&nbsp;|&nbsp;<a class="back_to_top" href="#nav_menu">Back to menu</a>
<br />{{ replace . "{Year}" now.Year | markdownify}} <br />{{ replace . "{Year}" now.Year | markdownify}}
{{ end }} {{ end }}
{{ if .GitInfo}} {{ if .GitInfo}}

View file

@ -22,7 +22,7 @@
</head> </head>
<body> <body>
<nav> <nav id="nav_menu">
<ul class="menu"> <ul class="menu">
{{ range .Site.Menus.main }} {{ range .Site.Menus.main }}
<li><a href="{{ .URL | relURL }}">{{ .Name }}</a></li> <li><a href="{{ .URL | relURL }}">{{ .Name }}</a></li>

View file

@ -9,26 +9,28 @@
{{ end }} {{ end }}
</h3> </h3>
{{ end }} {{ end }}
{{ if (gt .Date 0) }}<h4 class="date">Published: {{ .Date.Format "2006/01/02" }}</h4>{{ end }} {{ if (gt .Date 0) }}<h4 class="date">Published: {{ .Date.Format "2006/01/02" }}</h4>{{ end }}
{{ if (gt .Lastmod 0) }}<h4 class="date">Last Modified: {{ .Lastmod.Format "2006/01/02" }}</h4>{{ end }} {{ if (gt .Lastmod 0) }}<h4 class="date">Last Modified: {{ .Lastmod.Format "2006/01/02" }}</h4>{{ end }}
<p class="terms">
{{ range $i := (slice "categories" "tags") }}
{{ with ($.Param $i) }}
{{ $i | title }}: {{ range $k := . }}<a href="{{ relURL (print "/" $i "/" $k | urlize) }}">{{$k}}</a> {{ end }}
{{ end }}
{{ end }}
</p>
<p class="terms">
{{ partial "related.html" . }}
</p>
<p> <p>
{{ if (gt .ReadingTime 0) }}<small>Reading Time: {{ .ReadingTime }} minutes</small>{{ end }} {{ if (gt .ReadingTime 0) }}<small>Reading Time: {{ .ReadingTime }} minutes</small>{{ end }}
&nbsp;|&nbsp; &nbsp;|&nbsp;
{{ if (gt .WordCount 0) }}<small>Word Count: {{ .WordCount }} words</small>{{ end }} {{ if (gt .WordCount 0) }}<small>Word Count: {{ .WordCount }} words</small>{{ end }}
</p> </p>
</div>
<p class="terms">
{{ partial "categories_tags.html" . }}
</p>
<p class="terms">
{{ partial "related.html" . }}
</p>
</div>
<a id="top" />
{{ if .Params.toc }} {{ if .Params.toc }}
{{ .TableOfContents }} {{ .TableOfContents }}
{{ else }}
{{ end }} {{ end }}

View file

@ -1,3 +1,5 @@
<a id="related" />
{{ range first 1 (where (where .Site.Pages ".Params.tags" "intersect" .Params.tags) "Permalink" "!=" .Permalink) }} {{ range first 1 (where (where .Site.Pages ".Params.tags" "intersect" .Params.tags) "Permalink" "!=" .Permalink) }}
{{ $.Scratch.Set "has_related" true }} {{ $.Scratch.Set "has_related" true }}
{{ end }} {{ end }}