Fix absolute links for static resources

This commit is contained in:
Tissevert 2021-05-07 11:04:46 +02:00
parent f229a17bbb
commit dc9e7bc99d

View file

@ -50,7 +50,7 @@ instance PageType ArticlesList where
h2_ . toHtml =<< description al h2_ . toHtml =<< description al
ul_ $ do ul_ $ do
asks hasRSS >>= rssLink asks hasRSS >>= rssLink
li_ . a_ [href "" $ otherURL al, class_ "other"] =<< otherLink li_ . a_ [href_ . pack $ otherURL al, class_ "other"] =<< otherLink
div_ [class_ "articles"] ( div_ [class_ "articles"] (
mapM_ (mDContent False (pathToRoot al) . preview) =<< getArticles al mapM_ (mDContent False (pathToRoot al) . preview) =<< getArticles al
) )
@ -75,14 +75,14 @@ mDContent raw base markdown@(Markdown {key, body}) =
mDLink :: Bool -> FilePath -> Markdown -> HtmlGenerator () mDLink :: Bool -> FilePath -> Markdown -> HtmlGenerator ()
mDLink raw base (Markdown {Markdown.path, title}) = link $ toHtml title mDLink raw base (Markdown {Markdown.path, title}) = link $ toHtml title
where where
link = a_ [href base $ path <.> (if raw then "md" else "html")] link = a_ [href_ . prefix base $ path <.> (if raw then "md" else "html")]
href :: FilePath -> FilePath -> Attribute prefix :: FilePath -> FilePath -> Text
href base = href_ . pack . (base </>) prefix base = pack . (base </>)
tag :: FilePath -> String -> HtmlGenerator () tag :: FilePath -> String -> HtmlGenerator ()
tag base name = tag base name =
a_ [href base $ name ++ "/", class_ "tag"] $ toHtml name a_ [href_ . prefix base $ name ++ "/", class_ "tag"] $ toHtml name
defaultBanner :: FilePath -> HtmlGenerator () defaultBanner :: FilePath -> HtmlGenerator ()
defaultBanner base = defaultBanner base =
@ -117,8 +117,8 @@ htmlDocument someContent =
head_ (do head_ (do
meta_ [charset_ "utf-8"] meta_ [charset_ "utf-8"]
title_ . toHtml =<< asks name title_ . toHtml =<< asks name
script_ [src_ "/js/remarkable.min.js"] empty script_ [src_ $ prefix base "js/remarkable.min.js"] empty
script_ [src_ "/js/hablo.js"] empty script_ [src_ $ prefix base "js/hablo.js"] empty
optional (faviconLink base) =<< (asks $skin.$favicon) optional (faviconLink base) =<< (asks $skin.$favicon)
optional (Card.make someContent) =<< (asks $urls.$cards) optional (Card.make someContent) =<< (asks $urls.$cards)
optional toHtmlRaw =<< (asks $skin.$head) optional toHtmlRaw =<< (asks $skin.$head)