Skip to content

Commit

Permalink
feature: add pub date and edit date to recipes (#12)
Browse files Browse the repository at this point in the history
Might want to set the edit date automatically in the future. For now it is fine to do it manually.
  • Loading branch information
martinhauke authored Aug 21, 2024
1 parent 774bc78 commit 0e6701d
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/components/RecipeList.astro
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,15 @@ const recipes = await getCollection('recipes')
<ul>
{recipes
.filter(recipe => recipe.data.isPublic && recipe.data.lang === lang)
.sort((a, b) => {
if (a.data.pubDate > b.data.pubDate) {
return -1
}
if (a.data.pubDate < b.data.pubDate) {
return 1
}
return 0
})
.map(recipe => (
<RecipeListItem
href={import.meta.env.BASE_URL + "/" + lang + "/recipe/" + recipe.data.id}
Expand Down
2 changes: 2 additions & 0 deletions src/content/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ const language = z.enum(["de", "en"])
const recipe = z.object({
id: z.string(),
name: z.string(),
pubDate: z.date(),
editDate: z.date(),
description: z.string().optional(),
lang: language,
ingredientGroups: z.array(ingredientGroup),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ name: Schmortofu mit frischem Kirchererbsen-Bohnen-Dipp
description: Schnelles Sommergericht mit vielen Proteinen
lang: de
isPublic: true
pubDate: 2024-08-14
editDate: 2024-08-14
metaInformation:
numberOfServings: 4
difficulty: difficulty.easy
Expand Down
2 changes: 2 additions & 0 deletions src/content/recipes/de/ScrambledTofuMitTomaten.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ name: Rührtofu mit Tomaten
description: Schnelles und leckeres Rezept zum Frühstück.
lang: de
isPublic: true
pubDate: 2024-08-18
editDate: 2024-08-18
metaInformation:
numberOfServings: 4
difficulty: difficulty.easy
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ name: Roasted Tofu with fresh Chickpea-Bean-Dip
description: Fast summer meal with lots of protein
lang: en
isPublic: true
pubDate: 2024-08-14
editDate: 2024-08-14
metaInformation:
numberOfServings: 4
difficulty: difficulty.easy
Expand Down
2 changes: 2 additions & 0 deletions src/content/recipes/en/ScrambledTofuMitTomaten.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ name: Scrambled Tofu with Tomatoes
description: Quick and tasty breakfast idea
lang: en
isPublic: true
pubDate: 2024-08-18
editDate: 2024-08-18
metaInformation:
numberOfServings: 4
difficulty: difficulty.easy
Expand Down

0 comments on commit 0e6701d

Please sign in to comment.