diff options
| author | Eltrac <hi@guhub.cn> | 2025-01-25 14:11:26 +0800 |
|---|---|---|
| committer | Eltrac <hi@guhub.cn> | 2025-01-25 14:11:26 +0800 |
| commit | c082657d0e7386f9e381c4c33a6f3a12940fb845 (patch) | |
| tree | a06deb4d50688acb64970b8b65ec18e3b7049671 /layouts | |
| parent | 774265e7229e001e3f4667a12f3c729b38a2aa7b (diff) | |
chore(i18n): set up multilanguage
Former-commit-id: 7cb739da4ce26856beee919f2c6a54d1b2c51bdc
Diffstat (limited to 'layouts')
| -rw-r--r-- | layouts/index.html | 3 | ||||
| -rw-r--r-- | layouts/partials/footer.html | 12 | ||||
| -rw-r--r-- | layouts/partials/head/css.html | 1 | ||||
| -rw-r--r-- | layouts/partials/header.html | 6 | ||||
| -rw-r--r-- | layouts/partials/scripts.html | 4 | ||||
| -rw-r--r-- | layouts/partials/snippets/globe-icon.html | 1 |
6 files changed, 24 insertions, 3 deletions
diff --git a/layouts/index.html b/layouts/index.html index d6a41bed..6138f0db 100644 --- a/layouts/index.html +++ b/layouts/index.html @@ -1,6 +1,8 @@ {{ partial "snippets/document-start.html" . }} <article class="posts"> {{ partial "header.html" . }} + + {{ if eq .Site.Language.Lang "zh" }} <header id="posts-header"> <div id="post-series"> <h1>专栏</h1> @@ -49,6 +51,7 @@ </div> </div> </header> + {{ end }} <div id="posts-list"> {{ $currentYear := now.Format "2006" }} <!-- 获取当前年份 --> diff --git a/layouts/partials/footer.html b/layouts/partials/footer.html index d5baa527..ed0abcc2 100644 --- a/layouts/partials/footer.html +++ b/layouts/partials/footer.html @@ -6,7 +6,7 @@ {{ range (where .Site.Pages "Kind" "page" )}} {{$scratch.Add "total" .WordCount}} {{ end }} - <p class="word-count">🪦 {{$scratch.Get "total" }} 字在这里<span style="display:inline-block; transform:rotate(7deg) translateY(0.15rem); filter: blur(1px)">死去</span></p> + <p class="word-count">🪦 {{$scratch.Get "total" }} words are <span style="display:inline-block; transform:rotate(7deg) translateY(0.15rem); filter: blur(1px)">dead</span></p> </section> <section id="footer-links"> <ul class="footer-navigation"> @@ -20,6 +20,16 @@ <img src="{{ .icon }}" /> </a></li> {{ end }} + <li> + {{ if eq .Site.Language.Lang "en" }} + <a href="/en/posts/index.xml" title="RSS (English)" target="_blank"> + {{ else if eq .Site.Language.Lang "zh" }} + <a href="/zh/posts/index.xml" title="RSS (中文)" target="_blank"> + {{ end }} + {{ partial "snippets/rss-icon" . }} + </a> + </li> + </ul> </section> </footer> diff --git a/layouts/partials/head/css.html b/layouts/partials/head/css.html index c3fc5aaf..9061dde0 100644 --- a/layouts/partials/head/css.html +++ b/layouts/partials/head/css.html @@ -10,6 +10,7 @@ <link rel="preconnect" href="https://fonts.googleapis.com"> <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin> <link href="https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@200..900&display=swap" rel="stylesheet"> +<link href="https://fonts.googleapis.com/css2?family=Playfair+Display:ital,wght@0,400..900;1,400..900&display=swap" rel="stylesheet"> <!-- Extra --> {{ range .Site.Params.extraCSSFiles -}} diff --git a/layouts/partials/header.html b/layouts/partials/header.html index 29314d44..48f6a168 100644 --- a/layouts/partials/header.html +++ b/layouts/partials/header.html @@ -14,6 +14,10 @@ </div> {{ end }} </nav> - <a href="https://rss.beauty/rss?url=https%3A%2F%2Fwww.geedea.pro%2Fposts%2Findex.xml" target="_blank" title="RSS">{{ partial "snippets/rss-icon" . }}</a> + {{ if eq .Site.Language.Lang "en" }} + <a href="/zh/" class="no-swup" title="切换至中文">{{ partial "snippets/globe-icon" . }}</a> + {{ else if eq .Site.Language.Lang "zh" }} + <a href="/en/" class="no-swup" title="Switch to English">{{ partial "snippets/globe-icon" . }}</a> + {{ end }} </div> </header> diff --git a/layouts/partials/scripts.html b/layouts/partials/scripts.html index e1babce6..e498c129 100644 --- a/layouts/partials/scripts.html +++ b/layouts/partials/scripts.html @@ -26,7 +26,9 @@ loadToc(); littlefoot.littlefoot(littlefootOptions) /* === swup === */ -const swup = new Swup(); +const swup = new Swup({ + linkSelector: 'a[href]:not(.no-swup)' +}); swup.hooks.on('page:view', () => { lazyLoadInstance.update(); Fancybox.bind("[data-fancybox]"); diff --git a/layouts/partials/snippets/globe-icon.html b/layouts/partials/snippets/globe-icon.html new file mode 100644 index 00000000..932831c9 --- /dev/null +++ b/layouts/partials/snippets/globe-icon.html @@ -0,0 +1 @@ +<svg style="width: 1rem; height: 1rem; fill: var(--text-color)" fill="#000000" width="800px" height="800px" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M10 .4C4.705.4.399 4.707.399 10S4.705 19.6 10 19.6c5.293 0 9.6-4.307 9.6-9.6S15.293.4 10 .4zm8.188 9.6c0 1.873-.636 3.6-1.696 4.98-.3-.234-.619-.867-.319-1.523.303-.66.382-2.188.312-2.783-.066-.594-.375-2.025-1.214-2.039-.838-.012-1.413-.289-1.911-1.283-1.033-2.068 1.939-2.465.906-3.609-.289-.322-1.783 1.322-2.002-.869-.014-.157.135-.392.336-.636 3.244 1.09 5.588 4.157 5.588 7.762zM8.875 1.893c-.196.382-.713.537-1.027.824-.684.619-.978.533-1.346 1.127-.371.594-1.567 1.449-1.567 1.879s.604.936.906.838c.302-.1 1.099-.094 1.567.07.469.166 3.914.332 2.816 3.244-.348.926-1.873.77-2.279 2.303-.061.225-.272 1.186-.285 1.5-.025.486.344 2.318-.125 2.318-.471 0-1.738-1.639-1.738-1.936s-.328-1.338-.328-2.23c0-.891-1.518-.877-1.518-2.062 0-1.068.823-1.6.638-2.113-.181-.51-1.627-.527-2.23-.59a8.213 8.213 0 0 1 6.516-5.172zM7.424 17.77c.492-.26.542-.596.988-.613.51-.023.925-.199 1.5-.326.51-.111 1.423-.629 2.226-.695.678-.055 2.015.035 2.375.689a8.159 8.159 0 0 1-7.089.945z"/></svg> |
