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`)
.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.
......
......@@ -111,6 +111,12 @@ class WebPage {
constructor(args) {
Object.assign(this, args);
}
// setMeta() {
// if (!this.meta) {
// console.warn("Meta information missing")
// }
// }
}
module.exports = WebPage;
......
<!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
......@@ -269,6 +269,12 @@ class WebPage {
constructor(args) {
Object.assign(this, args);
}
// setMeta() {
// if (!this.meta) {
// console.warn("Meta information missing")
// }
// }
}
module.exports = WebPage;
......
<!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
......@@ -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" />
......
<!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
......@@ -269,6 +269,12 @@ class WebPage {
constructor(args) {
Object.assign(this, args);
}
// setMeta() {
// if (!this.meta) {
// console.warn("Meta information missing")
// }
// }
}
module.exports = WebPage;
......
......@@ -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
{
"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