hugo-soresu

My fork of hugo-xmin

git clone git://git.shimmy1996.com/hugo-soresu.git
commit dad4ec6309815449445ed339735c5bdf67b79799
parent 6e6fa9293d5bd374dce84d55721fdb2733897c95
Author: Shimmy Xu <shimmy.xu@shimmy1996.com>
Date:   Fri, 25 May 2018 23:52:31 -0500

Make partials more modular and rewrite templates to be more flexible.

Diffstat:
Mlayouts/_default/list.html | 45+++++++++++++--------------------------------
Mlayouts/_default/single.html | 21++++++++++++---------
Mlayouts/_default/terms.html | 20+++++---------------
Mlayouts/partials/comment.html | 4----
Alayouts/partials/favicon.html | 10++++++++++
Dlayouts/partials/foot_custom.html | 9---------
Mlayouts/partials/footer.html | 13+++++--------
Dlayouts/partials/head_custom.html | 18------------------
Mlayouts/partials/header.html | 34+++++++++++++++-------------------
Alayouts/partials/i18n_title.html | 6++++++
Alayouts/partials/include_css.html | 3+++
Alayouts/partials/include_js.html | 2++
Dlayouts/partials/navi_custom.html | 8--------
Alayouts/partials/navigation_bar.html | 11+++++++++++
14 files changed, 82 insertions(+), 122 deletions(-)
diff --git a/layouts/_default/list.html b/layouts/_default/list.html
@@ -1,38 +1,19 @@
 {{ partial "header.html" . }}
+{{ if not .IsHome }} {{ partial "i18n_title.html" . }} {{ end }}
 
-{{if not .IsHome }}
-  {{$title := i18n (lower .Title)}}
-  {{ if eq $title ""}}
-    <h1>{{ .Title }}</h1>
-  {{ else }}
-    <h1>{{ $title }}</h1>
-  {{ end }}
-{{ end }}
-
-{{ .Content }}
+<main>{{ .Content }}</main>
 
-{{if not .IsHome }}
-  <ul>
-    {{ range (where .Data.Pages "Section" "!=" "") }}
-    <li>
-      <span class="date">{{ .Date.Format "2006-01-02" }}</span>
-      <a href="{{ .URL }}">{{ .Title }}</a>
-      <br>
-      {{.Description}}
-    </li>
-    {{ end }}
-  </ul>
-{{else}}
-  <ul>
-    {{ range first 5 (where .Data.Pages "Section" "!=" "") }}
-    <li>
-      <span class="date">{{ .Date.Format "2006-01-02" }}</span>
-      <a href="{{ .URL }}">{{ .Title }}</a>
-      <br>
-      {{ .Description }}
-    </li>
-    {{ end }}
-  </ul>
+<ul>
+{{ if .IsHome }}
+  {{ range (first 5 (where .Data.Pages "Section" "!=" "") ) }}
+    <li><span class="date">{{ .Date.Format "2006-01-02" }}</span> <a href="{{ .URL }}">{{ .Title }}</a></li>
+  {{ end }}
+{{ else }}
+  {{ range (where .Data.Pages "Section" "!=" "") }}
+    <li><span class="date">{{ .Date.Format "2006-01-02" }}</span> <a href="{{ .URL }}">{{ .Title }}</a></li>
+  {{ end }}
 {{ end }}
+</ul>
 
+<hr/>
 {{ partial "footer.html" . }}
diff --git a/layouts/_default/single.html b/layouts/_default/single.html
@@ -1,22 +1,25 @@
 {{ partial "header.html" . }}
+
 <div class="article-meta">
 <h1><span class="title">{{ .Title }}</span></h1>
 {{ with .Params.author }}<h2 class="author">{{ . }}</h2>{{ end }}
 {{ if (lt 0 .Params.date) }}<h2 class="date">{{ .Date.Format "2006-01-02" }}</h2>{{ end }}
 <p class="terms">
-  {{ range $i := (slice "categories" "tags") }}
-  {{ with ($.Param $i) }}
-  {{ i18n (lower ($i | title)) }} | {{ range $k := . }}<a href="{{ relURL (print "/" $.Site.Language.Lang "/" $i "/" $k | urlize) }}">{{i18n $k}} </a> | {{ end }}
-  <br />
-  {{ end }}
+{{ range $key, $name := .Site.Params.Taxonomy }}
+  {{ with ($.Param $key) }}
+    {{ $name }} |
+    {{ range $term := . }}
+      <a href="{{ print "/" $key "/" $term | relLangURL}}">{{ i18n $term }}</a> |
+    {{ end }}
+    <br/>
   {{ end }}
+{{ end }}
 </p>
 </div>
 
-<main>
-{{ .Content }}
-</main>
+<main>{{ .Content }}</main>
 
-<!-- Enable Comments -->
+<hr/>
 {{ partial "comment.html" . }}
+<hr/>
 {{ partial "footer.html" . }}
diff --git a/layouts/_default/terms.html b/layouts/_default/terms.html
@@ -1,23 +1,13 @@
 {{ partial "header.html" . }}
+{{ partial "i18n_title.html" . }}
 
-{{$title := i18n .Title}}
-{{ if eq $title ""}}
-  <h1>{{ .Title }}</h1>
-{{ else }}
-  <h1>{{ $title }}</h1>
-{{ end }}
-
-{{ .Content }}
+<main>{{ .Content }}</main>
 
 <ul class="terms">
   {{ range $key, $value := .Data.Terms }}
-  <li>
-    <a href="{{ (print "/" $.Site.Language.Lang "/" $.Data.Plural "/" $key | urlize) | relURL }}">
-      {{ i18n $key }}
-    </a>
-    ({{ len $value }})
-  </li>
-  {{ end }}
+  <li><a href="{{ print "/" $.Data.Plural "/" $key | relLangURL }}">{{ i18n $key }}</a>({{ len $value }})</li>
+{{ end }}
 </ul>
 
+<hr/>
 {{ partial "footer.html" . }}
diff --git a/layouts/partials/comment.html b/layouts/partials/comment.html
@@ -1,7 +1,3 @@
-<!-- Sperate from main body -->
-<hr />
-
-<!-- Isso support -->
 <script data-isso="/isso/"
         data-isso-css="false"
         data-isso-lang={{ .Site.Language }}
diff --git a/layouts/partials/favicon.html b/layouts/partials/favicon.html
@@ -0,0 +1,10 @@
+<link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png?v=PY4lvMYpEv">
+<link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png?v=PY4lvMYpEv">
+<link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png?v=PY4lvMYpEv">
+<link rel="manifest" href="/site.webmanifest?v=PY4lvMYpEv">
+<link rel="mask-icon" href="/safari-pinned-tab.svg?v=PY4lvMYpEv" color="#700000">
+<link rel="shortcut icon" href="/favicon.ico?v=PY4lvMYpEv">
+<meta name="apple-mobile-web-app-title" content="Library of Trantor">
+<meta name="application-name" content="Library of Trantor">
+<meta name="msapplication-TileColor" content="#700000">
+<meta name="theme-color" content="#707070">
diff --git a/layouts/partials/foot_custom.html b/layouts/partials/foot_custom.html
@@ -1,9 +0,0 @@
-<!-- MathJax Support -->
-<script src="/js/math-code.js"></script>
-<script async src="/MathJax/MathJax.js?config=TeX-MML-AM_CHTML"></script>
-
-<!-- Translated footer -->
-{{ with i18n "footer" }}
-    <hr/>
-    {{ . | markdownify }}
-{{ end }}
diff --git a/layouts/partials/footer.html b/layouts/partials/footer.html
@@ -1,9 +1,6 @@
-  <footer>
-  {{ partial "foot_custom.html" . }}
-  {{ with .Site.Params.footer }}
-  <hr/>
-  {{ . | markdownify }}
-  {{ end }}
-  </footer>
-  </body>
+<footer>
+  {{ partial "include_js.html" . }}
+  {{ with .Site.Copyright }} {{ . | markdownify }} {{ end }}
+</footer>
+</body>
 </html>
diff --git a/layouts/partials/head_custom.html b/layouts/partials/head_custom.html
@@ -1,18 +0,0 @@
-<!-- Favicon Settings -->
-<link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png?v=PY4lvMYpEv">
-<link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png?v=PY4lvMYpEv">
-<link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png?v=PY4lvMYpEv">
-<link rel="manifest" href="/site.webmanifest?v=PY4lvMYpEv">
-<link rel="mask-icon" href="/safari-pinned-tab.svg?v=PY4lvMYpEv" color="#700000">
-<link rel="shortcut icon" href="/favicon.ico?v=PY4lvMYpEv">
-<meta name="apple-mobile-web-app-title" content="Library of Trantor">
-<meta name="application-name" content="Library of Trantor">
-<meta name="msapplication-TileColor" content="#700000">
-<meta name="theme-color" content="#707070">
-<!-- Title Translation -->
-{{$title := i18n (lower .Title)}}
-{{ if eq $title ""}}
-  <title>{{ .Title }} | {{ .Site.Title }}</title>
-{{ else }}
-  <title>{{ $title }} | {{ .Site.Title }}</title>
-{{ end }}
diff --git a/layouts/partials/header.html b/layouts/partials/header.html
@@ -1,21 +1,17 @@
 <!DOCTYPE html>
-<html lang="{{ .Site.Language }}">
-  <head>
-    <meta charset="utf-8">
-    <meta name="viewport" content="width=device-width, initial-scale=1">
-    <link rel="stylesheet" href="{{ "/css/isso.css" | relURL }}" />
-    <link rel="stylesheet" href="{{ "/css/style.css" | relURL }}" />
-    <link rel="stylesheet" href="{{ "/css/fonts.css" | relURL }}" />
-    {{ partial "head_custom.html" . }}
-  </head>
+<html lang="{{.Site.Language}}">
+<head>
+  <meta charset="utf-8">
+  <meta name="viewport" content="width=device-width, initial-scale=1">
+  {{ partial "include_css.html" . }}
+  {{ partial "favicon.html" . }}
+  {{ $title := i18n (lower .Title) }}
+  {{ if eq $title "" }}
+    <title>{{.Title}} | {{.Site.Title}}</title>
+  {{else}}
+    <title>{{$title}} | {{.Site.Title}}</title>
+  {{end}}
 
-  <body>
-    <nav>
-    <ul class="menu">
-      {{ range .Site.Menus.main }}
-      <li><a href="{{ .URL | relURL }}">{{ .Name }}</a></li>
-      {{ end }}
-      {{ partial "navi_custom.html" . }}
-    </ul>
-    <hr/>
-    </nav>
+</head>
+<body>
+{{ partial "navigation_bar.html" . }}
diff --git a/layouts/partials/i18n_title.html b/layouts/partials/i18n_title.html
@@ -0,0 +1,6 @@
+{{ $title := i18n (lower .Title) }}
+{{ if eq $title ""}}
+  <h1>{{ .Title }}</h1>
+{{ else }}
+  <h1>{{ $title }}</h1>
+{{ end }}
diff --git a/layouts/partials/include_css.html b/layouts/partials/include_css.html
@@ -0,0 +1,3 @@
+<link rel="stylesheet" href="{{ "/css/isso.css" | relURL }}" />
+<link rel="stylesheet" href="{{ "/css/style.css" | relURL }}" />
+<link rel="stylesheet" href="{{ "/css/fonts.css" | relURL }}" />
diff --git a/layouts/partials/include_js.html b/layouts/partials/include_js.html
@@ -0,0 +1,2 @@
+<script src="/js/math-code.js"></script>
+<script async src="/MathJax/MathJax.js?config=TeX-MML-AM_CHTML"></script>
diff --git a/layouts/partials/navi_custom.html b/layouts/partials/navi_custom.html
@@ -1,7 +0,0 @@
-{{ if .IsTranslated }}
-    {{ range .Translations }}
-    <li>
-        <a href="{{ .Permalink }}">{{ .Site.Language.LanguageName }}</a>
-    </li>
-    {{ end}}
-{{ end }}-
\ No newline at end of file
diff --git a/layouts/partials/navigation_bar.html b/layouts/partials/navigation_bar.html
@@ -0,0 +1,11 @@
+<nav>
+<ul class="menu">
+  {{ range .Site.Menus.main }}
+    <li><a href="{{ .URL | relURL }}">{{ .Name }}</a></li>
+  {{ end }}
+  {{ range .Translations }}
+    <li><a href="{{ .Permalink }}">{{ .Site.Language.LanguageName }}</a></li>
+  {{ end }}
+</ul>
+</nav>
+<hr/>