Put images before recipe

This commit is contained in:
2024-10-05 19:15:20 +02:00
parent 7825f62fa2
commit c1ce2185a5
2 changed files with 29 additions and 4 deletions

View File

@@ -18,7 +18,7 @@ makeImageHTML :: Token (FilePath, FilePath) -> DepGenM' Text
makeImageHTML t = do
(thumbnail, actual) <- untupleDepGenM t
appendTexts
(inject "<p><a href=\"")
(inject "<p class=\"image\"><a href=\"")
(appendTexts
(toText actual)
(appendTexts
@@ -48,10 +48,20 @@ handleRecipeDir inputDir outputDir template indexName name = do
mapDepGenM_
(\files -> convertImage files $ inject $ ResizeToWidth 800)
(zipDepGenM imagePaths thumbnailImagePaths)
htmlBodyBase <- runPandoc $ readTextFile $ joinPaths dir $ inject "ret.md"
md <- readTextFile $ joinPaths dir $ inject "ret.md"
ingredienserHeadline <- inject "## Ingredienser"
mdTemplate <- makeTemplate md ingredienserHeadline
htmlBodyImages <- mapDepGenM makeImageHTML $ zipDepGenM thumbnailImageFilenames imageFilenames
imagesHtml <- concatTexts htmlBodyImages
htmlBody <- appendTexts htmlBodyBase imagesHtml
md' <- applyTemplate mdTemplate (
appendTexts
(inject "<p class=\"imagetext\">Opskrift fortsætter efter billedet.</p>\n")
(appendTexts
imagesHtml
(appendTexts
(inject "\n\n")
ingredienserHeadline)))
htmlBody <- runPandoc md'
html <- applyTemplate template htmlBody
saveFile html $ joinPaths recipeDirOut indexName