-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathblog.html
More file actions
138 lines (118 loc) · 4.82 KB
/
blog.html
File metadata and controls
138 lines (118 loc) · 4.82 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
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>AxionOS Blog</title>
<!-- Cloudflare DNS Prefetch -->
<link rel="dns-prefetch" href="https://fonts.googleapis.com">
<link rel="dns-prefetch" href="https://fonts.gstatic.com">
<!-- Preconnect for critical resources -->
<link rel="preconnect" href="https://fonts.googleapis.com" crossorigin>
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<!-- Preload critical CSS -->
<link rel="preload" href="css/theme.css" as="style">
<link rel="preload" href="css/blog.css" as="style">
<!-- Stylesheets -->
<link rel="stylesheet" href="css/theme.css" />
<link rel="stylesheet" href="css/blog.css" />
<link href="https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined" rel="stylesheet" />
<script src="posts.js"></script>
</head>
<body>
<header class="site-header">
<div class="container header-inner">
<h1 class="site-title">Blog</h1>
<p class="site-subtitle">Changelogs and news from the AxionOS team.</p>
</div>
</header>
<main class="container">
<section id="featured-post" class="featured-post"></section>
<section id="older-posts" class="blog-grid"></section>
</main>
<script>
function renderBlogPosts() {
const featuredContainer = document.getElementById('featured-post');
const olderContainer = document.getElementById('older-posts');
if (!window.posts || !window.posts.length) {
featuredContainer.innerHTML = '<p>No blog posts found.</p>';
return;
}
const sorted = [...window.posts].sort((a, b) => new Date(b.date) - new Date(a.date));
const [latest, ...older] = sorted;
const author = latest.author || {};
const date = new Date(latest.date).toLocaleDateString(undefined, {
year: 'numeric',
month: 'long',
day: 'numeric'
});
featuredContainer.innerHTML = `
<article class="featured-split">
<div class="featured-image" style="background-image:url('${latest.banner || 'assets/default-banner.jpg'}')"></div>
<div class="featured-text">
<p class="featured-date">${date}</p>
<h2 class="featured-title"><a href="post.html?id=${latest.id}">${latest.title}</a></h2>
<p class="featured-summary">${latest.summary}</p>
<div class="featured-author">
<span class="material-symbols-outlined">person_outline</span>
${author.name || 'Unknown'} (${author.username || ''})
</div>
<a href="post.html?id=${latest.id}" class="read-more">Read More →</a>
</div>
</article>
`;
older.forEach(post => {
const article = document.createElement('article');
const author = post.author || {};
const date = new Date(post.date).toLocaleDateString(undefined, { year: 'numeric', month: 'long', day: 'numeric' });
article.classList.add('blog-card');
article.style.backgroundImage = `url('${post.banner || 'assets/default-banner.jpg'}')`;
article.style.backgroundSize = 'cover';
article.style.backgroundPosition = 'center';
article.style.position = 'relative';
article.style.color = '#fff';
article.style.overflow = 'hidden';
const overlay = document.createElement('div');
overlay.style.position = 'absolute';
overlay.style.top = 0;
overlay.style.left = 0;
overlay.style.width = '100%';
overlay.style.height = '100%';
overlay.style.background = 'rgba(0, 0, 0, 0.5)';
overlay.style.zIndex = 1;
article.appendChild(overlay);
const cardContent = document.createElement('div');
cardContent.classList.add('card-content');
cardContent.style.position = 'relative';
cardContent.style.zIndex = 2;
cardContent.innerHTML = `
<p class="tagline">${post.tagline || ''}</p>
<h3 class="post-title">${post.title}</h3>
<p class="post-meta">
<span class="material-symbols-outlined">calendar_today</span> ${date}
<span class="material-symbols-outlined">person_outline</span> ${author.name || 'Unknown'} (${author.username || ''})
</p>
<a href="post.html?id=${post.id}" class="read-more">Read More →</a>
`;
article.appendChild(cardContent);
olderContainer.appendChild(article);
});
}
if (document.readyState === 'loading') {
document.addEventListener('DOMContentLoaded', renderBlogPosts);
} else {
if (window.posts) {
renderBlogPosts();
} else {
const checkPosts = setInterval(() => {
if (window.posts) {
clearInterval(checkPosts);
renderBlogPosts();
}
}, 50);
setTimeout(() => clearInterval(checkPosts), 5000);
}
}
</script>
</body>
</html>