feat: dynamic magazine category filter from published articles

Add articleCategories GraphQL query returning distinct categories from
published articles; magazine page fetches them at load time and renders
only categories that actually have content.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-12 17:13:08 +01:00
parent 505d59b813
commit bfd058ae58
4 changed files with 42 additions and 10 deletions

View File

@@ -298,6 +298,23 @@ export async function getArticles(
});
}
const ARTICLE_CATEGORIES_QUERY = gql`
query GetArticleCategories {
articleCategories
}
`;
export async function getArticleCategories(
fetchFn?: typeof globalThis.fetch,
): Promise<string[]> {
return loggedApiCall("getArticleCategories", async () => {
const data = await getGraphQLClient(fetchFn).request<{ articleCategories: string[] }>(
ARTICLE_CATEGORIES_QUERY,
);
return data.articleCategories;
});
}
const ARTICLE_BY_SLUG_QUERY = gql`
query GetArticleBySlug($slug: String!) {
article(slug: $slug) {