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
1 changed files with 7 additions and 4 deletions

View File

@ -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
)
)