From 726c3adade556082e4252d78503c703f69d1f5a9 Mon Sep 17 00:00:00 2001 From: peter_rabbit <pierrejarriges@gmail.com> Date: Thu, 28 Jan 2021 10:23:40 +0100 Subject: [PATCH] build pages meta data --- build.js | 17 ++++++++++++++++- public/education/index.html | 2 +- public/games/index.html | 2 +- public/software-development/index.html | 2 +- 4 files changed, 19 insertions(+), 4 deletions(-) diff --git a/build.js b/build.js index 6bdbd9a..cda3ae5 100644 --- a/build.js +++ b/build.js @@ -22,7 +22,7 @@ function getPageHtml(pageName, pageMeta) { const setMeta = function (metaName, value) { return html.replace( html.match(new RegExp(`<meta.+name="${metaName}".+>`, "g")), - `<meta name="${metaName}" content="${value}">` + `<meta name="${metaName}" content="${value}"/>` ); }; const setTitle = function (value) { @@ -43,10 +43,25 @@ function getPageHtml(pageName, pageMeta) { `<script type="text/javascript" src="./${pageName}.js"></script>` ); }; + const setAdditionalMeta = function (metas) { + return html.replace( + "</head>", + `${metas + .map(kv => { + const [name, content] = kv; + return `<meta name="${name}" content="${content}"/>`; + }) + .join("\n")}</head>` + ); + }; html = setMeta("description", pageMeta.description); html = setTitle(pageMeta.title); html = setStyleSheet(); html = setJs(); + html = setAdditionalMeta( + Object.entries(pageMeta).filter(kv => kv[0] !== "description" && kv[0] !== "title") + ); + return html; } diff --git a/public/education/index.html b/public/education/index.html index 23ca440..51e755d 100644 --- a/public/education/index.html +++ b/public/education/index.html @@ -3,7 +3,7 @@ <head> <meta charset="utf-8" /> <title>Kuadrado Software | Pédagogie</title> - <meta name="description" content="Animations autour de la création de jeux vidéos, vulgarisation numérique. Découvrez nos initiatives pédagogiques."> + <meta name="description" content="Animations autour de la création de jeux vidéos, vulgarisation numérique. Découvrez nos initiatives pédagogiques."/> <meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1" /> <link rel="icon" type="image/svg+xml" href="/favicon.svg"> <link href="/style/style.css" rel="stylesheet" /> diff --git a/public/games/index.html b/public/games/index.html index e68f86f..5fbf110 100644 --- a/public/games/index.html +++ b/public/games/index.html @@ -3,7 +3,7 @@ <head> <meta charset="utf-8" /> <title>Kuadrado Software | Jeux</title> - <meta name="description" content="Création de jeux vidéos indépendants. Jeux web, PC et projets en cours de développement"> + <meta name="description" content="Création de jeux vidéos indépendants. Jeux web, PC et projets en cours de développement"/> <meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1" /> <link rel="icon" type="image/svg+xml" href="/favicon.svg"> <link href="/style/style.css" rel="stylesheet" /> diff --git a/public/software-development/index.html b/public/software-development/index.html index 431e009..593f1fb 100644 --- a/public/software-development/index.html +++ b/public/software-development/index.html @@ -3,7 +3,7 @@ <head> <meta charset="utf-8" /> <title>Kuadrado Software | Software</title> - <meta name="description" content="Développement web, moteur de jeux, outillage logiciel, retrouvez nos projets en détail."> + <meta name="description" content="Développement web, moteur de jeux, outillage logiciel, retrouvez nos projets en détail."/> <meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1" /> <link rel="icon" type="image/svg+xml" href="/favicon.svg"> <link href="/style/style.css" rel="stylesheet" /> -- GitLab