@@ -5,6 +5,7 @@ import RenderSource from "@components/RenderSource.astro";
5
5
import Layout from " @layouts/Layout.astro" ;
6
6
import { getLogin } from " @lib/login-cookie" ;
7
7
import { prisma } from " @lib/prisma" ;
8
+ import slugify from " @lib/slugify" ;
8
9
import type {
9
10
Category ,
10
11
Recipe ,
@@ -51,14 +52,20 @@ if (slug && username) {
51
52
});
52
53
}
53
54
54
- RenderSource == RenderSource ;
55
+ const ingredientNames = recipe ?.ingredients .map (
56
+ (ingredient ) => ingredient .name
57
+ );
55
58
---
56
59
57
60
<script >
58
61
import "@github/relative-time-element";
59
62
</script >
60
63
61
- <Layout title ={ recipe ?.name ?? " No such recipe" } user ={ activeUser } showScreenLock >
64
+ <Layout
65
+ title ={ recipe ?.name ?? " No such recipe" }
66
+ user ={ activeUser }
67
+ showScreenLock
68
+ >
62
69
{
63
70
recipe ? (
64
71
<div class = " recipe" itemscope itemtype = " https://schema.org/Recipe" >
@@ -88,6 +95,7 @@ RenderSource == RenderSource;
88
95
itemprop = " recipeIngredient"
89
96
itemscope
90
97
itemtype = " https://schema.org/HowToSupply"
98
+ id = { slugify (ingredient .name )}
91
99
>
92
100
{ ingredient .amount ? (
93
101
<span
@@ -118,13 +126,13 @@ RenderSource == RenderSource;
118
126
<h3 >Instructions</h3 >
119
127
{ recipe .steps .length === 1 ? (
120
128
<div itemprop = " recipeInstructions" >
121
- <Markdown source = { recipe .steps [0 ]! } />
129
+ <Markdown source = { recipe .steps [0 ]! } { ingredientNames } />
122
130
</div >
123
131
) : (
124
132
<ol >
125
133
{ recipe .steps .map ((step ) => (
126
134
<li itemprop = " recipeInstructions" >
127
- <Markdown source = { step } />
135
+ <Markdown source = { step } { ingredientNames } />
128
136
</li >
129
137
))}
130
138
</ol >
@@ -139,7 +147,7 @@ RenderSource == RenderSource;
139
147
<li itemprop = " recipeCategory" >
140
148
<a
141
149
href = { ` /search?category=${encodeURIComponent (
142
- category .name .replaceAll (" " , " _" ),
150
+ category .name .replaceAll (" " , " _" )
143
151
)} ` }
144
152
>
145
153
{ category .name }
@@ -164,7 +172,7 @@ RenderSource == RenderSource;
164
172
/>
165
173
) : (
166
174
<RecipeNote note = { note } />
167
- ),
175
+ )
168
176
)}
169
177
</ol >
170
178
{ activeUser ? (
0 commit comments