From 91b82b2e3fd1f42bdf5504f7a340f20d4c351f2c Mon Sep 17 00:00:00 2001 From: peter_rabbit <pierrejarriges@gmail.com> Date: Tue, 2 Feb 2021 15:33:31 +0100 Subject: [PATCH] fix:og meta name attribute --- build.js | 25 +++++++++++++++++++------ public/education/index.html | 13 ++++++------- public/games/index.html | 13 ++++++------- public/index.html | 11 ++++++----- public/software-development/index.html | 13 ++++++------- src/pages/games/meta.json | 2 +- 6 files changed, 44 insertions(+), 33 deletions(-) diff --git a/build.js b/build.js index 15d298c..a675f9f 100644 --- a/build.js +++ b/build.js @@ -2,7 +2,6 @@ "use strict"; - const fs = require("fs"); const browserify = require("browserify"); const config = require("./config"); @@ -100,20 +99,34 @@ function getPageHtml(pageName, pageMeta) { const { key, defaultValue } = entry; html = html.replace( html.match(getOgMetaSearchRegex(key)), - `<meta property="og:${key}" content="${pageOgMeta[key] || defaultValue}" />` + `<meta property="og:${key}" content="${ + pageOgMeta[key] || defaultValue + }" name="${key}"/>` ); }); - // TODO handle addition og meta + const additionalOgMeta = Object.keys(pageMeta.open_graph).filter( + k => !requiredOgMeta.map(rom => rom.key).includes(k) + ); + + if (additionalOgMeta.length > 0) { + html = html.replace( + "</head>", + `${additionalOgMeta + .map( + k => + `<meta property="og:${k}" content="${pageMeta.open_graph[k]}" name="${k}"/>` + ) + .join("\n")}</head>` + ); + } }; setMeta("description", pageMeta.description); setTitle(); setStyleSheet(); setJs(); setAdditionalMeta( - Object.entries(pageMeta).filter( - kv => !build_conf.default_meta_keys.includes(kv[0]) - ) + Object.entries(pageMeta).filter(kv => !build_conf.default_meta_keys.includes(kv[0])) ); setOgMeta(); return html; diff --git a/public/education/index.html b/public/education/index.html index 660916d..3d0de7d 100644 --- a/public/education/index.html +++ b/public/education/index.html @@ -6,16 +6,15 @@ <meta name="description" content="Animations autour de la création de jeux vidéos, vulgarisation numérique. Découvrez nos initiatives pédagogiques."/> <!-- Open Graph Protocol meta data --> - <meta property="og:title" content="Kuadrado Software | Pédagogie" /> - <meta property="og:description" content="Animations autour de la création de jeux vidéos, vulgarisation numérique. Découvrez nos initiatives pédagogiques." /> - <meta property="og:type" content="website" /> - <meta property="og:url" content="https://kuadrado-software.fr/education" /> - <meta property="og:image" content="https://kuadrado-software.fr/assets/images/brain.svg" /> - <meta property="og:locale" content="fr_FR" /> + <meta property="og:title" content="Kuadrado Software | Pédagogie" name="title"/> + <meta property="og:description" content="Animations autour de la création de jeux vidéos, vulgarisation numérique. Découvrez nos initiatives pédagogiques." name="description"/> + <meta property="og:type" content="website" name="type"/> + <meta property="og:url" content="https://kuadrado-software.fr name=url/education" name="url"/> + <meta property="og:image" content="https://kuadrado-software.fr/assets/images/brain.svg" name="image"/> + <meta property="og:locale" content="fr_FR name=locale" name="locale"/> <!-- English translation not ready yet --> <!-- <meta property="og:locale:alternate" content="en_GB" /> --> - <!-- END OGP --> <meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1" /> <link rel="icon" type="image/svg+xml" href="/favicon.svg" /> diff --git a/public/games/index.html b/public/games/index.html index eb16d90..c4b3946 100644 --- a/public/games/index.html +++ b/public/games/index.html @@ -6,16 +6,15 @@ <meta name="description" content="Création de jeux vidéos indépendants. Jeux web, PC et projets en cours de développement"/> <!-- Open Graph Protocol meta data --> - <meta property="og:title" content="Kuadrado Software | Jeux" /> - <meta property="og:description" content="Création de jeux vidéos indépendants. Jeux web, PC et projets en cours de développement" /> - <meta property="og:type" content="website" /> - <meta property="og:url" content="https://kuadrado-software.fr/games" /> - <meta property="og:image" content="https://kuadrado-software.fr/assets/images/game_controller.svg" /> - <meta property="og:locale" content="fr_FR" /> + <meta property="og:title" content="Kuadrado Software | Jeux" name="title"/> + <meta property="og:description" content="Création de jeux vidéos indépendants. Jeux web, PC et projets en cours de développement" name="description"/> + <meta property="og:type" content="website" name="type"/> + <meta property="og:url" content="https://kuadrado-software.fr name=url/games" name="url"/> + <meta property="og:image" content="https://kuadrado-software.fr/assets/images/game_controller.svg" name="image"/> + <meta property="og:locale" content="fr_FR name=locale" name="locale"/> <!-- English translation not ready yet --> <!-- <meta property="og:locale:alternate" content="en_GB" /> --> - <!-- END OGP --> <meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1" /> <link rel="icon" type="image/svg+xml" href="/favicon.svg" /> diff --git a/public/index.html b/public/index.html index 76d6135..31d4521 100644 --- a/public/index.html +++ b/public/index.html @@ -9,22 +9,23 @@ /> <!-- Open Graph Protocol meta data --> - <meta property="og:title" content="Kuadrado Software" /> + <meta property="og:title" content="Kuadrado Software" name="title"/> <meta property="og:description" content="Créations numériques, jeu vidéo, web, software et pédagogie. Made in Ardèche, Vernoux en Vivarais." + name="description" /> - <meta property="og:type" content="website" /> - <meta property="og:url" content="https://kuadrado-software.fr" /> + <meta property="og:type" content="website" name="type"/> + <meta property="og:url" content="https://kuadrado-software.fr" name="url"/> <meta property="og:image" content="https://kuadrado-software.fr/assets/images/logo_kuadrado.svg" + name="image" /> - <meta property="og:locale" content="fr_FR" /> + <meta property="og:locale" content="fr_FR" name="locale"/> <!-- English translation not ready yet --> <!-- <meta property="og:locale:alternate" content="en_GB" /> --> - <!-- END OGP --> <meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1" /> <link rel="icon" type="image/svg+xml" href="/favicon.svg" /> diff --git a/public/software-development/index.html b/public/software-development/index.html index e2c3f8d..dc08685 100644 --- a/public/software-development/index.html +++ b/public/software-development/index.html @@ -6,16 +6,15 @@ <meta name="description" content="Développement web, moteur de jeux, outillage logiciel, retrouvez nos projets en détail."/> <!-- Open Graph Protocol meta data --> - <meta property="og:title" content="Kuadrado Software | Software" /> - <meta property="og:description" content="Développement web, moteur de jeux, outillage logiciel, retrouvez nos projets en détail." /> - <meta property="og:type" content="website" /> - <meta property="og:url" content="https://kuadrado-software.fr/software-development" /> - <meta property="og:image" content="https://kuadrado-software.fr/assets/images/meca_proc.svg" /> - <meta property="og:locale" content="fr_FR" /> + <meta property="og:title" content="Kuadrado Software | Software" name="title"/> + <meta property="og:description" content="Développement web, moteur de jeux, outillage logiciel, retrouvez nos projets en détail." name="description"/> + <meta property="og:type" content="website" name="type"/> + <meta property="og:url" content="https://kuadrado-software.fr name=url/software-development" name="url"/> + <meta property="og:image" content="https://kuadrado-software.fr/assets/images/meca_proc.svg" name="image"/> + <meta property="og:locale" content="fr_FR name=locale" name="locale"/> <!-- English translation not ready yet --> <!-- <meta property="og:locale:alternate" content="en_GB" /> --> - <!-- END OGP --> <meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1" /> <link rel="icon" type="image/svg+xml" href="/favicon.svg" /> diff --git a/src/pages/games/meta.json b/src/pages/games/meta.json index ae505b3..5651a6f 100644 --- a/src/pages/games/meta.json +++ b/src/pages/games/meta.json @@ -6,4 +6,4 @@ "description": "Création de jeux vidéos indépendants. Jeux web, PC et projets en cours de développement", "image": "https://kuadrado-software.fr/assets/images/game_controller.svg" } -} \ No newline at end of file +} -- GitLab