Single Page Application (SPA) router for static site. View demo.
<script src="https://cdn.jsdelivr.net/gh/kevin-lem0n/Igloo/src/igloo.1.1.2.js"></script>Only available in igloo.2.js and above version
When prettyUrl is set to true, the url will be:
localhost:3000/#/page1 instead of localhost:3000/#/page1.
When prettyUrl is enabled, navigation between pages will cause a full page refresh.
<script src="https://cdn.jsdelivr.net/gh/kevin-lem0n/Igloo/src/igloo.2.js"></script>
<script>
// Igloo router configuration
$Igloo({
root: "#root"
folder: "views",
default_path: "index",
scope: ["index", "page1", "page2", "page3"],
error: "error"
prettyUrl: true;
})
</script>- In the root of your project directory, create an
index.html - In the root of your project directory, in
index.html, inside the head tag,
add the script to includeigloo.1.1.js
<script src="igloo.1.1.js"></script>- In the root of your project directory, create a
viewsfolder - Create these files inside the
viewsfolder:
- index.html
- page1.html
- page2.html
- page3.html
- error.html
- Copy the contents of each file form this repo
viewsfolder and paste them to your own code correspondingly. - In the root of your project directory, in
index.html, inside the body tag, paste these codes:
<br>
<a route="#index">Homepage</a>
<a route="#page1">Page 1</a>
<a route="#page2">Page 2</a>
<a route="#page3">Page 3</a>
<div id="root"></div>
<script>
// Igloo router configuration
$Igloo({
root: "#root" // this is the id of the div to inject the content to
folder: "views",
default_path: "index",
scope: ["index", "page1", "page2", "page3"],
error: "error"
prettyUrl: true;
})
</script>
<style>
#root{
margin-top: 20px;
}
a{
padding: 10px;
margin-right: 5px;
border: 1px solid darkgrey;
text-decoration: none;
color: black;
}
</style>- You are done with the sample template.