mirror of
https://github.com/baz-scm/awesome-reviewers.git
synced 2025-08-20 18:58:52 +03:00
Add dynamic news section on website
This commit is contained in:
@@ -67,6 +67,9 @@ Baz projects are community-contributed and while we strive to maintain high qual
|
||||
|
||||
## News
|
||||
|
||||
This section is also displayed on [awesomereviewers.com](https://awesomereviewers.com)
|
||||
and updates automatically with the latest merged pull requests.
|
||||
|
||||
*2025-07-27 11:02 UTC*
|
||||
|
||||
- 2025-07-27: Add research article and footer nav (#72)
|
||||
|
||||
@@ -939,5 +939,6 @@
|
||||
<script src="{{ '/assets/prism/prism.js' | relative_url }}"></script>
|
||||
<script src="{{ '/assets/js/prism-init.js' | relative_url }}"></script>
|
||||
<script src="{{ '/assets/js/main.js' | relative_url }}"></script>
|
||||
<script src="{{ '/assets/js/news.js' | relative_url }}"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -1923,3 +1923,48 @@ h2 .stat-value {
|
||||
color: var(--accent);
|
||||
margin-left: 0.25rem;
|
||||
}
|
||||
|
||||
/* News section */
|
||||
.news-box {
|
||||
margin-top: 2rem;
|
||||
padding: 1rem 1.25rem;
|
||||
background: var(--bg-card);
|
||||
border: 1px solid var(--border);
|
||||
border-radius: 8px;
|
||||
box-shadow: var(--shadow);
|
||||
}
|
||||
|
||||
.news-box h2 {
|
||||
margin-top: 0;
|
||||
font-size: 1.25rem;
|
||||
}
|
||||
|
||||
.news-list {
|
||||
list-style: none;
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.news-list li {
|
||||
padding: 0.25rem 0;
|
||||
border-bottom: 1px solid var(--border);
|
||||
}
|
||||
|
||||
.news-list li:last-child {
|
||||
border-bottom: none;
|
||||
}
|
||||
|
||||
.news-list a {
|
||||
color: var(--accent);
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.news-list a:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
.news-timestamp {
|
||||
margin-top: 0.5rem;
|
||||
font-size: 0.875rem;
|
||||
color: var(--text-muted);
|
||||
}
|
||||
|
||||
27
assets/js/news.js
Normal file
27
assets/js/news.js
Normal file
@@ -0,0 +1,27 @@
|
||||
// Fetch and display latest merged PRs for News section
|
||||
document.addEventListener('DOMContentLoaded', function () {
|
||||
const list = document.getElementById('news-list');
|
||||
const stampEl = document.getElementById('news-timestamp');
|
||||
if (!list) return;
|
||||
fetch('https://api.github.com/repos/baz-scm/awesome-reviewers/pulls?state=closed&per_page=10', {
|
||||
headers: { 'Accept': 'application/vnd.github+json' }
|
||||
})
|
||||
.then(res => res.ok ? res.json() : Promise.reject(res.status))
|
||||
.then(prs => {
|
||||
const merged = prs.filter(pr => pr.merged_at).slice(0, 5);
|
||||
list.innerHTML = '';
|
||||
merged.forEach(pr => {
|
||||
const li = document.createElement('li');
|
||||
const date = new Date(pr.merged_at).toISOString().slice(0, 10);
|
||||
li.innerHTML = `<span class="pr-date">${date}</span> <a href="${pr.html_url}" target="_blank" rel="noopener noreferrer">${pr.title}</a>`;
|
||||
list.appendChild(li);
|
||||
});
|
||||
if (stampEl) {
|
||||
const now = new Date();
|
||||
stampEl.textContent = `Updated ${now.toISOString().replace('T', ' ').slice(0, 16)} UTC`;
|
||||
}
|
||||
})
|
||||
.catch(() => {
|
||||
list.innerHTML = '<li>Unable to load news.</li>';
|
||||
});
|
||||
});
|
||||
@@ -85,6 +85,14 @@ layout: default
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
|
||||
<div class="news-box">
|
||||
<h2>News</h2>
|
||||
<ul id="news-list" class="news-list">
|
||||
<li>Loading...</li>
|
||||
</ul>
|
||||
<p id="news-timestamp" class="news-timestamp"></p>
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user