Skip to content

Commit f54ce45

Browse files
committed
Featured: Adding recipes collection.
This has been something I've been meaning to do for a long time, but I finally got around to stubbing in the basics. I keep a local text file on my main desktop, that I have filled with some of the basic recipes and meals that I regular cook and enjoy. I really want to get those into both a more *durable* place, but also continue some long-running experiments around recipe formatting. This first recipe that I'm adding is just a basic bread recipe that I use almost weekly. But just like this new collection, it's really just a jumping off point for more experimentation. I look forward to collating more these and exploring new/better formatting options.
1 parent a9693d2 commit f54ce45

File tree

5 files changed

+127
-13
lines changed

5 files changed

+127
-13
lines changed

src/content/config.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,11 +110,20 @@ const sci0PicsCollection = defineCollection({
110110
}),
111111
});
112112

113+
const recipesCollection = defineCollection({
114+
type: 'content',
115+
schema: z.object({
116+
name: z.string(),
117+
servings: z.string().optional(),
118+
}),
119+
});
120+
113121
export const collections = {
114122
blog: blogCollection,
115123
projects: projectsCollection,
116124
sci0games: sci0GamesCollection,
117125
sci0pics: sci0PicsCollection,
118126
thoughts: thoughtsCollection,
119127
TILs: tilsCollection,
128+
recipes: recipesCollection,
120129
};

src/content/recipes/basic-bread.mdx

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
---
2+
name: "Basic Bread"
3+
servings: "two loaves"
4+
---
5+
6+
* <data>1,000 g</data> bread flour
7+
* <data>600 ml</data> water
8+
* <data>20 g</data> salt
9+
* <data>5 g</data> yeast
10+
11+
1. <small>Dissolve</small> water and yeast in small. Let bloom for 3 to 5 minutes
12+
1. <small>Combine</small> flour and salt in large mixing bowl. Pour the yeast mixture into the flour mixture and mix by hand until combined
13+
1. <small>Rest</small> dough for 30 minutes
14+
1. <small>Stretch-and-fold</small>. Repeat at least three more stretch-and-folds, resting 15 to 30 minutes between each
15+
1. <small>Proof</small> dough until doubled in size
16+
1. <small>Divide</small> roughly in half and shape into loaf
17+
1. <small>Bake</small> at 425&deg; F oven for 40 minutes
18+
1. <small>Rest</small> for at least 30 minutes before slicing
19+
20+
<hr className="simple" />
21+
22+
This is a simple crusty bread recipe, based on a fundamental ratio of 5&ratio;3, flour to water, (or a 60% hydration). This is really just a
23+
_starting point_ for most other types of bread: _e.g._ pizza dough, bagels, baguettes, and buns.

src/pages/recipes/[...slug].astro

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
---
2+
import { getCollection } from 'astro:content';
3+
import Page from '../../layouts/page.astro';
4+
export async function getStaticPaths() {
5+
const recipeEntries = await getCollection('recipes');
6+
return recipeEntries.map((entry) => ({
7+
params: { slug: entry.slug },
8+
props: { recipe: entry },
9+
}));
10+
}
11+
12+
const { recipe } = Astro.props;
13+
const { name, servings } = recipe.data;
14+
const { Content } = await recipe.render();
15+
---
16+
17+
<Page>
18+
<article class="markdown recipe">
19+
<h1>{name}</h1>
20+
{servings && <p class="servings">makes {servings}</p>}
21+
<Content />
22+
</article>
23+
</Page>
24+
25+
<style>
26+
.recipe {
27+
font-feature-settings: 'onum';
28+
}
29+
30+
.servings {
31+
text-align: center;
32+
font-style: italic;
33+
quotes: '(' ')';
34+
margin-top: -1rlh;
35+
font-size: var(--f-small);
36+
&:not(:empty) {
37+
&::before { content: open-quote; }
38+
&::after { content: close-quote; }
39+
}
40+
}
41+
42+
.recipe::before, .recipe::after {
43+
display: block;
44+
content: '\2042';
45+
font-size: var(--f-x-large);
46+
margin-block: 2rlh;
47+
text-align: center;
48+
}
49+
50+
.recipe h1 {
51+
text-align: center;
52+
margin-block-start: 0;
53+
}
54+
55+
.recipe :global(ul) {
56+
margin-inline: auto;
57+
width: max-content;
58+
columns: 2;
59+
column-rule: 3px double currentColor;
60+
column-gap: 4ch;
61+
margin-block: 1rlh;
62+
}
63+
64+
.recipe :global(ol) {
65+
margin-block: 1rlh;
66+
}
67+
68+
.recipe :global(ol li) {
69+
display: inline;
70+
&:not(:last-child)::after { content: ' \29F8 '; }
71+
&:last-child::after { content: '.'; }
72+
}
73+
</style>

src/pages/recipes/index.astro

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
---
2+
import { getCollection } from 'astro:content';
3+
import Page from '../../layouts/page.astro';
4+
5+
const allRecipes = await getCollection('recipes');
6+
---
7+
8+
<Page title="Recipes" description="Some thoughts on food and recipes.">
9+
<h1>Recipes</h1>
10+
<ul class="recipes">
11+
{allRecipes.map(recipe => <li><a href={`/recipes/${recipe.slug}`}>{recipe.data.name}</a></li>)}
12+
</ul>
13+
<em>Showing {allRecipes.length} recipes.</em>
14+
15+
</Page>
16+
17+
<style>
18+
.recipes {
19+
margin-bottom: 1lh;
20+
}
21+
</style>

src/styles/core.css

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -158,26 +158,14 @@ mark {
158158
hr {
159159
height: 0;
160160
border: 0;
161-
margin: calc(1rlh * 2.5) 0;
161+
margin: 2rlh 0;
162162
position: relative;
163163
clear: both;
164164
overflow: visible;
165165
text-align: center;
166166
color: var(--pal-light);
167167
border-bottom: 1px dotted currentColor;
168168
page-break-after: avoid;
169-
170-
&::after {
171-
content: "\2042";
172-
position: relative;
173-
font-size: 1.3348rem;
174-
color: currentColor;
175-
top: calc(1rlh * -1);
176-
line-height: calc(1rlh * 2);
177-
background-color: white;
178-
padding: 1rem;
179-
border-radius: 50%;
180-
}
181169
}
182170

183171
q {

0 commit comments

Comments
 (0)