-
Notifications
You must be signed in to change notification settings - Fork 0
/
blog.html
230 lines (204 loc) · 8.61 KB
/
blog.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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>BLOGS</title>
<link rel="icon" href="/favicon.ico">
<link href="https://unpkg.com/[email protected]/css/nes.min.css" rel="stylesheet">
<link href="https://fonts.googleapis.com/css2?family=Press+Start+2P&display=swap" rel="stylesheet">
<script src="https://cdn.tailwindcss.com"></script>
<style>
@font-face {
font-family: 'Joystick';
src: url('../fonts/joystix_monospace.otf') format('opentype');
}
@font-face {
font-family: 'Gumball';
src: url('../fonts/title.TTF') format('truetype');
}
@font-face {
font-family: 'Fipps';
src: url('../fonts/Fipps.otf') format('opentype');
}
.headingfont {
font-family: 'Joystick', monospace;
}
.title {
font-family: 'Gumball', monospace;
}
.fipps {
font-family: 'Fipps', monospace;
}
body {
background-color: black;
background-repeat: repeat;
background-position: top center;
background-attachment: scroll;
background-size: 30% auto;
color: white;
margin: 0;
padding: 0;
height: 100%;
width: 100%;
position: relative;
}
*,
*::before,
*::after {
box-sizing: border-box;
}
.img {
image-rendering: -webkit-optimize-contrast;
image-rendering: crisp-edges;
image-rendering: pixelated;
}
.navbar {
box-shadow: 0 -4px #000, 0 -8px #fff, 4px 0 #000, 4px -4px #fff, 8px 0 #fff, 0 4px #000, 0 8px #fff, -4px 0 #000, -4px 4px #fff, -8px 0 #fff, -4px -4px #fff, 4px 4px #fff;
background-color: black;
color: white;
top: 15px;
left: 20px;
right: 20px;
position: fixed;
height: 30px;
display: flex;
align-items: center;
justify-content: space-between;
z-index: 1000;
padding: 0 10px;
}
.nav-item {
margin: 0 10px;
}
.modal {
display: none;
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: rgba(0, 0, 0, 0.5);
z-index: 100;
justify-content: center;
align-items: center;
}
.modal-content {
background-color: white;
border-radius: 8px;
padding: 20px;
max-width: 90%;
max-height: 90%;
overflow-y: auto;
}
.boxxy {
box-shadow: 0 -4px #000, 0 -8px #fff, 4px 0 #000, 4px -4px #fff, 8px 0 #fff, 0 4px #000, 0 8px #fff, -4px 0 #000, -4px 4px #fff, -8px 0 #fff, -4px -4px #fff, 4px 4px #fff;
background-color: black;
color: white;
}
</style>
</head>
<body>
<header class="w-full">
<nav class="navbar">
<div class="hidden md:flex items-center justify-between w-full">
<div class="flex items-center space-x-4">
<a class="nav-item" href="blog.html">Blog</a>
<a class="nav-item" href="project.html">Projects</a>
</div>
<a href="/index.html" class="flex items-center justify-center">
<img src="indexbg/logo.png" alt="logo" class="h-8 img">
</a>
<div class="flex items-center space-x-4">
<a class="nav-item" href="about.html">About</a>
<a class="nav-item" href="contact.html">Contact</a>
</div>
</div>
<!-- Hamburger menu -->
<div class="md:hidden flex items-center justify-between w-full">
<a href="/index.html" class="flex items-center justify-start">
<img src="indexbg/logo.png" alt="logo" class="h-8 img">
</a>
<button id="menu-toggle" class="flex items-center justify-end">
<svg class="w-6 h-6 text-white" fill="none" stroke="currentColor" viewBox="0 0 24 24"
xmlns="http://www.w3.org/2000/svg">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
d="M4 6h16M4 12h16m-7 6h7"></path>
</svg>
</button>
</div>
<div id="mobile-menu" class="hidden absolute top-0 right-0 bg-black w-full mt-14 z-50">
<a class="block py-2 px-4 text-white" href="index.html">Home</a>
<a class="block py-2 px-4 text-white" href="blog.html">Blog</a>
<a class="block py-2 px-4 text-white" href="project.html">Projects</a>
<a class="block py-2 px-4 text-white" href="about.html">About</a>
<a class="block py-2 px-4 text-white" href="contact.html">Contact</a>
</div>
</nav>
</header>
<main class="py-6 mt-14 w-full px-4 sm:px-16 space-y-8" id="blog-container">
<!-- Blog posts will be inserted here -->
</main>
<!-- Pagination Controls -->
<div id="pagination" class="flex items-center justify-evenly md:justify-center my-6">
<button id="prev-page" class="px-2 py-1 bg-gray-700 text-white boxxy h-[30px] text-[12px] md:text-[16px]"
disabled>Previous</button>
<span id="page-info" class="mx-4 text-white align-center md:mx-10 text-[16px]">1</span>
<button id="next-page"
class="px-2 py-1 bg-gray-700 text-white boxxy h-[30px] text-[12px] md:text-[16px]">Next</button>
</div>
<footer class="mt-10 flex items-center justify-center py-4 w-full bg-gray-900">
<p class="text-white max-[320px]:text-[8px] text-[10px] lg:text-[16px] mr-2">Copyright © 2024 --</p>
<a href="mailto:tanishvashisth@"
class="text-white max-[320px]:text-[8px] text-[10px] lg:text-[16px] underline">tanishvashisth</a>
</footer>
<script>
let currentPage = 1;
const postsPerPage = 5;
const blogContainer = document.getElementById('blog-container');
const pageInfo = document.getElementById('page-info');
const prevPageButton = document.getElementById('prev-page');
const nextPageButton = document.getElementById('next-page');
function fetchPosts(page = 1) {
fetch(`https://dev.to/api/articles?username=bogusdeck&page=${page}&per_page=${postsPerPage}`)
.then(response => response.json())
.then(data => {
blogContainer.innerHTML = ''; // Clear current posts
data.forEach(post => {
const blogPost = document.createElement('div');
blogPost.className = 'boxxy mb-6 p-4 mx-4';
blogPost.innerHTML = `
<h2 class="text-xl font-semibold title"><a href="blog-detail.html?id=${post.id}" class="text-blue-500 hover:underline">${post.title}</a></h2>
<p class="text-white-700 mt-2 headingfont">${post.description}</p>
<p class="text-gray-400 mt-2 text-sm"><small>Posted on ${new Date(post.published_at).toDateString()}</small></p>
`;
blogContainer.appendChild(blogPost);
});
pageInfo.textContent = `${currentPage}`;
updatePaginationControls();
})
.catch(error => console.error('Error fetching blog posts:', error));
}
function updatePaginationControls() {
prevPageButton.disabled = currentPage <= 1;
nextPageButton.disabled = false; // You might want to add logic to determine if there's more data to load
}
prevPageButton.addEventListener('click', () => {
if (currentPage > 1) {
currentPage--;
fetchPosts(currentPage);
}
});
nextPageButton.addEventListener('click', () => {
currentPage++;
fetchPosts(currentPage);
});
// Initial fetch
fetchPosts();
document.getElementById('menu-toggle').addEventListener('click', function () {
const menu = document.getElementById('mobile-menu');
menu.classList.toggle('hidden');
});
</script>
</body>
</html>