Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/CaiJimmy/hugo-theme-stack.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJimmy Cai <github@jimmycai.com>2022-02-27 11:48:57 +0300
committerGitHub <noreply@github.com>2022-02-27 11:48:57 +0300
commitb3b8fa73ef5f82bed55e12221526fbeddc03374f (patch)
treedd454a8fbe0d21413b64179804bf7bb9911f5bb5
parent26fb06951b880cbafd9d408637c300eb19dfceab (diff)
feat(article): add link to translated content (#511)
-rw-r--r--assets/icons/language.svg10
-rw-r--r--assets/scss/partials/article.scss9
-rw-r--r--exampleSite/config.yaml10
-rw-r--r--exampleSite/content/page/about/index.cn.md5
-rw-r--r--layouts/partials/article/components/details.html11
5 files changed, 42 insertions, 3 deletions
diff --git a/assets/icons/language.svg b/assets/icons/language.svg
new file mode 100644
index 0000000..66ede1c
--- /dev/null
+++ b/assets/icons/language.svg
@@ -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>
+
+
diff --git a/assets/scss/partials/article.scss b/assets/scss/partials/article.scss
index 459c22f..0d3efba 100644
--- a/assets/scss/partials/article.scss
+++ b/assets/scss/partials/article.scss
@@ -91,7 +91,8 @@
}
}
-.article-time {
+.article-time,
+.article-translations {
display: flex;
align-items: center;
color: var(--card-text-color-tertiary);
@@ -101,19 +102,21 @@
svg {
vertical-align: middle;
- margin-right: 15px;
width: 20px;
height: 20px;
stroke-width: 1.33;
}
- time {
+ time,
+ a {
font-size: 1.4rem;
+ color: var(--card-text-color-tertiary);
}
& > div {
display: inline-flex;
align-items: center;
+ gap: 15px;
}
}
diff --git a/exampleSite/config.yaml b/exampleSite/config.yaml
index 7ff0505..b2fe1d3 100644
--- a/exampleSite/config.yaml
+++ b/exampleSite/config.yaml
@@ -4,6 +4,16 @@ theme: hugo-theme-stack
paginate: 5
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
disqusShortname: hugo-theme-stack
diff --git a/exampleSite/content/page/about/index.cn.md b/exampleSite/content/page/about/index.cn.md
new file mode 100644
index 0000000..060c006
--- /dev/null
+++ b/exampleSite/content/page/about/index.cn.md
@@ -0,0 +1,5 @@
+---
+title: 关于
+---
+
+This is a test page for i18n support. \ No newline at end of file
diff --git a/layouts/partials/article/components/details.html b/layouts/partials/article/components/details.html
index 64d6c6e..2ec1241 100644
--- a/layouts/partials/article/components/details.html
+++ b/layouts/partials/article/components/details.html
@@ -42,4 +42,15 @@
{{ end }}
</footer>
{{ 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> \ No newline at end of file