blog-engine-sac
Advanced tools
Comparing version 7.4.4 to 7.5.0
# changelog | ||
## 7.5.0 | ||
Add possibility to translate category names | ||
## 7.4.0 | ||
@@ -4,0 +8,0 @@ |
@@ -16,3 +16,3 @@ export { createCategoryHtml }; | ||
const { posts, categoryName, defaultAuthor: author, subTitle: description, lang, extensionLinks} = options; | ||
const escapedCategoryName = escapeHtml(categoryName); | ||
const escapedCategoryName = escapeHtml(translate(lang, categoryName)); | ||
const topLevel = false; | ||
@@ -19,0 +19,0 @@ return minifyHtml(`<!doctype html> |
@@ -7,3 +7,3 @@ export { makeUrl, linkFromPost, linkFromCategory, escapeHtml, indexFileName, indexLink, categoryFileName, postStartName}; | ||
import { isLocalUrl } from '../source/urls.js'; | ||
import path from "path"; | ||
import { translate } from '../translations/translate.js'; | ||
@@ -15,3 +15,3 @@ // const capitalize = (words) => { | ||
const linkFromCategory = (categoryName, {extensionLinks, lang, defaultLang}, subPath=``) => { | ||
return `<a href="${subPath}./${urls.categories}${categoryNameStart(categoryName, lang, defaultLang)}${extensionLinks}">${escapeHtml(categoryName)}</a>`; | ||
return `<a href="${subPath}./${urls.categories}${categoryNameStart(categoryName, lang, defaultLang)}${extensionLinks}">${escapeHtml(translate(lang, categoryName))}</a>`; | ||
}; | ||
@@ -18,0 +18,0 @@ |
{ | ||
"name": "blog-engine-sac", | ||
"version": "7.4.4", | ||
"version": "7.5.0", | ||
"description": "static site generator, that uses markdown files as input and outputs web pages", | ||
@@ -5,0 +5,0 @@ "license": "CC0-1.0", |
@@ -183,3 +183,6 @@ # [Blog-engine-sac](https://gitlab.com/GrosSacASac/blog-engine-z) | ||
- tag: travel | ||
"fr": voyages | ||
- tag: dance | ||
"fr": danse | ||
``` | ||
@@ -186,0 +189,0 @@ |
@@ -156,2 +156,18 @@ /* stats.birthtime, can be later than modified date | ||
const addTranslatedCategories = function (categories) { | ||
categories.forEach(category => { | ||
Object.entries(category).forEach(([key, value]) => { | ||
if (key === `tag`) { | ||
return; | ||
} | ||
let translationsForThatLang = translations[key]; | ||
if (!translationsForThatLang) { | ||
translations[key] = {}; | ||
translationsForThatLang = translations[key]; | ||
} | ||
translationsForThatLang[category.tag] = value; | ||
}) | ||
}) | ||
}; | ||
const buildSite = async ({inputFolder}) => { | ||
@@ -187,3 +203,3 @@ const userOptionsSource = `${inputFolder}blog-engine-sac`; | ||
commonOptions.extensionLinks = commonOptions.htmlExtensionLinks && `.html` || ``; | ||
addTranslatedCategories(commonOptions.categories); | ||
@@ -190,0 +206,0 @@ try { |
536338
10873
285