Skip to content

Commit

Permalink
Fix more blog stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
gavinhenderson committed Nov 22, 2023
1 parent 3aba58d commit 874d0bd
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 18 deletions.
30 changes: 14 additions & 16 deletions lib/posts/get-categories.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,22 +31,20 @@ export const getAllCategories = async () => {
const { categories } = await request(ENDPOINT, GetAllCategories);
const nodes = categories.nodes || [];

return nodes
.map((category) => {
const featuredImage = getFeaturedImage(category);

if (!featuredImage)
throw new Error(
`You need a featured image for a blog category: ${category.name}`
);

return {
slug: category.slug,
title: category.name,
featuredImage,
};
})
.filter((x) => x.slug !== "at-scholar");
return nodes.map((category) => {
const featuredImage = getFeaturedImage(category);

if (!featuredImage)
throw new Error(
`You need a featured image for a blog category: ${category.name}`
);

return {
slug: category.slug,
title: category.name,
featuredImage,
};
});
};

const getFeaturedImage = (category) => {
Expand Down
5 changes: 3 additions & 2 deletions pages/blog/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,9 @@ export const getStaticProps = async () => {

if (!latestsPosts) throw new Error("Couldn't get latests posts");

const blogCategories = await getAllCategories();

const blogCategories = (await getAllCategories()).filter(
(x) => x.slug !== "at-scholar"
);
if (!blogCategories) throw new Error("Couldn't get the blog categories");

return {
Expand Down

0 comments on commit 874d0bd

Please sign in to comment.