Add links to translated content

Links to translated content will appear next to the date, both on
the index page and on post pages. Also style the translation links
on post pages to be like those on the index page, although some
more thought about the design is probably in order.
This commit is contained in:
Jack Taylor 2017-04-07 12:40:56 +09:00
parent c4cfe47e01
commit ff657d2db1
7 changed files with 30 additions and 6 deletions

View File

@ -3,6 +3,10 @@
translation: "January 2, 2006"
- id: postedOnDate
translation: "Posted on {{ .Count }}"
- id: translationsLabel
translation: "Other languages: "
- id: translationsSeparator
translation: ", "
- id: readMore
translation: "Read More"
- id: olderPosts

View File

@ -3,6 +3,10 @@
translation: "2006年1月2日"
- id: postedOnDate
translation: "{{ .Count }}に投稿"
- id: translationsLabel
translation: "翻訳:"
- id: translationsSeparator
translation: "・"
- id: readMore
translation: "続きを読む"
- id: olderPosts

View File

@ -30,9 +30,7 @@
{{ end }}
</a>
<p class="post-meta">
{{ default (i18n "dateFormat") .Site.Params.dateformat | .Date.Format | i18n "postedOnDate" }}
</p>
{{ partial "post_meta.html" . }}
<div class="post-entry">
{{ if .Truncated }}
{{ .Summary }}

View File

@ -32,7 +32,7 @@
{{ end }}
{{ end }}
{{ if eq .Type "post" }}
<span class="post-meta">{{ default (i18n "dateFormat") .Site.Params.dateformat | .Date.Format | i18n "postedOnDate" }}</span>
{{ partial "post_meta.html" . }}
{{ end }}
</div>
</div>
@ -57,7 +57,7 @@
{{ end }}
{{ end }}
{{ if eq .Type "post" }}
<span class="post-meta">{{ default (i18n "dateFormat") .Site.Params.dateformat | .Date.Format | i18n "postedOnDate" }}</span>
{{ partial "post_meta.html" . }}
{{ end }}
</div>
</div>

View File

@ -0,0 +1,11 @@
<span class="post-meta">
{{ default (i18n "dateFormat") .Site.Params.dateformat | .Date.Format | i18n "postedOnDate" }}
{{ if .IsTranslated -}}
{{- $sortedTranslations := sort .Translations "Site.Language.Weight" -}}
{{- $links := apply $sortedTranslations "partial" "translation_link.html" "." -}}
{{- $cleanLinks := apply $links "chomp" "." -}}
{{- $linksOutput := delimit $cleanLinks (i18n "translationsSeparator") -}}
&nbsp;&bull;&nbsp; {{ i18n "translationsLabel" }}{{ $linksOutput }}
{{- end }}
</span>

View File

@ -0,0 +1,2 @@
<a href="{{ .Permalink }}" lang="{{ .Lang }}">{{ default .Lang .Site.Language.LanguageName }}</a>

View File

@ -337,6 +337,11 @@ footer .theme-by {
font-style: italic;
margin: 0 0 10px;
}
.post-preview .post-meta a,
.post-heading .post-meta a {
color: #404040;
text-decoration: none;
}
.post-preview .post-entry {
font-family: 'Open Sans', 'Helvetica Neue', Helvetica, Arial, sans-serif;
}
@ -694,4 +699,4 @@ td.gutter {
input.gsc-input, .gsc-input-box, .gsc-input-box-hover, .gsc-input-box-focus, .gsc-search-button {
box-sizing: content-box;
line-height: normal;
}
}