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",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue