-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathpost.html
More file actions
44 lines (38 loc) · 1.4 KB
/
post.html
File metadata and controls
44 lines (38 loc) · 1.4 KB
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>AxionOS Blog Post</title>
<link rel="stylesheet" href="css/theme.css" />
<link rel="stylesheet" href="css/post.css" />
<script src="posts.js"></script>
</head>
<body>
<main class="post-container">
<article id="post-content"></article>
</main>
<script>
const params = new URLSearchParams(window.location.search);
const id = params.get('id');
const post = window.posts.find(p => p.id === id);
const container = document.getElementById('post-content');
if (!post) {
container.innerHTML = '<p>Post not found.</p>';
} else {
const authorName = post.author?.name || 'Unknown';
const authorUser = post.author?.username ? `(${post.author.username})` : '';
const date = new Date(post.date).toLocaleDateString(undefined, { year: 'numeric', month: 'long', day: 'numeric' });
container.innerHTML = `
<header class="post-header">
<p class="post-meta">Written on ${date} by ${authorName} ${authorUser}</p>
<h1 class="post-title">${post.title}</h1>
<p class="post-summary">${post.summary}</p>
</header>
${post.banner ? `<img class="post-banner" src="${post.banner}" alt="Banner">` : ''}
<div class="post-body">${post.content}</div>
`;
}
</script>
</body>
</html>