diff options
-rw-r--r-- | archetypes/blog.md | 4 | ||||
-rw-r--r-- | archetypes/book.md | 4 | ||||
-rw-r--r-- | archetypes/default.md | 4 | ||||
-rw-r--r-- | assets/css/custom.css | 0 | ||||
-rw-r--r-- | assets/css/theme.css | 7 | ||||
-rw-r--r-- | i18n/en.toml | 13 | ||||
-rw-r--r-- | i18n/fr.toml | 13 | ||||
-rw-r--r-- | i18n/vi.toml | 11 | ||||
-rw-r--r-- | layouts/_default/baseof.html | 4 | ||||
-rw-r--r-- | layouts/_default/list.html | 40 | ||||
-rw-r--r-- | layouts/_default/single.html | 4 | ||||
-rw-r--r-- | layouts/index.html | 14 | ||||
-rw-r--r-- | layouts/partials/footer.html | 5 | ||||
-rw-r--r-- | layouts/partials/head.html | 5 | ||||
-rw-r--r-- | layouts/partials/header.html | 5 | ||||
-rw-r--r-- | layouts/partials/language-switcher.html | 11 | ||||
-rw-r--r-- | layouts/partials/post-language-switcher.html | 6 |
17 files changed, 113 insertions, 37 deletions
diff --git a/archetypes/blog.md b/archetypes/blog.md index 2f7a907..4299061 100644 --- a/archetypes/blog.md +++ b/archetypes/blog.md @@ -1,6 +1,6 @@ -+++ +--- title: "{{ replace .Name "-" " " | title }}" date: {{ now.Format "2026-01-02" }} categories: [ blog ] draft: true -+++ +--- diff --git a/archetypes/book.md b/archetypes/book.md index 0da07c8..0218afb 100644 --- a/archetypes/book.md +++ b/archetypes/book.md @@ -1,6 +1,6 @@ -+++ +--- title: "{{ replace .Name "-" " " | title }}" weight: categories: [ book ] draft: true -+++ +--- diff --git a/archetypes/default.md b/archetypes/default.md index 351a260..26f317f 100644 --- a/archetypes/default.md +++ b/archetypes/default.md @@ -1,5 +1,5 @@ -+++ +--- title: "{{ replace .Name "-" " " | title }}" date: {{ .Date }} draft: true -+++ +--- diff --git a/assets/css/custom.css b/assets/css/custom.css new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/assets/css/custom.css diff --git a/assets/css/theme.css b/assets/css/theme.css new file mode 100644 index 0000000..ae5acde --- /dev/null +++ b/assets/css/theme.css @@ -0,0 +1,7 @@ +nav ul, nav ul li { + display: inline-block; +} + +footer { + padding-top: 1.5rem; +} diff --git a/i18n/en.toml b/i18n/en.toml new file mode 100644 index 0000000..1cf0f8a --- /dev/null +++ b/i18n/en.toml @@ -0,0 +1,13 @@ +["choose language"] +other = "Choose another language:" + +[current] +other = "current" + +["word count"] +one = "{{ .WordCount }} word" +other = "{{ .WordCount }} words" + +["reading time"] +one = "approximately {{ .Count }} minute reading" +other = "approximately {{ .Count }} minutes reading" diff --git a/i18n/fr.toml b/i18n/fr.toml new file mode 100644 index 0000000..563b24a --- /dev/null +++ b/i18n/fr.toml @@ -0,0 +1,13 @@ +["choose language"] +other = "Choisir une autre langue:" + +[current] +other = "actuelle" + +["word count"] +one = "{{ .WordCount }} mot" +other = "{{ .WordCount }} mots" + +["reading time"] +one = "environ {{ .Count }} minute de lecture" +other = "environ {{ .Count }} minutes de lecture" diff --git a/i18n/vi.toml b/i18n/vi.toml new file mode 100644 index 0000000..c327799 --- /dev/null +++ b/i18n/vi.toml @@ -0,0 +1,11 @@ +["choose language"] +other = "Chọn ngôn ngữ khác:" + +[current] +other = "hiện tại" + +["word count"] +other = "{{ .WordCount }} từ" + +["reading time"] +other = "đọc hết khoảng {{ .Count }} phút" 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 }} |