about summary refs log tree commit diff
path: root/layouts
diff options
context:
space:
mode:
authorNgô Ngọc Đức Huy <huyngo@disroot.org>2023-07-29 17:33:12 +0700
committerNgô Ngọc Đức Huy <huyngo@disroot.org>2023-07-29 17:33:12 +0700
commit8261eed6f8c2aeb2488a481f1d89ab9c8ff3a119 (patch)
tree4dd87c1ca0f2ebc2a459395ee10a3547db3be106 /layouts
parent5f84f18c24b3bf64768befad82823a59c26e65d5 (diff)
downloadvictor-8261eed6f8c2aeb2488a481f1d89ab9c8ff3a119.tar.gz
Support multilingual
Diffstat (limited to 'layouts')
-rw-r--r--layouts/_default/baseof.html4
-rw-r--r--layouts/_default/list.html40
-rw-r--r--layouts/_default/single.html4
-rw-r--r--layouts/index.html14
-rw-r--r--layouts/partials/footer.html5
-rw-r--r--layouts/partials/head.html5
-rw-r--r--layouts/partials/header.html5
-rw-r--r--layouts/partials/language-switcher.html11
-rw-r--r--layouts/partials/post-language-switcher.html6
9 files changed, 63 insertions, 31 deletions
diff --git a/layouts/_default/baseof.html b/layouts/_default/baseof.html
index b17f8ce..bd9f83d 100644
--- a/layouts/_default/baseof.html
+++ b/layouts/_default/baseof.html
@@ -5,7 +5,11 @@ SPDX-License-Identifier: MIT
 */}}
 
 <!DOCTYPE html>
+{{ with .Page.Params.Lang }}
+<html lang="{{ . }}">
+{{ else }}
 <html lang="{{ .Page.Language.Lang }}">
+{{ end }}
 <head>
     {{ block "head" . }}
         {{ partial "head.html" . }}
diff --git a/layouts/_default/list.html b/layouts/_default/list.html
index ecac06c..7c774d5 100644
--- a/layouts/_default/list.html
+++ b/layouts/_default/list.html
@@ -11,26 +11,40 @@ SPDX-License-Identifier: MIT
   {{ if in .Params.categories "book" }}
   <section class="toc">
     <ol>
+      {{ range .Page.Translations | append .Page }}
       {{ range sort .Pages "Weight" }}
-        <li>
-          <a href="{{ .RelPermalink }}">{{ trim .Title " " }}</a>
-          {{ partial "post-language-switcher.html" . }}
-          {{ partial "post-info.html" . }}
-        </li>
+      <li>
+        <a href="{{ .RelPermalink }}">{{ trim .Title " " }}</a>
+        {{ partial "post-info.html" . }}
+      </li>
       {{ end }}
-      <ol>
+      {{ end }}
+    <ol>
   </section>
-  {{ else }}
+  {{ else if in .Params.categories "blog" }}
   <section class="feed">
+    <ol reversed>
+      {{ range sort .Pages "Date" "desc" }}
+      <li>
+        <time datetime="{{ .Date }}">{{ .Date.Format "2006-01-02" }}</time>:
+        <a href="{{ .RelPermalink }}">{{ trim .Title " " }}</a>
+        {{ partial "post-language-switcher.html" . }}
+        {{ partial "post-info.html" . }}
+      </li>
+      {{ end }}
     <ol>
+  </section>
+  {{ else }}
+  <section class="list">
+    <ul>
       {{ range sort .Pages "Date" }}
-        <li>
-          <a href="{{ .RelPermalink }}">{{ trim .Title " " }}</a>
-          {{ partial "post-language-switcher.html" . }}
-          {{ partial "post-info.html" . }}
-        </li>
+      <li>
+        <a href="{{ .RelPermalink }}">{{ trim .Title " " }}</a>
+        {{ partial "post-language-switcher.html" . }}
+        {{ partial "post-info.html" . }}
+      </li>
       {{ end }}
-      <ol>
+    <ul>
   </section>
   {{ end }}
 {{ end }}
diff --git a/layouts/_default/single.html b/layouts/_default/single.html
index 3dc85e7..d2d60dd 100644
--- a/layouts/_default/single.html
+++ b/layouts/_default/single.html
@@ -8,8 +8,8 @@ SPDX-License-Identifier: MIT
   <article>
     <header>
       <h1>{{ trim .Title  " " }}</h1>
-      {{ .WordCount }} words
-      ({{ div .WordCount 240}}~{{ div .WordCount 180}} minutes reading)
+      {{ i18n "word count" . }}
+      ({{ i18n "reading time" .ReadingTime }})
 
       {{ partial "post-language-switcher.html" . }}
       {{ partial "post-navigation.html" . }}
diff --git a/layouts/index.html b/layouts/index.html
index 07fbc94..5a9c4ed 100644
--- a/layouts/index.html
+++ b/layouts/index.html
@@ -1,10 +1,8 @@
 {{ define "main" }}
-<main>
-	{{ .Content }}
-	<ul>
-		{{ range .Pages }}
-		<li><a href="{{ .Permalink }}">{{ .Title }}</a></li>
-		{{ end }}
-	</ul>
-</main>
+{{ .Content }}
+<ul>
+	{{ range .Pages }}
+	<li><a href="{{ .Permalink }}">{{ .Title }}</a></li>
+	{{ end }}
+</ul>
 {{ end }}
diff --git a/layouts/partials/footer.html b/layouts/partials/footer.html
index 619beab..341bed7 100644
--- a/layouts/partials/footer.html
+++ b/layouts/partials/footer.html
@@ -5,10 +5,9 @@ SPDX-License-Identifier: MIT
 */}}
 
 <footer class="common-footer" id="footer">
-  {{ $languagesCount := $.Site.Home.AllTranslations }}
-  {{/* if gt $languagesCount 1 }}
+  {{ if .Site.IsMultiLingual }}
     {{ partial "language-switcher.html" . }}
-  {{ end */}}
+  {{ end }}
 
   <div class="common-footer-bottom">
     <div class="copyright">
diff --git a/layouts/partials/head.html b/layouts/partials/head.html
index 79d51b5..3857a99 100644
--- a/layouts/partials/head.html
+++ b/layouts/partials/head.html
@@ -1,4 +1,7 @@
-{{ $style := resources.Get "css/readable/readable.css" }}
+{{ $readable := resources.Get "css/readable/readable.css" }}
+{{ $theme := resources.Get "css/theme.css" }}
+{{ $custom := resources.Get "css/custom.css" }}
+{{ $style := slice $readable $theme $custom | resources.Concat "css/style.css" | minify | fingerprint }}
 
 <meta charset="utf-8">
 <meta name="HandheldFriendly" content="True">
diff --git a/layouts/partials/header.html b/layouts/partials/header.html
index d015389..7b35a2a 100644
--- a/layouts/partials/header.html
+++ b/layouts/partials/header.html
@@ -1,3 +1,6 @@
 <nav>
-	<a href="/" >{{ .Site.Title }}</a>
+	<a href="{{ .Site.Home.RelPermalink | absLangURL }}" >{{ .Site.Title }}</a>
+	{{ range .Site.Menus.main }}
+	<a href="{{ .URL | absLangURL }}">{{ .Title }}</a>
+	{{ end }}
 </nav>
diff --git a/layouts/partials/language-switcher.html b/layouts/partials/language-switcher.html
new file mode 100644
index 0000000..af29a78
--- /dev/null
+++ b/layouts/partials/language-switcher.html
@@ -0,0 +1,11 @@
+{{ i18n "choose language" }}
+{{ $pageLang := .Page.Lang}}
+<nav>
+	{{ range .AllTranslations }}
+		{{ if eq .Lang $pageLang }}
+			<a>{{ .Language.LanguageName }} ({{ i18n "current" }})</a>
+		{{ else }}
+			<a href="{{ .Permalink }}">{{ .Language.LanguageName }}</a>
+		{{ end }}
+	{{ end }}
+</nav>
diff --git a/layouts/partials/post-language-switcher.html b/layouts/partials/post-language-switcher.html
index 162cdf3..d5faf75 100644
--- a/layouts/partials/post-language-switcher.html
+++ b/layouts/partials/post-language-switcher.html
@@ -4,13 +4,13 @@
         {{ range .AllTranslations }}
             {{ if eq .Lang $pageLang }}
                 <li>
-                    {{ upper .Lang }}
+                    {{ .Language.LanguageName }} ({{ i18n "current" }})
                 </li>
             {{ else }}
                 <li>
-                    <a href="{{ .Permalink }}">{{ upper .Lang }}</a>
+                    <a href="{{ .Permalink }}">{{ .Language.LanguageName }}</a>
                 </li>
             {{ end }}
         {{ end }}
     </ul>
-{{ end }}
\ No newline at end of file
+{{ end }}