generated from tonytins/frontpage25
Initial commit
This commit is contained in:
commit
f825693b8e
6 changed files with 497 additions and 0 deletions
5
public/content/home.html
Normal file
5
public/content/home.html
Normal file
|
@ -0,0 +1,5 @@
|
|||
<h2>Welcome to the Home Page</h2>
|
||||
<p>
|
||||
This is the home page content, dynamically loaded from an external HTML
|
||||
file.
|
||||
</p>
|
34
public/index.html
Normal file
34
public/index.html
Normal file
|
@ -0,0 +1,34 @@
|
|||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>Frontpage 25</title>
|
||||
<link rel="stylesheet" href="style.css" />
|
||||
</head>
|
||||
<body>
|
||||
<header>
|
||||
<h1>Frontpage 25</h1>
|
||||
</header>
|
||||
|
||||
<main>
|
||||
<nav id="sidebar">
|
||||
<!-- Menu will be injected by JS -->
|
||||
</nav>
|
||||
|
||||
<section id="content">
|
||||
<h2>Welcome to the Future of the Past</h2>
|
||||
<p>
|
||||
This is a modern website with a 2003 aesthetic. You're
|
||||
welcome.
|
||||
</p>
|
||||
</section>
|
||||
</main>
|
||||
|
||||
<footer>
|
||||
<p>© 2025 Frontpage 25</p>
|
||||
</footer>
|
||||
|
||||
<script src="script.js"></script>
|
||||
</body>
|
||||
</html>
|
83
public/script.js
Normal file
83
public/script.js
Normal file
|
@ -0,0 +1,83 @@
|
|||
// Mobile menu toggle
|
||||
const menuToggle = document.createElement("div");
|
||||
menuToggle.className = "menu-toggle";
|
||||
menuToggle.textContent = "☰ Menu";
|
||||
document.body.insertBefore(menuToggle, document.body.firstChild);
|
||||
|
||||
const sidebar = document.getElementById("sidebar");
|
||||
|
||||
menuToggle.addEventListener("click", () => {
|
||||
sidebar.classList.toggle("active");
|
||||
});
|
||||
|
||||
// Create the menu dynamically
|
||||
const menuContainer = document.getElementById("sidebar");
|
||||
const menuData = {
|
||||
pages: [
|
||||
{
|
||||
Name: "home",
|
||||
Label: "Home",
|
||||
Contents: "content/home.html",
|
||||
},
|
||||
{
|
||||
Name: "about",
|
||||
Label: "About",
|
||||
Contents: "content/about.html",
|
||||
},
|
||||
{
|
||||
Name: "services",
|
||||
Label: "Services",
|
||||
Contents: "content/services.html",
|
||||
},
|
||||
{
|
||||
Name: "contact",
|
||||
Label: "Contact",
|
||||
Contents: "content/contact.html",
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
// Generate the menu
|
||||
menuData.pages.forEach((page) => {
|
||||
const listContainer = document.createElement("ul");
|
||||
const list = document.createElement("li");
|
||||
const link = document.createElement("a");
|
||||
link.href = `#${page.Name}`;
|
||||
link.textContent = page.Label;
|
||||
link.addEventListener("click", (e) => {
|
||||
e.preventDefault();
|
||||
loadPage(page.Name);
|
||||
});
|
||||
listContainer.appendChild(list);
|
||||
list.appendChild(link);
|
||||
menuContainer.appendChild(listContainer);
|
||||
});
|
||||
|
||||
// Load the content dynamically
|
||||
function loadPage(name) {
|
||||
const page = menuData.pages.find((p) => p.Name === name);
|
||||
if (!page) return;
|
||||
|
||||
fetch(page.Contents)
|
||||
.then((response) => response.text())
|
||||
.then((html) => {
|
||||
document.getElementById("content").innerHTML = html;
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error("Error loading content:", error);
|
||||
document.getElementById("content").innerHTML =
|
||||
`<p>Failed to load ${page.Label} content.</p>`;
|
||||
});
|
||||
}
|
||||
|
||||
// Handle hash changes
|
||||
window.addEventListener("hashchange", () => {
|
||||
const hash = window.location.hash.substring(1) || "home";
|
||||
loadPage(hash);
|
||||
});
|
||||
|
||||
// Load the default page
|
||||
window.addEventListener("load", () => {
|
||||
const hash = window.location.hash.substring(1) || "home";
|
||||
loadPage(hash);
|
||||
});
|
114
public/style.css
Normal file
114
public/style.css
Normal file
|
@ -0,0 +1,114 @@
|
|||
/* Reset some defaults */
|
||||
* {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
font-family: Arial;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
body {
|
||||
font-family: "Trebuchet MS", sans-serif;
|
||||
background-color: #f0f0f0;
|
||||
color: #333;
|
||||
line-height: 1.6;
|
||||
}
|
||||
|
||||
header {
|
||||
background-color: #003366;
|
||||
color: #fff;
|
||||
padding: 1em;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
main {
|
||||
display: flex;
|
||||
padding: 1em;
|
||||
margin-left: auto;
|
||||
margin-right: auto;
|
||||
max-width: 1024px;
|
||||
}
|
||||
|
||||
nav {
|
||||
width: 200px;
|
||||
background-color: #cccccc;
|
||||
padding: 1em;
|
||||
}
|
||||
|
||||
nav ul {
|
||||
list-style: none;
|
||||
}
|
||||
|
||||
nav ul li {
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
nav ul li a {
|
||||
color: #000;
|
||||
text-decoration: none;
|
||||
display: block;
|
||||
padding: 5px;
|
||||
background-color: #ddd;
|
||||
border-radius: 4px;
|
||||
}
|
||||
|
||||
nav ul li a:hover {
|
||||
background-color: #aaa;
|
||||
}
|
||||
|
||||
.menu-toggle {
|
||||
display: none;
|
||||
}
|
||||
|
||||
#content {
|
||||
flex: 1;
|
||||
padding: 1em;
|
||||
background-color: #fff;
|
||||
margin-left: 1em;
|
||||
border: 1px solid #ccc;
|
||||
border-radius: 4px;
|
||||
}
|
||||
|
||||
footer {
|
||||
position: fixed;
|
||||
bottom: 0;
|
||||
text-align: center;
|
||||
padding: 1em;
|
||||
background-color: #003366;
|
||||
color: #fff;
|
||||
margin-top: 1em;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
/* Mobile menu */
|
||||
@media (max-width: 768px) {
|
||||
main {
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
nav {
|
||||
width: 100%;
|
||||
margin-bottom: 1em;
|
||||
}
|
||||
|
||||
#content {
|
||||
margin-left: 0;
|
||||
}
|
||||
|
||||
.menu-toggle {
|
||||
display: block;
|
||||
background: #003366;
|
||||
color: #fff;
|
||||
padding: 10px;
|
||||
text-align: center;
|
||||
cursor: pointer;
|
||||
border-bottom: 1px solid #ccc;
|
||||
}
|
||||
|
||||
#sidebar {
|
||||
display: none;
|
||||
}
|
||||
|
||||
#sidebar.active {
|
||||
display: block;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue