feat(article): add link to translated content (#511)

This commit is contained in:
Jimmy Cai 2022-02-27 09:48:57 +01:00 committed by GitHub
parent 26fb06951b
commit b3b8fa73ef
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 42 additions and 3 deletions

10
assets/icons/language.svg Normal file
View File

@ -0,0 +1,10 @@
<svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-language" width="24" height="24" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round">
<path stroke="none" d="M0 0h24v24H0z" fill="none"/>
<path d="M4 5h7" />
<path d="M9 3v2c0 4.418 -2.239 8 -5 8" />
<path d="M5 9c-.003 2.144 2.952 3.908 6.7 4" />
<path d="M12 20l4 -9l4 9" />
<path d="M19.1 18h-6.2" />
</svg>

After

Width:  |  Height:  |  Size: 467 B

View File

@ -91,7 +91,8 @@
} }
} }
.article-time { .article-time,
.article-translations {
display: flex; display: flex;
align-items: center; align-items: center;
color: var(--card-text-color-tertiary); color: var(--card-text-color-tertiary);
@ -101,19 +102,21 @@
svg { svg {
vertical-align: middle; vertical-align: middle;
margin-right: 15px;
width: 20px; width: 20px;
height: 20px; height: 20px;
stroke-width: 1.33; stroke-width: 1.33;
} }
time { time,
a {
font-size: 1.4rem; font-size: 1.4rem;
color: var(--card-text-color-tertiary);
} }
& > div { & > div {
display: inline-flex; display: inline-flex;
align-items: center; align-items: center;
gap: 15px;
} }
} }

View File

@ -4,6 +4,16 @@ theme: hugo-theme-stack
paginate: 5 paginate: 5
title: Example Site title: Example Site
languages:
en:
languageName: English
title: Example Site
weight: 1
cn:
languageName: 中文
title: 演示站点
weight: 2
# Change it to your Disqus shortname before using # Change it to your Disqus shortname before using
disqusShortname: hugo-theme-stack disqusShortname: hugo-theme-stack

View File

@ -0,0 +1,5 @@
---
title: 关于
---
This is a test page for i18n support.

View File

@ -42,4 +42,15 @@
{{ end }} {{ end }}
</footer> </footer>
{{ end }} {{ end }}
{{ if .IsTranslated }}
<footer class="article-translations">
{{ partial "helper/icon" "language" }}
<div>
{{ range .Translations }}
<a href="{{ .Permalink }}" class="link">{{ .Language.LanguageName }}</a>
{{ end }}
</div>
</footer>
{{ end }}
</div> </div>