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:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user