- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.js
More file actions
Latest commit
34 lines (24 loc) · 1010 Bytes
/
Copy pathbuild.js
File metadata and controls
34 lines (24 loc) · 1010 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
constfs=require('fs');
constpath=require('path');
constpageNames=[
"arianna",
"aron",
"nile"
];
// Paths to header and footer
constheaderPath=path.join(__dirname,'src','sections','header.html');
constfooterPath=path.join(__dirname,'src','sections','footer.html');
// Read the header and footer content
constheaderContent=fs.readFileSync(headerPath,'utf8');
constfooterContent=fs.readFileSync(footerPath,'utf8');
pageNames.forEach(name=>{
// Path to the content file
constcontentPath=path.join(__dirname,'content',`${name}.html`);
constpageContent=fs.readFileSync(contentPath,'utf8');
// Combine header, page content, and footer
constfinalContent=`${headerContent}\n${pageContent}\n${footerContent}`;
constoutputPath=path.join(__dirname,`${name}.html`);
fs.writeFileSync(outputPath,finalContent,'utf8');
console.log(`Created ${outputPath}`);
});
console.log('All files have been created successfully.');