-
Notifications
You must be signed in to change notification settings - Fork 0
/
blogpost.html
56 lines (51 loc) · 1.94 KB
/
blogpost.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script src="https://cdn.jsdelivr.net/npm/marked/marked.min.js"></script>
<title>Wilbur's Blog</title>
<link rel="shortcut icon" href="images/icon.ico" type="image/x-icon">
<link rel="stylesheet" href="css/styleBlog.css">
</head>
<body>
<header>
<div class="header-container">
<h1>Wilbur's Cool Site</h1>
<nav>
<ul>
<li><a href="index.html"><u style="color: red;">H</u>ome</a></li>
<li><a href="blog.html"><u style="color: red;">B</u>log</a></li>
<li><a href="projects.html"><u style="color: red;">P</u>rojects</a></li>
<li><a href="about.html"><u style="color: red;">A</u>bout Me</a></li>
</ul>
</nav>
</div>
</header>
<div class="wrapper">
<div id="main-projects">
<span id="blogpostmd"></span>
</div>
</div>
<script>
const urlParams = new URLSearchParams(window.location.search);
const post = urlParams.get('post');
fetch('blogposts/' + post)
.then(response => {
if (!response.ok) {
throw new Error(`HTTP error! Status: ${response.status}`);
}
return response.text();
})
.then(markdownContent => {
console.log("Got post:", markdownContent);
document.getElementById('blogpostmd').innerHTML = marked.parse(markdownContent);
})
.catch(error => {
console.error("Failed to Load Blogpost:", error);
document.getElementById('blogpostmd').innerHTML = "<h1>FAILED TO GET POST</h1>"
});
</script>
</body>
</html>