add i18n widget

This commit is contained in:
zhixuan 2022-02-27 12:09:31 +09:00
parent ca9b873f37
commit ae5a0be743
No known key found for this signature in database
GPG Key ID: 05D14AD50C51A06F
16 changed files with 109 additions and 10 deletions

8
assets/icons/docs.svg Normal file
View File

@ -0,0 +1,8 @@
<svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-file-text" 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="M14 3v4a1 1 0 0 0 1 1h4" />
<path d="M17 21h-10a2 2 0 0 1 -2 -2v-14a2 2 0 0 1 2 -2h7l5 5v11a2 2 0 0 1 -2 2z" />
<line x1="9" y1="9" x2="10" y2="9" />
<line x1="9" y1="13" x2="15" y2="13" />
<line x1="9" y1="17" x2="15" y2="17" />
</svg>

After

Width:  |  Height:  |  Size: 538 B

8
assets/icons/i18n.svg Normal file
View File

@ -0,0 +1,8 @@
<svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-language-hiragana" 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="M7 4c0 4.846 0 7 .5 8" />
<path d="M10 8.5c0 2.286 -2 4.5 -3.5 4.5s-2.5 -1.135 -2.5 -2c0 -2 1 -3 3 -3s5 .57 5 2.857c0 1.524 -.667 2.571 -2 3.143" />
<path d="M12 20l4 -9l4 9" />
<path d="M19.1 18h-6.2" />
</svg>

After

Width:  |  Height:  |  Size: 541 B

View File

@ -64,3 +64,26 @@
}
}
}
/* i18n nav widget */
.widget.i18n {
.i18n--list {
border-radius: var(--card-border-radius);
box-shadow: var(--shadow-l1);
background-color: var(--card-background);
}
.i18n--node {
a {
font-size: 1.4rem;
padding: 18px 25px;
display: flex;
span {
flex: 1;
color: var(--card-text-color-main);
font-weight: bold;
}
}
}
}

View File

@ -140,8 +140,10 @@ params:
- type: tag-cloud
params:
limit: 10
- type: i18n-nav
page:
- type: toc
- type: i18n-nav
opengraph:
twitter:
@ -184,6 +186,15 @@ menu:
newTab: false
icon: home
- identifier: docs
name: Docs
url: https://docs.stack.jimmycai.com/
weight: -40
params:
### For demonstration purpose, the home link will be open in a new tab
newTab: true
icon: docs
social:
- identifier: github
name: GitHub
@ -232,6 +243,25 @@ languages:
weight: 1
languageCode: en
zh-cn:
languageName: 日本語
languageName: 简体中文
weight: 2
languageCode: zh-cn
menu:
main:
- identifier: home
name: 主页
url: /
weight: -100
params:
### For demonstration purpose, the home link will be open in a new tab
newTab: false
icon: home
- identifier: docs
name: 文档
url: https://docs.stack.jimmycai.com/
weight: -40
params:
### For demonstration purpose, the home link will be open in a new tab
newTab: true
icon: docs

View File

@ -1,5 +1,5 @@
---
title: About
title: 关于
description: Hugo, the world's fastest framework for building websites
date: '2019-02-28'
aliases:

View File

@ -1,5 +1,5 @@
---
title: "Archives"
title: "归档"
date: 2019-05-28
layout: "archives"
slug: "archives"

View File

@ -1,5 +1,5 @@
---
title: Links
title: 链接
links:
- title: GitHub
description: GitHub is the world's largest software development platform.

View File

@ -1,5 +1,5 @@
---
title: "Search"
title: "搜索"
slug: "search"
layout: "search"
outputs:

View File

@ -52,6 +52,10 @@ widget:
title:
other: Tags
i18n-nav:
title:
other: multi language
search:
title:
other: Search

View File

@ -38,6 +38,10 @@ widget:
title:
other: 标签云
i18n-nav:
title:
other: 多语言
search:
title:
other: 搜索

View File

@ -0,0 +1,22 @@
{{- $context := .Context -}}
{{ if ne (len $context.Translations) "0" }}
<section class="widget i18n">
<div class="widget-icon">
{{ partial "helper/icon" "i18n" }}
</div>
<h2 class="widget-title section-title">{{ T "widget.i18n-nav.title" }}</h2>
<div class="i18n--list">
{{ range $context.Translations }}
<div class="i18n--node">
<a href="{{ .RelPermalink }}">
<span class="year">{{ .Language.LanguageName }}</span>
</a>
</div>
{{ end }}
</div>
</section>
{{ end }}