Add support for listing other languages versions in a post header
This commit is contained in:
parent
98e33603c1
commit
8a5e11234f
6 changed files with 36 additions and 0 deletions
11
.eleventy.js
11
.eleventy.js
|
|
@ -5,6 +5,17 @@ module.exports = function(eleventyConfig) {
|
|||
|
||||
eleventyConfig.addPassthroughCopy("static");
|
||||
|
||||
eleventyConfig.addNunjucksFilter("alternateLanguages", function(collection, postId, currentLanguageKey) {
|
||||
return collection.filter(post =>
|
||||
post.data.postId === postId && post.data.langKey !== currentLanguageKey
|
||||
)
|
||||
.map(post => ({
|
||||
lang: post.data.langKey,
|
||||
url: post.url,
|
||||
title: post.data.title
|
||||
}))
|
||||
});
|
||||
|
||||
eleventyConfig.addNunjucksFilter("smartTitle", function(str) {
|
||||
if (!str) return "";
|
||||
const smallWords = ["a","an","and","at","but","by","for","in","nor","of","on","or","so","the","to","up","yet",
|
||||
|
|
|
|||
|
|
@ -15,6 +15,10 @@ const globalValues = {
|
|||
module.exports = {
|
||||
// global: globalValues,
|
||||
en: {
|
||||
language: "english",
|
||||
availableInOtherLanguages: "Also available in other languages",
|
||||
pt: "portuguese",
|
||||
en: "english",
|
||||
home: "home",
|
||||
welcome: "welcome",
|
||||
homeWelcomeParagraph: "It seems that you have found my website! Hi, I am <b>Adrian Victor</b> (or <b>tenkuma</b>), a Brazilian guy who likes to mess around with computers, computer programs and <i>enimatpyrtlyhtemids</i>.",
|
||||
|
|
@ -53,6 +57,10 @@ module.exports = {
|
|||
options: "Options"
|
||||
},
|
||||
pt: {
|
||||
language: "português",
|
||||
availableInOtherLanguages: "Também disponível em outros idiomas",
|
||||
pt: "português",
|
||||
en: "inglês",
|
||||
home: "início",
|
||||
welcome: "bem-vindo",
|
||||
homeWelcomeParagraph: "Parece que você encontrou meu website! Olá, sou <b>Adrian Victor</b> (ou <b>tenkuma</b>), um cara brasileiro que gosta de mexer com computadores, programas de computadores e <i>enimatpirtlitemídios</i>.",
|
||||
|
|
|
|||
|
|
@ -2,11 +2,22 @@
|
|||
layout: base.njk
|
||||
title: Adrian Victor:Blog
|
||||
---
|
||||
{% set altLanguages = collections.post | alternateLanguages(postId, langKey) %}
|
||||
<main>
|
||||
<article>
|
||||
<div id="postHeader">
|
||||
<h1>{{ postTitle }}</h1>
|
||||
<p>{{ authors or "Adrian Victor" }} - {{ date }}</p>
|
||||
{% if altLanguages.length > 0 %}
|
||||
{{ i18n[langKey].availableInOtherLanguages }}:
|
||||
{% for alt in altLanguages %}
|
||||
<li class="inlineList">
|
||||
<a href="{{ alt.url }}" hreflang="{{ alt.lang }}">
|
||||
{{ i18n[alt.lang].language }}
|
||||
</a>
|
||||
</li>
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
</div>
|
||||
{{ content | safe }}
|
||||
</article>
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
---
|
||||
postTitle: "On the Recent Changes to App Distribution Requirements in the Android System by Google."
|
||||
postId: developer-verification
|
||||
langKey: en
|
||||
layout: post.njk
|
||||
date: 2025-08-30
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
---
|
||||
postTitle: "Sobre as recentes mudanças nos requisitos de distribuição de apps no sistema Android feitas pela Google."
|
||||
postId: developer-verification
|
||||
layout: post.njk
|
||||
date: 2025-08-30
|
||||
background: android-jellybean.jpg
|
||||
|
|
|
|||
|
|
@ -31,6 +31,10 @@ li {
|
|||
list-style-type: none;
|
||||
}
|
||||
|
||||
li.inlineList {
|
||||
display: inline;
|
||||
}
|
||||
|
||||
select {
|
||||
background-color: transparent;
|
||||
color: white;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue