Skip to content

Commit

Permalink
Fix build issues
Browse files Browse the repository at this point in the history
  • Loading branch information
ethanuppal committed Apr 27, 2024
1 parent 0b9fbc6 commit d88b9c7
Show file tree
Hide file tree
Showing 8 changed files with 38 additions and 32 deletions.
3 changes: 3 additions & 0 deletions src/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ nav {
padding: 0.5em;
border-radius: 0.1em;
}
#nav-list a {
text-decoration: none;
}
.reset-float {
float: none;
}
3 changes: 3 additions & 0 deletions src/html/nav.html
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
<nav>
<div id="nav-list">
<a href="/">Home</a>
|
<a href="/404.html">404</a>
|
<a href="/broken1">Broken Link 1</a>
|
<a href="/broken2">Broken Link 2</a>
</div>
<div class="reset-float"></div>
Expand Down
50 changes: 25 additions & 25 deletions src/js/page.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,32 +4,33 @@ function assert(condition, message) {
}
}

function include(element, source, substitutions) {
fetch(`/src/html/${source}`)
.then(response => response.text())
.then(data => {
let temp = data;
if (substitutions) {
for (const key in substitutions) {
temp = temp.replace(`{{${key}}}`, substitutions[key]);
}
async function include(element, source, substitutions) {
try {
let response = await fetch(`/src/html/${source}`);
let data = await response.text();
let temp = data;
if (substitutions) {
for (const key in substitutions) {
temp = temp.replace(`{{${key}}}`, substitutions[key]);
}
element.innerHTML = temp;
})
.catch(error => console.error(error));
}
element.innerHTML = temp;
} catch (error) {
console.error(error);
}
}

let html = document.getElementsByTagName('html')[0];
html.lang = 'en';
html.dir = 'ltr';
include(html, 'template.html');
let script = document.createElement('script');
script.src = `/src/js/page/${html.id}`;
script.defer = true;
document.head.appendChild(script);
window.addEventListener('load', async function () {
let html = document.getElementsByTagName('html')[0];
html.lang = 'en';
html.dir = 'ltr';
await include(html, 'template.html');
let script = document.createElement('script');
script.src = `/src/js/page/${html.id}`;
script.defer = true;
document.head.appendChild(script);

window.addEventListener('load', function () {
let body = document.body;
let body = document.getElementsByTagName('body')[0];

let container = document.createElement('div');
container.id = 'container';
Expand All @@ -40,7 +41,7 @@ window.addEventListener('load', function () {
container.appendChild(header);
return header;
})()
include(header, 'nav.html');
await include(header, 'nav.html');

let content = document.createElement('div');
content.id = 'content';
Expand All @@ -61,7 +62,6 @@ window.addEventListener('load', function () {
let page = {
content: content
};
Page(page);
await Page(page);
document.title = page.title || "cornellev.github.io";

}, false)
2 changes: 1 addition & 1 deletion src/js/page.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions src/js/page/404.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
function Page(page) {
async function Page(page) {
page.title = 'CEV Autonomy';
include(page.content, '404.html');
await include(page.content, '404.html');
}
2 changes: 1 addition & 1 deletion src/js/page/404.min.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
function Page(page){page.title="CEV Autonomy";include(page.content,"404.html")}
async function Page(page){page.title="CEV Autonomy";await include(page.content,"404.html")}
4 changes: 2 additions & 2 deletions src/js/page/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
function Page(page) {
async function Page(page) {
page.title = 'CEV Autonomy';
include(page.content, 'home.html');
await include(page.content, 'home.html');
}
2 changes: 1 addition & 1 deletion src/js/page/index.min.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
function Page(page){page.title="CEV Autonomy";include(page.content,"home.html")}
async function Page(page){page.title="CEV Autonomy";await include(page.content,"home.html")}

0 comments on commit d88b9c7

Please sign in to comment.