fix: use preEscapedText for inline JS script content

H.toHtml was escaping the JS content, causing the script tag to be empty.
H.preEscapedText preserves the text as-is, which is correct for script tags.
This commit is contained in:
2026-05-19 21:55:21 -04:00
parent 6970725a35
commit 8105cee498
+3 -4
View File
@@ -208,7 +208,8 @@ page title content =
-- | Inline JavaScript for client-side search + sort rendering. -- | Inline JavaScript for client-side search + sort rendering.
searchJs :: Text searchJs :: Text
searchJs = T.unlines searchJs =
T.unlines
[ "(function(){" [ "(function(){"
, "'use strict';" , "'use strict';"
, "" , ""
@@ -349,7 +350,7 @@ indexPage _mode recipes =
H.script ! A.id "roux-errors-data" ! A.type_ "application/json" $ H.script ! A.id "roux-errors-data" ! A.type_ "application/json" $
H.toHtml (decodeUtf8 (LB.toStrict (encode (Prelude.map Idx.toSearchEntry (filterBad recipes))))) H.toHtml (decodeUtf8 (LB.toStrict (encode (Prelude.map Idx.toSearchEntry (filterBad recipes)))))
-- Inline JS -- Inline JS
H.script ! A.type_ "text/javascript" $ H.toHtml searchJs H.script ! A.type_ "text/javascript" $ H.preEscapedText searchJs
where where
filterOk = filter (isRight . Idx.riRecipe) filterOk = filter (isRight . Idx.riRecipe)
filterBad = filter (isLeft . Idx.riRecipe) filterBad = filter (isLeft . Idx.riRecipe)
@@ -634,5 +635,3 @@ isLeft _ = False
-- | Check if an 'Either' is 'Right'. -- | Check if an 'Either' is 'Right'.
isRight :: Either a b -> Bool isRight :: Either a b -> Bool
isRight = not . isLeft isRight = not . isLeft