Pour tout problème contactez-nous par mail : support@froggit.fr | La FAQ :grey_question: | Rejoignez-nous sur le Chat :speech_balloon:

Skip to content
Snippets Groups Projects
Commit fb051b08 authored by peter_rabbit's avatar peter_rabbit
Browse files

build from html template

parent 06daedd8
No related branches found
No related tags found
No related merge requests found
...@@ -17,23 +17,37 @@ b.add(`${curDir}/src/main.js`) ...@@ -17,23 +17,37 @@ b.add(`${curDir}/src/main.js`)
.pipe(fs.createWriteStream(`${curDir}/public/main.js`)); .pipe(fs.createWriteStream(`${curDir}/public/main.js`));
// Handle subpages // Handle subpages
function getPageHtml(pagename) { function getPageHtml(pageName, pageMeta) {
return ` let html = fs.readFileSync(`${curDir}/public/index.html`, "utf-8");
<!DOCTYPE html> const setMeta = function (metaName, value) {
<html lang="fr"> return html.replace(
<head> html.match(new RegExp(`<meta.+name="${metaName}".+>`, "g")),
<meta charset="utf-8" /> `<meta name="${metaName}" content="${value}">`
<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"> const setTitle = function (value) {
<link href="/style/style.css" rel="stylesheet" /> return html.replace(
</head> html.match(new RegExp(`<title.+</title>`, "g")),
<body> `<title>${value}</title>`
<main></main> );
</body> };
<script type="text/javascript" src="./${pagename}.js"></script> const setStyleSheet = function () {
</html> 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`); const pages = fs.readdirSync(`${curDir}/src/pages`);
...@@ -53,7 +67,8 @@ for (const p of pages) { ...@@ -53,7 +67,8 @@ for (const p of pages) {
.pipe(fs.createWriteStream(`${targetDirPath}/${p}.js`)); .pipe(fs.createWriteStream(`${targetDirPath}/${p}.js`));
const page = fs.createWriteStream(`${targetDirPath}/index.html`); 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. // If pages have been deleted in source, remove them in output directory too.
......
...@@ -111,6 +111,12 @@ class WebPage { ...@@ -111,6 +111,12 @@ class WebPage {
constructor(args) { constructor(args) {
Object.assign(this, args); Object.assign(this, args);
} }
// setMeta() {
// if (!this.meta) {
// console.warn("Meta information missing")
// }
// }
} }
module.exports = WebPage; module.exports = WebPage;
......
<!DOCTYPE html> <!DOCTYPE html>
<html lang="fr"> <html lang="fr">
<head> <head>
<meta charset="utf-8" /> <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" /> <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 rel="icon" type="image/svg+xml" href="/favicon.svg">
<link href="/style/style.css" rel="stylesheet" /> <link href="/style/style.css" rel="stylesheet" />
</head> </head>
...@@ -13,4 +13,3 @@ ...@@ -13,4 +13,3 @@
</body> </body>
<script type="text/javascript" src="./education.js"></script> <script type="text/javascript" src="./education.js"></script>
</html> </html>
\ No newline at end of file
...@@ -269,6 +269,12 @@ class WebPage { ...@@ -269,6 +269,12 @@ class WebPage {
constructor(args) { constructor(args) {
Object.assign(this, args); Object.assign(this, args);
} }
// setMeta() {
// if (!this.meta) {
// console.warn("Meta information missing")
// }
// }
} }
module.exports = WebPage; module.exports = WebPage;
......
<!DOCTYPE html> <!DOCTYPE html>
<html lang="fr"> <html lang="fr">
<head> <head>
<meta charset="utf-8" /> <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" /> <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 rel="icon" type="image/svg+xml" href="/favicon.svg">
<link href="/style/style.css" rel="stylesheet" /> <link href="/style/style.css" rel="stylesheet" />
</head> </head>
...@@ -13,4 +13,3 @@ ...@@ -13,4 +13,3 @@
</body> </body>
<script type="text/javascript" src="./games.js"></script> <script type="text/javascript" src="./games.js"></script>
</html> </html>
\ No newline at end of file
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
<head> <head>
<meta charset="utf-8" /> <meta charset="utf-8" />
<title>Kuadrado Software</title> <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" /> <meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1" />
<link rel="icon" type="image/svg+xml" href="/favicon.svg"> <link rel="icon" type="image/svg+xml" href="/favicon.svg">
<link href="/style/style.css" rel="stylesheet" /> <link href="/style/style.css" rel="stylesheet" />
......
<!DOCTYPE html> <!DOCTYPE html>
<html lang="fr"> <html lang="fr">
<head> <head>
<meta charset="utf-8" /> <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" /> <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 rel="icon" type="image/svg+xml" href="/favicon.svg">
<link href="/style/style.css" rel="stylesheet" /> <link href="/style/style.css" rel="stylesheet" />
</head> </head>
...@@ -13,4 +13,3 @@ ...@@ -13,4 +13,3 @@
</body> </body>
<script type="text/javascript" src="./software-development.js"></script> <script type="text/javascript" src="./software-development.js"></script>
</html> </html>
\ No newline at end of file
...@@ -269,6 +269,12 @@ class WebPage { ...@@ -269,6 +269,12 @@ class WebPage {
constructor(args) { constructor(args) {
Object.assign(this, args); Object.assign(this, args);
} }
// setMeta() {
// if (!this.meta) {
// console.warn("Meta information missing")
// }
// }
} }
module.exports = WebPage; module.exports = WebPage;
......
...@@ -4,6 +4,12 @@ class WebPage { ...@@ -4,6 +4,12 @@ class WebPage {
constructor(args) { constructor(args) {
Object.assign(this, args); Object.assign(this, args);
} }
// setMeta() {
// if (!this.meta) {
// console.warn("Meta information missing")
// }
// }
} }
module.exports = WebPage; module.exports = WebPage;
\ No newline at end of file
{
"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
{
"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
{
"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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment