diff --git a/scripts/fetch-discussions.mjs b/scripts/fetch-discussions.mjs
index 37dc20e..7ad3949 100644
--- a/scripts/fetch-discussions.mjs
+++ b/scripts/fetch-discussions.mjs
@@ -27,10 +27,22 @@ mkdirSync(DATA_DIR, { recursive: true });
const API =
"https://api.github.com/repos/CodeGateSoftware/keel/discussions?per_page=50&state=open";
-/** One output feed: category slug, destination file, item cap (#13). */
+/**
+ * One output feed: category slug, destination file, item cap. `exclude`
+ * instead of `category` = everything but those slugs (#73: the community's
+ * own threads — Q&A, compliance classification, ideas — get a window
+ * without flooding the announcements archive).
+ */
const FEEDS = [
- { category: "announcements", file: "discussions.json", maxItems: 10 },
+ { category: "announcements", file: "discussions.json", maxItems: 30 },
{ category: "show-and-tell", file: "show-and-tell.json", maxItems: 5 },
+ {
+ category: null,
+ exclude: ["announcements", "show-and-tell"],
+ file: "community.json",
+ maxItems: 5,
+ label: "discussions",
+ },
];
const headers = {
@@ -61,7 +73,12 @@ const categoryUrl = (slug) =>
/** Write one feed's file from the fetched discussions. */
function writeFeed(feed, discussions) {
const items = discussions
- .filter((discussion) => discussion.category?.slug === feed.category)
+ .filter((discussion) =>
+ feed.category
+ ? discussion.category?.slug === feed.category
+ : !feed.exclude.includes(discussion.category?.slug ?? ""),
+ )
+ .sort((a, b) => b.created_at.localeCompare(a.created_at)) // newest first (#73)
.slice(0, feed.maxItems)
.map((discussion) => ({
number: discussion.number,
@@ -76,8 +93,8 @@ function writeFeed(feed, discussions) {
join(DATA_DIR, feed.file),
JSON.stringify(
{
- category: feed.category,
- categoryUrl: categoryUrl(feed.category),
+ category: feed.category ?? feed.label,
+ categoryUrl: feed.category ? categoryUrl(feed.category) : "https://github.com/CodeGateSoftware/keel/discussions",
fetchedAt: new Date().toISOString(),
items,
},
@@ -85,7 +102,7 @@ function writeFeed(feed, discussions) {
2,
) + "\n",
);
- console.log(` discussions: ${items.length} ${feed.category}(s) -> data/${feed.file}`);
+ console.log(` discussions: ${items.length} ${feed.category ?? feed.label}(s) -> data/${feed.file}`);
}
/** Degrade one feed's file: keep last-known data, else an empty stub. */
@@ -99,8 +116,8 @@ function degradeFeed(feed, reason) {
out,
JSON.stringify(
{
- category: feed.category,
- categoryUrl: categoryUrl(feed.category),
+ category: feed.category ?? feed.label,
+ categoryUrl: feed.category ? categoryUrl(feed.category) : "https://github.com/CodeGateSoftware/keel/discussions",
fetchedAt: null,
items: [],
},
diff --git a/src/components/pages/NewsPage.astro b/src/components/pages/NewsPage.astro
index 3f20aa2..f5067b1 100644
--- a/src/components/pages/NewsPage.astro
+++ b/src/components/pages/NewsPage.astro
@@ -7,9 +7,11 @@ import { t } from "../../i18n/ui";
interface Props {
locale: Locale;
+ /** 1-based page number; page 1 renders at /news/, archives at /news/2/… (#73). */
+ page?: number;
}
-const { locale } = Astro.props;
+const { locale, page = 1 } = Astro.props;
const c = news[locale];
const chrome = t(locale);
@@ -48,15 +50,35 @@ const showAndTell: DiscussionsFile =
fetchedAt: null,
items: [],
};
+
+/** Community window (#73) — newest threads from every other category. */
+const community: DiscussionsFile =
+ readDataFile {c.subscribeBody}
- {feed.items.map((item) => (
+ {pageItems.map((item) => (
{c.subscribeTitle}
{c.communityBody}
+ {community.items.length === 0 ? ( + + ) : ( ++ {item.title} +
+ {item.excerpt &&{item.excerpt}
} +