@@ -82,11 +82,12 @@ app.get('/sample/cookbook', async (request: express.Request, response: express.R
82
82
return ;
83
83
} )
84
84
85
- function renderRecipe ( req : express . Request , res : express . Response , stars : number , recipe : Recipe ) {
85
+ function renderRecipe ( req : express . Request , res : express . Response , stars : number , recipe : Recipe , fileLocation : string ) {
86
86
res . render ( 'pages/recipe' , {
87
87
recipeId : `g/${ req . params . username } /${ req . params . repo } ` ,
88
88
data : JSON . stringify ( recipe ) ,
89
- stars
89
+ stars,
90
+ fileLocation,
90
91
} ) ;
91
92
}
92
93
@@ -117,7 +118,7 @@ app.get('/g/:username/:repo', async (request: express.Request, response: express
117
118
const recipeFetch = await fetch ( github . getDefaultRecipeUrl ( username , repo ) , { } )
118
119
const recipeData = await recipeFetch . json ( )
119
120
await searchEng . storeResult ( `${ username } /${ repo } ` , recipeData )
120
- renderRecipe ( request , response , stars , recipeData )
121
+ renderRecipe ( request , response , stars , recipeData , '.recipe.json' )
121
122
} catch ( e ) {
122
123
console . warn ( `Could not find default recipe file` , e )
123
124
// Try to render the cookbook
@@ -153,7 +154,7 @@ app.get('/g/:username/:repo/:recipe', async (request: express.Request, response:
153
154
const recipeData = await recipeFetch . text ( )
154
155
const recipeJson = preprocessRecipeYaml ( fileLocation , recipeData )
155
156
await searchEng . storeResult ( `${ username } /${ repo } /${ recipe } ` , recipeJson )
156
- renderRecipe ( request , response , stars , recipeJson )
157
+ renderRecipe ( request , response , stars , recipeJson , fileLocation )
157
158
} catch ( e ) {
158
159
console . error ( e )
159
160
response . status ( 404 ) . send ( `Cannot find. Error: ${ e } ` )
0 commit comments