From bbef92410464d7ecf95d77c765201bf84b45e5f2 Mon Sep 17 00:00:00 2001 From: Tissevert Date: Wed, 6 Feb 2019 17:49:28 +0100 Subject: [PATCH] Add alias to create with a "navigation" class and help the JS code distinguish between hablo generated links which navigation should be hijacked and regular ones --- src/Dom.hs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/Dom.hs b/src/Dom.hs index a955d42..3af934f 100644 --- a/src/Dom.hs +++ b/src/Dom.hs @@ -40,7 +40,7 @@ instance Page ArticlesList where content al@(ArticlesList {featured}) = do h2_ . toHtml . pack $ pageTitle al - p_ . a_ [href_ . pack $ otherUrl al] . toHtml . pack $ otherLink al + p_ . navigationA [href_ . pack $ otherUrl al] . toHtml . pack $ otherLink al div_ [class_ "articles"] (mapM_ previewArticle featured) makeCard :: String -> String -> HtmlGenerator () @@ -53,15 +53,18 @@ makeCard title description = do where og attribute value = meta_ [makeAttribute "property" $ "og:" <> attribute , content_ $ pack value] +navigationA :: Term arg result => arg -> result +navigationA = "a" `termWith` [class_ "navigation"] + previewArticle :: Article -> HtmlGenerator () previewArticle (Article {urlPath, title, preview}) = article_ (do - a_ [href_ . pack $ "/" urlPath <.> "html"] . h3_ $ toHtml title + navigationA [href_ . pack $ "/" urlPath <.> "html"] . h3_ $ toHtml title pre_ $ toHtml preview ) tag :: String -> HtmlGenerator () -tag tagName = li_ (a_ [href_ $ pack ("/" tagName)] $ toHtml tagName) +tag tagName = li_ (navigationA [href_ $ pack ("/" tagName)] $ toHtml tagName) banner :: HtmlGenerator () banner = do @@ -70,7 +73,7 @@ banner = do defaultBanner :: HtmlGenerator () defaultBanner = do div_ [id_ "header"] ( - a_ [href_ "/"] ( + navigationA [href_ "/"] ( h1_ . toHtml =<< Blog.get name ) )