-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnews.html
More file actions
675 lines (631 loc) · 25 KB
/
news.html
File metadata and controls
675 lines (631 loc) · 25 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
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
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="News and press releases from Community Access -- the open source accessibility agents project.">
<title>News -- Community Access</title>
<link rel="icon" href="https://avatars.githubusercontent.com/u/263509777?v=4&s=32" type="image/png">
<link rel="apple-touch-icon" href="https://avatars.githubusercontent.com/u/263509777?v=4&s=180">
<meta property="og:title" content="News — Community Access">
<meta property="og:description" content="News and press releases from Community Access — the open source accessibility agents project.">
<meta property="og:image" content="https://avatars.githubusercontent.com/u/263509777?v=4&s=400">
<meta property="og:url" content="https://community-access.github.io/news.html">
<meta property="og:type" content="website">
<meta name="twitter:card" content="summary">
<link rel="stylesheet" href="styles.css">
<link rel="alternate" type="application/rss+xml" title="Community Access RSS Feed" href="https://community-access.org/feed.xml">
<style>
/* === Page Header === */
.page-header {
background: linear-gradient(160deg, var(--ca-indigo-dark) 0%, var(--ca-violet) 50%, var(--ca-indigo) 100%);
color: var(--ca-gray-50);
padding: 4rem 0 3rem;
text-align: center;
}
.page-header h1 {
font-size: clamp(2rem, 4vw, 3rem);
font-weight: 800;
letter-spacing: -0.03em;
line-height: 1.15;
margin-bottom: 1rem;
}
.page-header p {
font-size: 1.15rem;
max-width: 36rem;
margin: 0 auto;
opacity: 0.9;
}
/* === News List (uses shared .news-grid / .news-card from styles.css) === */
.news-list-section { padding: 4rem 0; }
/* === Single Post === */
.post-content {
max-width: 52rem;
margin: 0 auto;
padding: 3rem 0 5rem;
}
.post-content .post-back {
display: inline-block;
margin-bottom: 2rem;
color: var(--ca-indigo-light);
text-decoration: underline;
font-weight: 600;
font-size: 0.95rem;
}
.post-content .post-back:hover { text-decoration-thickness: 2px; }
.post-content h1 {
font-size: clamp(1.75rem, 3.5vw, 2.5rem);
font-weight: 800;
color: var(--ca-gray-900);
line-height: 1.2;
margin-bottom: 1rem;
}
.post-content .post-meta {
margin-bottom: 2rem;
font-size: 0.85rem;
font-weight: 600;
color: var(--ca-gray-700);
}
.post-content .post-date { color: var(--ca-indigo-light); }
.post-content .post-type { color: var(--ca-gray-700); }
.post-body h2 {
font-size: 1.5rem;
font-weight: 800;
color: var(--ca-gray-900);
margin: 2.5rem 0 1rem;
letter-spacing: -0.01em;
}
.post-body h3 {
font-size: 1.2rem;
font-weight: 700;
color: var(--ca-gray-900);
margin: 2rem 0 0.75rem;
}
.post-body p {
color: var(--ca-gray-700);
font-size: 1.05rem;
line-height: 1.8;
margin-bottom: 1.25rem;
}
.post-body ul, .post-body ol {
margin: 1rem 0 1.25rem 1.5rem;
color: var(--ca-gray-700);
font-size: 1.05rem;
line-height: 1.8;
}
.post-body li { margin-bottom: 0.5rem; }
.post-body strong { color: var(--ca-gray-900); }
.post-body a { color: var(--ca-indigo-light); text-decoration: underline; text-underline-offset: 2px; }
.post-body a:hover { text-decoration-thickness: 2px; }
.post-body code {
font-family: var(--font-mono);
background: var(--ca-gray-100);
padding: 0.15rem 0.4rem;
border-radius: 4px;
font-size: 0.9em;
}
.post-body pre {
background: var(--ca-gray-900);
color: #e2e8f0;
padding: 1.25rem 1.5rem;
border-radius: 10px;
overflow-x: auto;
font-family: var(--font-mono);
font-size: 0.9rem;
line-height: 1.6;
margin: 1.5rem 0;
}
.post-body pre code {
background: none;
padding: 0;
border-radius: 0;
font-size: inherit;
color: inherit;
}
@media (prefers-color-scheme: dark) {
.post-body pre { background: #0f172a; border: 1px solid var(--ca-gray-200); }
}
.post-body blockquote {
border-left: 4px solid var(--ca-indigo-light);
padding: 1rem 1.5rem;
margin: 1.5rem 0;
background: var(--ca-gray-50);
border-radius: 0 8px 8px 0;
}
.post-body blockquote p { margin-bottom: 0; }
.post-body table {
width: 100%;
border-collapse: collapse;
margin: 1.5rem 0;
font-size: 0.95rem;
}
.post-body th, .post-body td {
border: 1px solid var(--ca-gray-200);
padding: 0.6rem 1rem;
text-align: left;
}
.post-body thead th {
background: var(--ca-gray-50);
font-weight: 600;
color: var(--ca-gray-900);
}
.post-body tbody tr:nth-child(even) { background: var(--ca-gray-50); }
.post-body hr {
border: none;
border-top: 1px solid var(--ca-gray-200);
margin: 2rem 0;
}
/* === Pagination === */
.pagination {
max-width: 52rem;
margin: 0 auto 3rem;
padding-top: 1rem;
}
.pagination-list {
list-style: none;
display: flex;
justify-content: center;
align-items: center;
gap: 0.35rem;
flex-wrap: wrap;
}
.pagination-btn {
display: inline-flex;
align-items: center;
justify-content: center;
min-width: 2.75rem;
height: 2.75rem;
padding: 0.5rem 0.85rem;
border: 2px solid var(--ca-gray-200);
border-radius: 8px;
background: var(--ca-white);
color: var(--ca-gray-800);
font-family: inherit;
font-size: 0.95rem;
font-weight: 600;
text-decoration: none;
cursor: pointer;
transition: background var(--transition), border-color var(--transition), color var(--transition);
}
.pagination-btn:hover {
background: var(--ca-gray-100);
border-color: var(--ca-indigo-light);
color: var(--ca-indigo-light);
}
.pagination-btn[aria-current="page"] {
background: var(--ca-indigo);
border-color: var(--ca-indigo);
color: var(--ca-gray-50);
cursor: default;
}
@media (prefers-color-scheme: dark) {
.pagination-btn[aria-current="page"] {
background: var(--ca-indigo-light);
border-color: var(--ca-indigo-light);
color: #1e1b4b;
}
}
.pagination-btn:disabled {
opacity: 0.55;
cursor: not-allowed;
}
.pagination-btn:disabled:hover {
background: var(--ca-white);
border-color: var(--ca-gray-200);
color: var(--ca-gray-800);
}
.pagination-ellipsis {
display: inline-flex;
align-items: center;
justify-content: center;
min-width: 2rem;
height: 2.75rem;
color: var(--ca-gray-700);
font-weight: 600;
user-select: none;
}
/* === Loading === */
.loading {
text-align: center;
padding: 4rem 0;
color: var(--ca-gray-700);
font-size: 1.1rem;
}
@media (max-width: 48rem) {
.page-header { padding: 3rem 0 2rem; }
.post-content { padding: 2rem 0 3rem; }
}
</style>
</head>
<body>
<a href="#main" class="skip-link">Skip to main content</a>
<header class="site-header">
<div class="container header-inner">
<a href="index.html" class="logo" aria-label="Community Access home">
<span class="logo-mark" aria-hidden="true">CA</span>
<span class="logo-text">Community Access</span>
</a>
<nav class="header-nav" aria-label="Main navigation">
<ul>
<li class="nav-dropdown">
<button class="nav-dropdown-toggle" aria-expanded="false">Accessibility Agents</button>
<ul class="nav-dropdown-menu">
<li><a href="docs.html">Documentation</a></li>
<li><a href="index.html#agents">Agents</a></li>
<li><a href="index.html#install">Install</a></li>
<li><a href="index.html#contribute">Contribute</a></li>
</ul>
</li>
<li><a href="index.html#mission">Mission</a></li>
<li><a href="news.html" aria-current="page">News</a></li>
<li><a href="repos.html">Repositories</a></li>
<li><a href="about.html">About</a></li>
<li><a href="index.html#faq">FAQ</a></li>
<li><a href="https://github.com/Community-Access">GitHub</a></li>
</ul>
</nav>
<button class="theme-toggle" type="button" aria-label="Switch to dark mode">
<span class="icon-sun" aria-hidden="true">☀️</span>
<span class="icon-moon" aria-hidden="true">☾️</span>
</button>
</div>
</header>
<main id="main">
<div id="page-header-region" class="page-header">
<div class="container">
<h1>News</h1>
<p>Press releases, announcements, and updates from the Community Access project.</p>
</div>
</div>
<div class="container">
<div id="news-content">
<p class="loading">Loading posts...</p>
</div>
<div class="sr-only" aria-live="polite" id="news-status"></div>
</div>
</main>
<footer class="site-footer">
<div class="container">
<div class="footer-inner">
<div>
<span style="font-weight:700; font-size:1.1rem;">Community Access</span>
<p style="color:#b0b8c4; font-size:0.9rem; margin-top:0.25rem;">Making software accessible by default.</p>
</div>
<nav aria-label="Footer navigation">
<ul class="footer-links">
<li><a href="https://github.com/Community-Access">GitHub Organization</a></li>
<li><a href="https://github.com/Community-Access/accessibility-agents">Accessibility Agents</a></li>
<li><a href="news.html">News</a></li>
<li><a href="blog.html">Blog</a></li>
<li><a href="repos.html">Repositories</a></li>
<li><a href="docs.html">Documentation</a></li>
<li><a href="quickstart.html">Quick Start</a></li>
<li><a href="about.html">About</a></li>
<li><a href="accessibility.html">Accessibility</a></li>
<li><a href="https://github.com/Community-Access/accessibility-agents/blob/main/CONTRIBUTING.md">Contribute</a></li>
<li><a href="https://github.com/Community-Access/accessibility-agents/blob/main/CODE_OF_CONDUCT.md">Code of Conduct</a></li>
</ul>
</nav>
</div>
<div class="a11y-statement">
<p>This site meets WCAG 2.2 Level AA. <a href="accessibility.html" style="color:var(--ca-emerald-light);">Accessibility statement</a>. <a href="https://github.com/Community-Access/accessibility-agents/issues" style="color:var(--ca-emerald-light);">Report a barrier</a>.</p>
</div>
<p class="footer-copy">A community project. Licensed under MIT.</p>
</div>
</footer>
<script>
(function () {
'use strict';
// Dropdown menu
var dropdown = document.querySelector('.nav-dropdown');
if (dropdown) {
var toggle = dropdown.querySelector('.nav-dropdown-toggle');
var menu = dropdown.querySelector('.nav-dropdown-menu');
function openMenu() { toggle.setAttribute('aria-expanded', 'true'); menu.classList.add('open'); var first = menu.querySelector('a'); if (first) first.focus(); }
function closeMenu(ret) { toggle.setAttribute('aria-expanded', 'false'); menu.classList.remove('open'); if (ret) toggle.focus(); }
toggle.addEventListener('click', function () { toggle.getAttribute('aria-expanded') === 'true' ? closeMenu(true) : openMenu(); });
toggle.addEventListener('keydown', function (e) {
if (e.key === 'ArrowDown') { e.preventDefault(); openMenu(); }
});
menu.addEventListener('keydown', function (e) {
var links = menu.querySelectorAll('a');
var idx = Array.prototype.indexOf.call(links, document.activeElement);
if (e.key === 'ArrowDown') { e.preventDefault(); if (idx < links.length - 1) links[idx + 1].focus(); }
else if (e.key === 'ArrowUp') { e.preventDefault(); if (idx > 0) links[idx - 1].focus(); else toggle.focus(); }
else if (e.key === 'Escape') { e.preventDefault(); closeMenu(true); }
});
document.addEventListener('click', function (e) { if (!dropdown.contains(e.target)) closeMenu(false); });
}
// Simple markdown to HTML converter
function md(text) {
// Remove the H1 title (first line starting with #) - we render it separately
var lines = text.split('\n');
var titleLine = -1;
for (var i = 0; i < lines.length; i++) {
if (lines[i].match(/^# /)) { titleLine = i; break; }
}
if (titleLine >= 0) lines.splice(titleLine, 1);
text = lines.join('\n');
// Parse markdown tables into HTML
function mdTables(src) {
return src.replace(/(?:^|\n)(\|.+\|\n\|[\s:|-]+\|\n(?:\|.+\|\n?)+)/g, function (m, tbl) {
var rows = tbl.trim().split('\n');
if (rows.length < 2) return m;
var headCells = rows[0].split('|').filter(function (c) { return c.trim() !== ''; });
var out = '<table><thead><tr>';
headCells.forEach(function (c) { out += '<th>' + c.trim() + '</th>'; });
out += '</tr></thead><tbody>';
for (var r = 2; r < rows.length; r++) {
var cells = rows[r].split('|').filter(function (c) { return c.trim() !== ''; });
out += '<tr>';
cells.forEach(function (c) { out += '<td>' + c.trim() + '</td>'; });
out += '</tr>';
}
out += '</tbody></table>';
return out;
});
}
// Convert tables first (before inline formatting mangles the pipes)
text = mdTables(text);
var html = text
// Code blocks
.replace(/```(\w*)\n([\s\S]*?)```/g, function (m, lang, code) {
return '<pre><code>' + code.replace(/</g, '<').replace(/>/g, '>').trim() + '</code></pre>';
})
// Horizontal rules
.replace(/^---+$/gm, '<hr>')
// Headers
.replace(/^### (.+)$/gm, '<h3>$1</h3>')
.replace(/^## (.+)$/gm, '<h2>$1</h2>')
// Bold
.replace(/\*\*(.+?)\*\*/g, '<strong>$1</strong>')
// Italic
.replace(/\*(.+?)\*/g, '<em>$1</em>')
// Links
.replace(/\[([^\]]+)\]\(([^)]+)\)/g, '<a href="$2">$1</a>')
// Bare URLs
.replace(/(^|[^"(])((https?:\/\/)[^\s<]+)/gm, '$1<a href="$2">$2</a>')
// Unordered lists
.replace(/^- (.+)$/gm, '<li>$1</li>')
// Inline code
.replace(/`([^`]+)`/g, '<code>$1</code>')
// Paragraphs
.replace(/\n\n+/g, '\n\n');
// Wrap loose li elements in ul
html = html.replace(/((?:<li>.*<\/li>\n?)+)/g, '<ul>$1</ul>');
// Wrap remaining text blocks in p tags
var blocks = html.split('\n\n');
html = blocks.map(function (block) {
block = block.trim();
if (!block) return '';
if (block.match(/^<(h[23]|ul|ol|pre|blockquote|table|hr)/)) return block;
if (block.match(/^<li/)) return '<ul>' + block + '</ul>';
return '<p>' + block.replace(/\n/g, '<br>') + '</p>';
}).join('\n');
return html;
}
// Format date
function formatDate(dateStr) {
var d = new Date(dateStr + 'T12:00:00');
var months = ['January','February','March','April','May','June','July','August','September','October','November','December'];
return months[d.getMonth()] + ' ' + d.getDate() + ', ' + d.getFullYear();
}
// Get slug from URL hash
function getSlug() {
var hash = window.location.hash;
if (hash && hash.indexOf('#post/') === 0) return hash.substring(6);
return null;
}
var container = document.getElementById('news-content');
var headerRegion = document.getElementById('page-header-region');
var POSTS_PER_PAGE = 6;
// Get current page from URL query parameter
function getCurrentPage() {
var params = new URLSearchParams(window.location.search);
var p = parseInt(params.get('page'), 10);
return (p && p > 0) ? p : 1;
}
// Update URL without full reload
function setPageURL(page) {
var url = new URL(window.location);
if (page <= 1) {
url.searchParams.delete('page');
} else {
url.searchParams.set('page', page);
}
// Remove hash when on list view
url.hash = '';
history.pushState(null, '', url);
}
// Build pagination range with ellipsis
function getPageRange(current, total) {
if (total <= 7) {
var arr = [];
for (var i = 1; i <= total; i++) arr.push(i);
return arr;
}
var pages = [1];
var start = Math.max(2, current - 1);
var end = Math.min(total - 1, current + 1);
if (start > 2) pages.push('...');
for (var j = start; j <= end; j++) pages.push(j);
if (end < total - 1) pages.push('...');
pages.push(total);
return pages;
}
var ORG = 'Community-Access';
// Fetch manual posts from posts.json
var postsPromise = fetch('posts/posts.json')
.then(function (r) { return r.json(); })
.then(function (posts) {
return posts.map(function (p) {
return { date: p.date, sortKey: p.date, title: p.title, summary: p.summary, type: p.type || '', repo: '', slug: p.slug, url: '#post/' + p.slug };
});
})
.catch(function () { return []; });
// Fetch releases from all org repos
var releasesPromise = fetch('https://api.github.com/orgs/' + ORG + '/repos?type=sources&per_page=100', {
headers: { 'Accept': 'application/vnd.github+json' }
})
.then(function (r) { return r.json(); })
.then(function (repos) {
if (!Array.isArray(repos)) return [];
var fetches = repos
.filter(function (r) { return !r.fork; })
.map(function (repo) {
return fetch('https://api.github.com/repos/' + repo.full_name + '/releases?per_page=5', {
headers: { 'Accept': 'application/vnd.github+json' }
})
.then(function (r) { return r.json(); })
.then(function (releases) {
if (!Array.isArray(releases)) return [];
return releases.map(function (rel) {
var sortKey = rel.published_at || rel.created_at;
var date = sortKey.slice(0, 10);
var body = rel.body || '';
var summary = body.length > 150 ? body.slice(0, 150) + '...' : body;
summary = summary.replace(/[#*_`\[\]]/g, '').replace(/\n/g, ' ').trim();
return { date: date, sortKey: sortKey, title: rel.name || rel.tag_name, summary: summary || 'New release published.', type: 'Release', repo: repo.name, slug: null, url: rel.html_url };
});
})
.catch(function () { return []; });
});
return Promise.all(fetches).then(function (results) {
return results.reduce(function (acc, arr) { return acc.concat(arr); }, []);
});
})
.catch(function () { return []; });
// Combine posts + releases (deduplicate releases covered by manual posts)
Promise.all([postsPromise, releasesPromise])
.then(function (results) {
var manualPosts = results[0];
var releases = results[1];
var postTitlesLower = manualPosts.map(function (p) { return p.title.toLowerCase(); });
releases = releases.filter(function (rel) {
var t = rel.title.toLowerCase();
return !postTitlesLower.some(function (pt) { return pt.indexOf(t) !== -1; });
});
var posts = manualPosts.concat(releases);
posts.sort(function (a, b) { return b.sortKey.localeCompare(a.sortKey); });
function renderList() {
headerRegion.querySelector('h1').textContent = 'News';
document.title = 'News -- Community Access';
if (posts.length === 0) {
container.innerHTML = '<p class="loading">No posts yet. Check back soon.</p>';
return;
}
var currentPage = getCurrentPage();
var totalPages = Math.ceil(posts.length / POSTS_PER_PAGE);
if (currentPage > totalPages) currentPage = totalPages;
var startIdx = (currentPage - 1) * POSTS_PER_PAGE;
var pagePosts = posts.slice(startIdx, startIdx + POSTS_PER_PAGE);
var html = '<div class="news-list-section"><div class="news-grid">';
pagePosts.forEach(function (post) {
html += '<article class="news-card">';
html += '<div class="news-card-meta">';
html += '<time class="news-card-date" datetime="' + post.date + '">' + formatDate(post.date) + '</time>';
if (post.type) html += '<span class="news-badge news-badge-type">' + post.type + '</span>';
if (post.repo) html += '<span class="news-badge news-badge-repo">' + post.repo + '</span>';
html += '</div>';
html += '<h2 class="news-card-title"><a href="' + post.url + '">' + post.title + '</a></h2>';
html += '<p class="news-card-summary">' + post.summary + '</p>';
html += '</article>';
});
html += '</div></div>';
// Pagination controls
if (totalPages > 1) {
html += '<nav class="pagination" aria-label="News pagination">';
html += '<ul class="pagination-list">';
html += '<li><button class="pagination-btn" data-page="' + (currentPage - 1) + '"' + (currentPage === 1 ? ' disabled' : '') + ' aria-label="Previous page">Previous</button></li>';
var range = getPageRange(currentPage, totalPages);
range.forEach(function (p) {
if (p === '...') {
html += '<li><span class="pagination-ellipsis" aria-hidden="true">…</span></li>';
} else {
html += '<li><button class="pagination-btn" data-page="' + p + '"';
if (p === currentPage) html += ' aria-current="page"';
html += ' aria-label="Page ' + p + '">' + p + '</button></li>';
}
});
html += '<li><button class="pagination-btn" data-page="' + (currentPage + 1) + '"' + (currentPage === totalPages ? ' disabled' : '') + ' aria-label="Next page">Next</button></li>';
html += '</ul>';
html += '</nav>';
}
container.innerHTML = html;
// Bind pagination clicks
var buttons = container.querySelectorAll('.pagination-btn[data-page]');
buttons.forEach(function (btn) {
btn.addEventListener('click', function () {
if (btn.disabled) return;
var page = parseInt(btn.getAttribute('data-page'), 10);
if (page === currentPage) return;
setPageURL(page);
renderList();
window.scrollTo(0, 0);
// Focus the newly active page button in the pagination
var active = container.querySelector('.pagination-btn[aria-current="page"]');
if (active) { active.focus(); }
});
});
var ns = document.getElementById('news-status');
if (ns) ns.textContent = 'Page ' + currentPage + ' of ' + totalPages + ', showing ' + pagePosts.length + ' articles';
}
function renderPost(slug) {
var post = null;
for (var i = 0; i < posts.length; i++) {
if (posts[i].slug && posts[i].slug === slug) { post = posts[i]; break; }
}
if (!post) {
container.innerHTML = '<div class="post-content"><p>Post not found. <a href="news.html">Back to News</a></p></div>';
return;
}
document.title = post.title + ' -- Community Access';
headerRegion.querySelector('h1').textContent = post.type || 'News';
container.innerHTML = '<div class="post-content"><p class="loading">Loading article...</p></div>';
fetch('posts/' + slug + '.md')
.then(function (r) { return r.text(); })
.then(function (text) {
// Extract title from first H1
var titleMatch = text.match(/^# (.+)$/m);
var title = titleMatch ? titleMatch[1] : post.title;
var html = '<article class="post-content">';
html += '<a href="news.html" class="post-back">Back to News</a>';
html += '<h1>' + title + '</h1>';
html += '<p class="post-meta"><time class="post-date" datetime="' + post.date + '">' + formatDate(post.date) + '</time>';
if (post.type) html += ' <span class="post-type">' + post.type + '</span>';
html += '</p>';
html += '<div class="post-body">' + md(text) + '</div>';
html += '</article>';
container.innerHTML = html;
var heading = container.querySelector('h1');
if (heading) { heading.setAttribute('tabindex', '-1'); heading.focus(); }
var ns = document.getElementById('news-status');
if (ns) ns.textContent = 'Loaded: ' + title;
window.scrollTo(0, 0);
})
.catch(function () {
container.innerHTML = '<div class="post-content"><p>Error loading article. <a href="news.html">Back to News</a></p></div>';
});
}
// Route
function route() {
var slug = getSlug();
if (slug) {
renderPost(slug);
} else {
renderList();
}
}
route();
window.addEventListener('hashchange', route);
window.addEventListener('popstate', function () {
if (!getSlug()) renderList();
});
})
.catch(function () {
container.innerHTML = '<p class="loading">Unable to load posts. Please try again later.</p>';
});
})();
</script>
</body>
</html>