Add alias to create <a/> with a "navigation" class and help the JS code distinguish between hablo generated links which navigation should be hijacked and regular ones

This commit is contained in:
Tissevert 2019-02-06 17:49:28 +01:00
parent dcf8d3d010
commit bbef924104

View file

@ -40,7 +40,7 @@ instance Page ArticlesList where
content al@(ArticlesList {featured}) = do content al@(ArticlesList {featured}) = do
h2_ . toHtml . pack $ pageTitle al 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) div_ [class_ "articles"] (mapM_ previewArticle featured)
makeCard :: String -> String -> HtmlGenerator () makeCard :: String -> String -> HtmlGenerator ()
@ -53,15 +53,18 @@ makeCard title description = do
where where
og attribute value = meta_ [makeAttribute "property" $ "og:" <> attribute , content_ $ pack value] 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 -> HtmlGenerator ()
previewArticle (Article {urlPath, title, preview}) = previewArticle (Article {urlPath, title, preview}) =
article_ (do article_ (do
a_ [href_ . pack $ "/" </> urlPath <.> "html"] . h3_ $ toHtml title navigationA [href_ . pack $ "/" </> urlPath <.> "html"] . h3_ $ toHtml title
pre_ $ toHtml preview pre_ $ toHtml preview
) )
tag :: String -> HtmlGenerator () tag :: String -> HtmlGenerator ()
tag tagName = li_ (a_ [href_ $ pack ("/" </> tagName)] $ toHtml tagName) tag tagName = li_ (navigationA [href_ $ pack ("/" </> tagName)] $ toHtml tagName)
banner :: HtmlGenerator () banner :: HtmlGenerator ()
banner = do banner = do
@ -70,7 +73,7 @@ banner = do
defaultBanner :: HtmlGenerator () defaultBanner :: HtmlGenerator ()
defaultBanner = do defaultBanner = do
div_ [id_ "header"] ( div_ [id_ "header"] (
a_ [href_ "/"] ( navigationA [href_ "/"] (
h1_ . toHtml =<< Blog.get name h1_ . toHtml =<< Blog.get name
) )
) )