Skip to content

Commit

Permalink
Add features
Browse files Browse the repository at this point in the history
  • Loading branch information
xuhdev committed Jun 3, 2024
1 parent a7f08b7 commit f3f2276
Show file tree
Hide file tree
Showing 13 changed files with 58 additions and 13 deletions.
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,21 @@

KamiMod makes a few incremental changes to [PaperMod][].

## Features

This theme adds the following features and quality improvements on top of PaperMod. They are
features or improvements that were left unmerged from PaperMod.

- Related posts (Corresponding to adityatelange/hugo-PaperMod#1049, with different implementation)
- Replace `thumbnailUrl` with `logo` in the schema (adityatelange/hugo-PaperMod#1488)
- `thumbnailUrl` is not part of the [Organization schema](Organization: https://schema.org/Organization)
- Remove the use of `accesskey` to improve accessibility (adityatelange/hugo-PaperMod#1494)
- [MDN advises not using accesskeys for general purpose websites for various reasons](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/accesskey#accessibility_concerns)
- [WebAIM also recommends against using accesskeys generally](https://webaim.org/techniques/keyboard/accesskey)
- Add an option to not display descriptions (adityatelange/hugo-PaperMod#1533)
- [`.Description` is meant to be used for metadata purpose](https://gohugo.io/methods/page/description/):
> Conceptually different from a content summary, a page description is typically used in metadata about the page.
- Add last modified date to post header (adityatelange/hugo-PaperMod#1337)


[PaperMod]: https://github.com/adityatelange/hugo-PaperMod
9 changes: 9 additions & 0 deletions assets/css/common/post-single.css
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,15 @@
margin-bottom: 10px;
}

.post-footer .related a {
box-shadow: 0 1px;
}

.post-footer .related h2 {
margin-bottom: 16px;
font-size: 24px;
}

.post-tags {
display: flex;
flex-wrap: wrap;
Expand Down
2 changes: 1 addition & 1 deletion layouts/_default/archives.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ <h1>
{{- end }}
{{- end }}
</h1>
{{- if .Description }}
{{- if and (.Param "ShowDescription") .Description }}
<div class="post-description">
{{ .Description }}
</div>
Expand Down
2 changes: 1 addition & 1 deletion layouts/_default/list.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ <h1>
{{- end }}
{{- end }}
</h1>
{{- if .Description }}
{{- if and (.Param "ShowDescription") .Description }}
<div class="post-description">
{{ .Description | markdownify }}
</div>
Expand Down
2 changes: 1 addition & 1 deletion layouts/_default/search.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ <h1>{{- (printf "%s&nbsp;" .Title ) | htmlUnescape -}}
<line x1="21" y1="21" x2="16.65" y2="16.65"></line>
</svg>
</h1>
{{- if .Description }}
{{- if and (.Param "ShowDescription") .Description }}
<div class="post-description">
{{ .Description }}
</div>
Expand Down
6 changes: 5 additions & 1 deletion layouts/_default/single.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ <h1 class="post-title entry-hint-parent">
</span>
{{- end }}
</h1>
{{- if .Description }}
{{- if and (.Param "ShowDescription") .Description }}
<div class="post-description">
{{ .Description }}
</div>
Expand Down Expand Up @@ -43,6 +43,10 @@ <h1 class="post-title entry-hint-parent">
{{- end }}

<footer class="post-footer">
{{/* Show related posts */}}
{{- if (.Param "ShowRelatedContent") }}
{{- partial "related.html" . }}
{{- end }}
{{- $tags := .Language.Params.Taxonomies.tag | default "tags" }}
<ul class="post-tags">
{{- range ($.GetTerms $tags) }}
Expand Down
2 changes: 1 addition & 1 deletion layouts/_default/terms.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
{{- if .Title }}
<header class="page-header">
<h1>{{ .Title }}</h1>
{{- if .Description }}
{{- if and (.Param "ShowDescription") .Description }}
<div class="post-description">
{{ .Description }}
</div>
Expand Down
2 changes: 1 addition & 1 deletion layouts/partials/footer.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
{{- end }}

{{- if (not site.Params.disableScrollToTop) }}
<a href="#top" aria-label="go to top" title="Go to Top (Alt + G)" class="top-link" id="top-link" accesskey="g">
<a href="#top" aria-label="go to top" title="Go to Top" class="top-link" id="top-link">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 12 6" fill="currentColor">
<path d="M12 6H0l6-6z" />
</svg>
Expand Down
9 changes: 4 additions & 5 deletions layouts/partials/header.html
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@
<div class="logo">
{{- $label_text := (site.Params.label.text | default site.Title) }}
{{- if site.Title }}
<a href="{{ "" | absLangURL }}" accesskey="h" title="{{ $label_text }} (Alt + H)">
<a href="{{ "" | absLangURL }}" title="{{ $label_text }}">
{{- if site.Params.label.icon }}
{{- $img := resources.Get site.Params.label.icon }}
{{- $img := resources.Get site.Params.label.icon | fingerprint }}
{{- if $img }}
{{- $processableFormats := (slice "jpg" "jpeg" "png" "tif" "bmp" "gif") -}}
{{- if hugo.IsExtended -}}
Expand Down Expand Up @@ -74,7 +74,7 @@
{{- end }}
<div class="logo-switches">
{{- if (not site.Params.disableThemeToggle) }}
<button id="theme-toggle" accesskey="t" title="(Alt + T)">
<button id="theme-toggle" title="Toggle Theme">
<svg id="moon" xmlns="http://www.w3.org/2000/svg" width="24" height="18" viewBox="0 0 24 24"
fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round"
stroke-linejoin="round">
Expand Down Expand Up @@ -126,8 +126,7 @@
{{- $page_url:= $currentPage.Permalink | absLangURL }}
{{- $is_search := eq (site.GetPage .KeyName).Layout `search` }}
<li>
<a href="{{ .URL | absLangURL }}" title="{{ .Title | default .Name }} {{- cond $is_search (" (Alt + /)" | safeHTMLAttr) ("" | safeHTMLAttr ) }}"
{{- cond $is_search (" accesskey=/" | safeHTMLAttr) ("" | safeHTMLAttr ) }}>
<a href="{{ .URL | absLangURL }}" title="{{ .Title | default .Name }}">
<span {{- if eq $menu_item_url $page_url }} class="active" {{- end }}>
{{- .Pre }}
{{- .Name -}}
Expand Down
5 changes: 5 additions & 0 deletions layouts/partials/post_meta.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

{{- if not .Date.IsZero -}}
{{- $scratch.Add "meta" (slice (printf "<span title='%s'>%s</span>" (.Date) (.Date | time.Format (default "January 2, 2006" site.Params.DateFormat)))) }}
{{ $date := .Date.Format "02.01.2006" }}
{{ $lastmod := .Lastmod.Format "02.01.2006" }}
{{- if ne $lastmod $date -}}
{{- $scratch.Add "meta" (slice (printf "<span title='%s'>(updated %s)</span>" (.Lastmod) (.Lastmod | time.Format (default "January 2, 2006" site.Params.DateFormat)))) }}
{{- end }}
{{- end }}

{{- if (.Param "ShowReadingTime") -}}
Expand Down
11 changes: 11 additions & 0 deletions layouts/partials/related.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{{ $related := .Site.RegularPages.Related . | first 3 }}
{{ with $related }}
<aside class="related">
<h2>Related Posts</h2>
<ul>
{{ range . }}
<li><a href="{{ .RelPermalink }}">{{ .LinkTitle }}</a></li>
{{ end }}
</ul>
</aside>
{{ end }}
2 changes: 1 addition & 1 deletion layouts/partials/templates/schema_json.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"name": {{ site.Title }},
"url": {{ site.Home.Permalink }},
"description": {{ site.Params.description | plainify | truncate 180 | safeHTML }},
"thumbnailUrl": {{ site.Params.assets.favicon | default "favicon.ico" | absURL }},
"logo": {{ site.Params.assets.favicon | default "favicon.ico" | absURL }},
"sameAs": [
{{- if site.Params.schema.sameAs }}
{{ range $i, $e := site.Params.schema.sameAs }}{{ if $i }}, {{ end }}{{ trim $e " " }}{{ end }}
Expand Down
2 changes: 1 addition & 1 deletion layouts/partials/toc.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
{{- if $has_headers -}}
<div class="toc">
<details {{if (.Param "TocOpen") }} open{{ end }}>
<summary accesskey="c" title="(Alt + C)">
<summary>
<span class="details">{{- i18n "toc" | default "Table of Contents" }}</span>
</summary>

Expand Down

0 comments on commit f3f2276

Please sign in to comment.