38 lines
1.1 KiB
JavaScript
38 lines
1.1 KiB
JavaScript
// Assembles section HTML files into the page.
|
|
// Each section is a separate file for easy editing.
|
|
|
|
const sections = [
|
|
"sections/header.html",
|
|
"sections/about.html",
|
|
"sections/teaching.html",
|
|
"sections/research.html",
|
|
"sections/cv.html",
|
|
// "sections/projects.html",
|
|
"sections/contact.html",
|
|
];
|
|
|
|
async function loadSections() {
|
|
const container = document.getElementById("page-content");
|
|
let html = "";
|
|
|
|
for (const section of sections) {
|
|
try {
|
|
const response = await fetch(section);
|
|
if (response.ok) {
|
|
const text = await response.text();
|
|
html += text;
|
|
} else {
|
|
console.warn(`Could not load section: ${section}`);
|
|
html += `<section><p>Error loading section: ${section}</p></section>`;
|
|
}
|
|
} catch (err) {
|
|
console.warn(`Failed to load section: ${section}`, err);
|
|
html += `<section><p>Failed to load section: ${section}</p></section>`;
|
|
}
|
|
}
|
|
|
|
container.innerHTML = html;
|
|
}
|
|
|
|
loadSections();
|