From ca4a88292929a2e2075fdf8c425db95b22a19f2a Mon Sep 17 00:00:00 2001 From: ache Date: Sat, 10 Aug 2024 16:35:57 +0200 Subject: Support for notes page in english and french --- src/build/i18n.mjs | 2 ++ src/build/index.mjs | 47 +++++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 47 insertions(+), 2 deletions(-) diff --git a/src/build/i18n.mjs b/src/build/i18n.mjs index 09dd6e4..00a554b 100644 --- a/src/build/i18n.mjs +++ b/src/build/i18n.mjs @@ -12,6 +12,7 @@ const i18n = { home: "L'accueil", git: "Dépôt git personnel", mastodon: "Mon mastodon", + notes: "Notes", }, articles: [ "framasoft-et-les-mascottes-du-libre.md", @@ -58,6 +59,7 @@ const i18n = { home: "Home", git: "Personnel git repository", mastodon: "Mastodon account", + notes: "Notes", }, articles: [ "rail-and-advertising.md", diff --git a/src/build/index.mjs b/src/build/index.mjs index 26d2067..980e6cd 100644 --- a/src/build/index.mjs +++ b/src/build/index.mjs @@ -17,6 +17,7 @@ const likesTmpl = fs.readFileSync("src/templates/likes.tmpl", "utf8"); const headerTmpl = fs.readFileSync("src/templates/header.tmpl", "utf8"); const articleTmpl = fs.readFileSync("src/templates/article.tmpl", "utf8"); const indexTmpl = fs.readFileSync("src/templates/index.tmpl", "utf8"); +const notesTmpl = fs.readFileSync("src/templates/notes.tmpl", "utf8"); const tagTmpl = fs.readFileSync("src/templates/tag.tmpl", "utf8"); const hidTmpl = fs.readFileSync("src/templates/hid.tmpl", "utf8"); const baseUrl = "https://ache.one/"; @@ -49,9 +50,16 @@ for (const lang in i18n) { // Same for notes const notes = notesAll.filter((note) => note.metaData.lang == lang); - const material = [...articles, ...notes]; + // Make notes directory + try { + fs.mkdirSync(`${lang}/notes`, { recursive: true }); + } catch { + fs.rmSync(`${lang}/notes`, { force: true, recursive: true }); + fs.mkdirSync(`${lang}/notes`, { recursive: true }); + } + for (const post of material) { const context = { svg, @@ -149,7 +157,7 @@ for (const lang in i18n) { }); } - // Home page + // Notes page: A note with a list of every note in that language { const alt_lang = { fr: { @@ -168,6 +176,41 @@ for (const lang in i18n) { lang, canonical: `${baseUrl}${lang}`, svg, + notes, + alt_lang: [alt_lang[lang]], + description: i18n[lang].index_desc, + }; + + console.log(`Create : Notes page ${lang}`); + const output = mustache.render(notesTmpl, context, partials); + fs.writeFileSync(`${lang}/notes/index.html`, minifyHTML(output)); + links.push({ + url: `${baseUrl}${lang}/notes`, + changefreq: "monthly", + priority: 0.7, + img: [{ url: "https://ache.one/res/ache.svg" }], + }); + } + + // Home page + { + const alt_lang = { + fr: { + lang: "en", + url: "/en/", + }, + en: { + lang: "fr", + url: "/fr/", + }, + }; + const context = { + page_title: i18n[lang].title.notes, + title: i18n[lang].title, + intro: i18n[lang].intro, + lang, + canonical: `${baseUrl}${lang}/notes`, + svg, articles, alt_lang: [alt_lang[lang]], description: i18n[lang].index_desc, -- cgit v1.2.3-70-g09d2