Skip to content

Commit 3c7f504

Browse files
committed
add contentful client
1 parent 4169523 commit 3c7f504

File tree

1 file changed

+19
-7
lines changed

1 file changed

+19
-7
lines changed

marmite/pages/index.js

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,19 @@
1-
export default function Recipes() {
2-
return (
3-
<div className="recipe-list">
4-
Recipe List
5-
</div>
6-
)
7-
}
1+
import { createClient } from "contentful";
2+
3+
export async function getStaticProps() {
4+
const client = createClient({
5+
space: process.env.CONTENTFUL_SPACE_ID,
6+
accessToken: process.env.CONTENTFUL_DELIVERY_API,
7+
});
8+
const res = await client.getEntries({ content_type: "recipe" });
9+
return {
10+
props: {
11+
recipes: res.items,
12+
},
13+
};
14+
}
15+
16+
export default function Recipes({ recipes }) {
17+
console.log(recipes);
18+
return <div className="recipe-list">Recipe List</div>;
19+
}

0 commit comments

Comments
 (0)