constexpress=require("express");constpath=require("path");constapp=express();/* Ensure any requests prefixed with /static will serve our "frontend/static" directory */app.use("/static",express.static(path.resolve(__dirname,"frontend","static")));/* Redirect all routes to our (soon to exist) "index.html" file */app.get("/*",(req,res)=>{res.sendFile(path.resolve("frontend","index.html"));});app.listen(process.env.PORT||3000,()=>console.log("Server running..."));
> **Note:** the `data-link` attributes on our `<a>` tags - any links marked with this attribute will use the History API to enable changes to the view (#app) without a page refresh. We'll learn more about this shortly.
> **Also note:** the #app div is used as the container for each view (Dashboard, Posts etc.) which we'll be learning more about a bit later on.
## Adding the CSS
We may as well get the CSS over and done with so we have something pretty to look at - let's make a new file within `frontend/static` named `main.css`.
```css
body {
--nav-width: 200px;
margin: 0 0 0 var(--nav-width);
font-family: 'Quicksand', sans-serif;
font-size: 18px;
}
/* Creates a full-height, left-mounted navigation menu */
.nav {
position: fixed;
top: 0;
left: 0;
width: var(--nav-width);
height: 100vh;
background: #222222;
}
/* Making these look fantastic */
.nav__link {
display: block;
padding: 12px 18px;
text-decoration: none;
color: #eeeeee;
font-weight: 500;
}
.nav__link:hover {
background: rgba(255, 255, 255, 0.05);
}
#app {
margin: 2em;
line-height: 1.5;
font-weight: 500;
}
/* The 'dcode' green always needs to make an appearance */
a {
color: #009579;
}
letmatch=potentialMatches.find(potentialMatch=>potentialMatch.result!==null);/* Route not found - return first route OR a specific "not-found" route */if (!match){match={route:routes[0],result:[location.pathname]};}
document.addEventListener("DOMContentLoaded",()=>{document.body.addEventListener("click",e=>{if (e.target.matches("[data-link]")){e.preventDefault();navigateTo(e.target.href);}});/* Document has loaded - run the router! */router();});