diff --git a/build.js b/build.js index f0b0f8bb75f3a6624c7090e4504bf80a561eaeb6..6bdbd9a8f3adaee57db3f74f2b4a4f801bc42d02 100644 --- a/build.js +++ b/build.js @@ -17,23 +17,37 @@ b.add(`${curDir}/src/main.js`) .pipe(fs.createWriteStream(`${curDir}/public/main.js`)); // Handle subpages -function getPageHtml(pagename) { - return ` -<!DOCTYPE html> -<html lang="fr"> - <head> - <meta charset="utf-8" /> - <meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1" /> - <title>Kuadrado Software - ${pagename}</title> - <link rel="icon" type="image/svg+xml" href="/favicon.svg"> - <link href="/style/style.css" rel="stylesheet" /> - </head> - <body> - <main></main> - </body> - <script type="text/javascript" src="./${pagename}.js"></script> -</html> - `; +function getPageHtml(pageName, pageMeta) { + let html = fs.readFileSync(`${curDir}/public/index.html`, "utf-8"); + const setMeta = function (metaName, value) { + return html.replace( + html.match(new RegExp(`<meta.+name="${metaName}".+>`, "g")), + `<meta name="${metaName}" content="${value}">` + ); + }; + const setTitle = function (value) { + return html.replace( + html.match(new RegExp(`<title.+</title>`, "g")), + `<title>${value}</title>` + ); + }; + const setStyleSheet = function () { + return html.replace( + html.match(new RegExp(`<link.+/style.css>`, "g")), + `<link href="/style/style.css" rel="stylesheet" />` + ); + }; + const setJs = function () { + return html.replace( + html.match(new RegExp(`<script.+main.js.+</script>`, "g")), + `<script type="text/javascript" src="./${pageName}.js"></script>` + ); + }; + html = setMeta("description", pageMeta.description); + html = setTitle(pageMeta.title); + html = setStyleSheet(); + html = setJs(); + return html; } const pages = fs.readdirSync(`${curDir}/src/pages`); @@ -53,7 +67,8 @@ for (const p of pages) { .pipe(fs.createWriteStream(`${targetDirPath}/${p}.js`)); const page = fs.createWriteStream(`${targetDirPath}/index.html`); - page.write(getPageHtml(p)); + const pageMeta = JSON.parse(fs.readFileSync(`${fPath}/meta.json`, "utf-8")); + page.write(getPageHtml(p, pageMeta)); } // If pages have been deleted in source, remove them in output directory too. diff --git a/public/education/education.js b/public/education/education.js index d576f8bcf83cbde2c2ceb69037563a7ceca9fd12..60c301a93a3e75e968ede3baf87c807ab6185f56 100644 --- a/public/education/education.js +++ b/public/education/education.js @@ -111,6 +111,12 @@ class WebPage { constructor(args) { Object.assign(this, args); } + + // setMeta() { + // if (!this.meta) { + // console.warn("Meta information missing") + // } + // } } module.exports = WebPage; diff --git a/public/education/index.html b/public/education/index.html index 04962dd242d08a319718a831f2d40f7c4e46807c..23ca44075947475b3cf1bd64afa36b789753c766 100644 --- a/public/education/index.html +++ b/public/education/index.html @@ -1,10 +1,10 @@ - <!DOCTYPE html> <html lang="fr"> <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="viewport" content="width=device-width, initial-scale=1, minimum-scale=1" /> - <title>Kuadrado Software - education</title> <link rel="icon" type="image/svg+xml" href="/favicon.svg"> <link href="/style/style.css" rel="stylesheet" /> </head> @@ -13,4 +13,3 @@ </body> <script type="text/javascript" src="./education.js"></script> </html> - \ No newline at end of file diff --git a/public/games/games.js b/public/games/games.js index 9f8e5ed0ab4ea7708baf206f5106460e1c5c4b54..f8474ebb63fe6148bc2909db5ccb764c3ef782c6 100644 --- a/public/games/games.js +++ b/public/games/games.js @@ -269,6 +269,12 @@ class WebPage { constructor(args) { Object.assign(this, args); } + + // setMeta() { + // if (!this.meta) { + // console.warn("Meta information missing") + // } + // } } module.exports = WebPage; diff --git a/public/games/index.html b/public/games/index.html index 820f92c083f690173940e1f515b15ce04f40c0c4..e68f86fcf0feaecf73a39109338dfc8b28a23fa0 100644 --- a/public/games/index.html +++ b/public/games/index.html @@ -1,10 +1,10 @@ - <!DOCTYPE html> <html lang="fr"> <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="viewport" content="width=device-width, initial-scale=1, minimum-scale=1" /> - <title>Kuadrado Software - games</title> <link rel="icon" type="image/svg+xml" href="/favicon.svg"> <link href="/style/style.css" rel="stylesheet" /> </head> @@ -13,4 +13,3 @@ </body> <script type="text/javascript" src="./games.js"></script> </html> - \ No newline at end of file diff --git a/public/index.html b/public/index.html index a4e2bc3e52b66def0da153d2b4e137464ca9647e..2edf9345588a0464e3c6edd236b128a39ee22cc6 100644 --- a/public/index.html +++ b/public/index.html @@ -3,6 +3,7 @@ <head> <meta charset="utf-8" /> <title>Kuadrado Software</title> + <meta name="description" content="Créations numériques, jeux vidéos, web, software et pédagogie."> <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 c66f21a162527b8bf9967ea849989a32087c06de..431e009c095e74640fe12867f63250b997add5c4 100644 --- a/public/software-development/index.html +++ b/public/software-development/index.html @@ -1,10 +1,10 @@ - <!DOCTYPE html> <html lang="fr"> <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="viewport" content="width=device-width, initial-scale=1, minimum-scale=1" /> - <title>Kuadrado Software - software-development</title> <link rel="icon" type="image/svg+xml" href="/favicon.svg"> <link href="/style/style.css" rel="stylesheet" /> </head> @@ -13,4 +13,3 @@ </body> <script type="text/javascript" src="./software-development.js"></script> </html> - \ No newline at end of file diff --git a/public/software-development/software-development.js b/public/software-development/software-development.js index f8c40d40ee85914a0c02d7332e283f81ec2456b4..68e82f3875ac32625a5c438a95d2bd16f65bdfc4 100644 --- a/public/software-development/software-development.js +++ b/public/software-development/software-development.js @@ -269,6 +269,12 @@ class WebPage { constructor(args) { Object.assign(this, args); } + + // setMeta() { + // if (!this.meta) { + // console.warn("Meta information missing") + // } + // } } module.exports = WebPage; diff --git a/src/lib/web-page.js b/src/lib/web-page.js index b58f4c0a88f85c2b45ca6220c6ed4651488dbfb1..022fd3bfdb091b5a072679f592b95e33e7632520 100644 --- a/src/lib/web-page.js +++ b/src/lib/web-page.js @@ -4,6 +4,12 @@ class WebPage { constructor(args) { Object.assign(this, args); } + + // setMeta() { + // if (!this.meta) { + // console.warn("Meta information missing") + // } + // } } module.exports = WebPage; \ No newline at end of file diff --git a/src/pages/education/meta.json b/src/pages/education/meta.json new file mode 100644 index 0000000000000000000000000000000000000000..3f229c5a6b5f5135976c5bd41fb098fa77363b67 --- /dev/null +++ b/src/pages/education/meta.json @@ -0,0 +1,4 @@ +{ + "title": "Kuadrado Software | Pédagogie", + "description": "Animations autour de la création de jeux vidéos, vulgarisation numérique. Découvrez nos initiatives pédagogiques." +} \ No newline at end of file diff --git a/src/pages/games/meta.json b/src/pages/games/meta.json new file mode 100644 index 0000000000000000000000000000000000000000..7476b5c4d50dfe6ddbb1b6275b8077f283c9111d --- /dev/null +++ b/src/pages/games/meta.json @@ -0,0 +1,4 @@ +{ + "title": "Kuadrado Software | Jeux", + "description": "Création de jeux vidéos indépendants. Jeux web, PC et projets en cours de développement" +} \ No newline at end of file diff --git a/src/pages/software-development/meta.json b/src/pages/software-development/meta.json new file mode 100644 index 0000000000000000000000000000000000000000..b6f4d515abdbc5d84205743c337383cd56a0f74c --- /dev/null +++ b/src/pages/software-development/meta.json @@ -0,0 +1,4 @@ +{ + "title": "Kuadrado Software | Software", + "description": "Développement web, moteur de jeux, outillage logiciel, retrouvez nos projets en détail." +} \ No newline at end of file