htdocs/node/makeprojects.js

47 lines
1.3 KiB
JavaScript
Raw Permalink Normal View History

2024-11-02 02:03:32 +01:00
const projects = require("/var/www/html/project/projects.js");
const filePath = "/var/www/html/project/projects/";
2024-10-31 14:52:17 +01:00
const fs = require("fs");
2024-11-02 02:03:32 +01:00
const { pageTop, pageBottom } = require("/var/www/html/html.js")
2024-10-31 14:52:17 +01:00
let content = `${pageTop}
<body>
<table class="projects-table">
<tr>
<td>Name:</td>
<td>Description:</td>
<td>Language(s):</td>
<td>Dependencies:</td>
<td>Date of Development:</td>
<td>.zip:&nbsp;&nbsp;&nbsp;&nbsp;</td>
<td>.tar.gz:</td>
<tr>`
console.log(projects);
////////////////////////////////
// Make each individual blog page
/////////////////////////////////
for (let length = 0; length < projects.length; length++) {
console.log(length)
content += `
<tr>
<td>${projects[length][0]}</td>
<td>${projects[length][1]}</td>
<td>${projects[length][2]}</td>
<td>${projects[length][3]}</td>
<td>${projects[length][4]}</td>
<td><a href="projects/${projects[length][5]}" download=""><img src="/images/download.png"></a></td>
<td><a href="projects/${projects[length][6]}" download=""><img src="/images/download.png"></a></td>`
}
content += `</table></body>${pageBottom}`
2024-11-02 02:03:32 +01:00
fs.writeFile("/var/www/html/project/index.html", content, (err) => {
2024-10-31 14:52:17 +01:00
if (err) {
console.error('Error creating file:', err);
} else {
2024-11-02 02:03:32 +01:00
console.log('File edited successfully: /var/www/html/project/index.html', );
2024-10-31 14:52:17 +01:00
}
});