-- | Define your site HTML here
renderPage :: Route a -> a -> Html ()
renderPage route val = html_ [lang_ "en"] $ do
  head_ $ do
    meta_ [httpEquiv_ "Content-Type", content_ "text/html; charset=utf-8"]
    title_ routeTitle
    mapM_ stylesheet [ "/assets/css/spectre.min.css"
                     , "//fonts.googleapis.com/css?family=Montserrat|Raleway"
                     , "//cdn.jsdelivr.net/gh/highlightjs/cdn-release@10.2.0/build/styles/default.min.css"
                     ]
    link_ [ rel_ "icon", href_ "/images/favicon.svg", sizes_ "any", type_ "image/svg+xml" ]
    -- <link rel="icon" href="images/favicon.svg" sizes="any" type="image/svg+xml">
    style_ [type_ "text/css"] $ C.render CSS.pageStyle
    style_ [type_ "text/css"] ("@page{margin: 3cm;}" :: Html ())
  body_ $ do
    div_ [id_ "headerWrapper"] $ do
      header_ [class_ "navbar"] $ do
        section_ [class_ "navbar-section"] $ do
          a_ [class_ "navbar-brand", href_ $ Rib.routeUrl Route_Index] $ do
            "Jonathan Reeve: "
            span_ [] "Computational Literary Analysis"
        section_ [class_ "navbar-section"] $ do
          ul_ [class_ "nav"] $ do
            navItem Route_Index "posts"
            navItem Route_CV "cv"
            navItem Route_Tags "tags"
            navItem Route_Feed "feed"
    div_ [class_ "container"] $ do
      content
    footer_ [ ] $ do
      div_ [ class_ "container" ] $ do
        div_ [ class_ "columns" ] $ do
          div_ [ class_ "column col-8" ] $ CV.md2Html coda
          div_ [ class_ "column col-4" ] $ do
            div_ [ class_ "icons" ] $ do
              a_ [href_ "http://github.com/JonathanReeve"] gitHubIcon
              a_ [href_ "http://twitter.com/j0_0n"] twitterIcon
              a_ [href_ "mailto:jonathan@jonreeve.com"] emailIcon
        script_ [ makeAttribute "data-goatcounter" "https://jonreeve.goatcounter.com/count"
                , async_ T.empty, src_ "//gc.zgo.at/count.js" ] T.empty
        script_ [ src_ "/assets/js/jquery-3.5.1.min.js" ] T.empty
        script_ [ src_ "/assets/js/main.js" ] T.empty
        script_ [src_ "//cdn.jsdelivr.net/gh/highlightjs/cdn-release@10.2.0/build/highlight.min.js"] T.empty
        script_ [] ("hljs.initHighlightingOnLoad();" :: Html ())
  where
    navItem :: Route a -> Html () -> Html ()
    navItem navRoute label = li_ [class_ "nav-item"] $ a_ [href_ $ Rib.routeUrl navRoute ] label

    routeTitle :: Html ()
    routeTitle = case route of
      Route_Index -> "Posts"
      Route_Tags -> "Tags"
      Route_CV -> "CV"
      Route_Article _ -> toHtml $ title $ getMeta val
      Route_Feed -> "Feed"
    content :: Html ()
    content = case route of
      Route_Index -> do
        section_ [id_ "greeting"] $ do
          CV.md2Html SiteData.greeting
          div_ [class_ "icons"] $ do
            img_ [src_ "assets/images/noun_Book_1593490.svg"]
            span_ [] "+"
            img_ [src_ "assets/images/noun_retro computer_1905469.svg"]
            span_ [] "="
            img_ [src_ "assets/images/noun_education_1909997.svg"]
        main_ [class_ "container" ] $ forM_ val $ \(r, src) -> do
          section_ [id_ "postList"] $ do
            li_ [class_ "post" ] $ do
              let meta = getMeta src
              div_ [vocab_ "https://schema.org", typeof_ "blogPosting"] $ do
                h2_ [class_ "postTitle", property_ "headline"] $ a_ [href_ (Rib.routeUrl r)] $ toHtml $ title meta
                p_ [class_ "meta"] $ do
                  span_ [class_ "date", property_ "datePublished", content_ (date meta)] $ toHtml $ T.concat ["(", date meta, ")"]
                  span_ [class_ "tags", property_ "keywords", content_ (T.intercalate "," (tags meta))] $ do
                    " in"
                    mapM_ (a_ [class_ "chip", rel_ "tag", href_ ""] . toHtml) (tags meta)
      Route_Tags -> do
        h1_ routeTitle
        div_ $ forM_ (sortOn (T.toLower . fst) $ Map.toList val) $ \(tag, rs) -> do
          a_ [id_ tag] mempty
          h2_ $ toHtml tag
          ul_ $ forM_ rs $ \(r, src) -> do
            li_ [class_ "pages"] $ do
              let meta = getMeta src
              b_ $ a_ [href_ (Rib.routeUrl r)] $ toHtml $ title meta
      Route_CV -> do
        main_ [class_ "container" ] $ do
          h1_ "Curriculum Vitae"
          h2_ "Jonathan Reeve"
          CV.cv
      Route_Article srcPath -> do
        h1_ routeTitle
        let (y, m, d, _) = parseJekyllFilename srcPath
        p_ [fmt|Posted {y}-{m}-{d}|]
        article_ $
          Pandoc.render val
        script_ [src_ "https://hypothes.is/embed.js" ] T.empty
      Route_Feed -> h1_ "RSS feed in development. Coming soon."

-- | Metadata in our markdown sources
renderPage :: Route a -> a -> Html ()
renderPage route val = html_ [lang_ "en"] $ do
  head_ $ do
    meta_ [httpEquiv_ "Content-Type", content_ "text/html; charset=utf-8"]
    title_ routeTitle
    mapM_ stylesheet [ "/assets/css/spectre.min.css"
                     , "//fonts.googleapis.com/css?family=Montserrat|Raleway"
                     , "//cdn.jsdelivr.net/gh/highlightjs/cdn-release@10.2.0/build/styles/default.min.css"
                     ]
    link_ [ rel_ "icon", href_ "/images/favicon.svg", sizes_ "any", type_ "image/svg+xml" ]
    -- <link rel="icon" href="images/favicon.svg" sizes="any" type="image/svg+xml">
    style_ [type_ "text/css"] $ C.render CSS.pageStyle
    style_ [type_ "text/css"] ("@page{margin: 3cm;}" :: Html ())
  body_ $ do
    div_ [id_ "headerWrapper"] $ do
      header_ [class_ "navbar"] $ do
        section_ [class_ "navbar-section"] $ do
          a_ [class_ "navbar-brand", href_ $ Rib.routeUrl Route_Index] $ do
            "Jonathan Reeve: "
            span_ [] "Computational Literary Analysis"
        section_ [class_ "navbar-section"] $ do
          ul_ [class_ "nav"] $ do
            navItem Route_Index "posts"
            navItem Route_CV "cv"
            navItem Route_Tags "tags"
            navItem Route_Feed "feed"
    div_ [class_ "container"] $ do
      content
    footer_ [ ] $ do
      div_ [ class_ "container" ] $ do
        div_ [ class_ "columns" ] $ do
          div_ [ class_ "column col-8" ] $ CV.md2Html coda
          div_ [ class_ "column col-4" ] $ do
            div_ [ class_ "icons" ] $ do
              a_ [href_ "http://github.com/JonathanReeve"] gitHubIcon
              a_ [href_ "http://twitter.com/j0_0n"] twitterIcon
              a_ [href_ "mailto:jonathan@jonreeve.com"] emailIcon
        script_ [ makeAttribute "data-goatcounter" "https://jonreeve.goatcounter.com/count"
                , async_ T.empty, src_ "//gc.zgo.at/count.js" ] T.empty
        script_ [ src_ "/assets/js/jquery-3.5.1.min.js" ] T.empty
        script_ [ src_ "/assets/js/main.js" ] T.empty
        script_ [src_ "//cdn.jsdelivr.net/gh/highlightjs/cdn-release@10.2.0/build/highlight.min.js"] T.empty
        script_ [] ("hljs.initHighlightingOnLoad();" :: Html ())
  where
    navItem :: Route a -> Html () -> Html ()
    navItem navRoute label = li_ [class_ "nav-item"] $ a_ [href_ $ Rib.routeUrl navRoute ] label

    routeTitle :: Html ()
    routeTitle = case route of
      Route_Index -> "Posts"
      Route_Tags -> "Tags"
      Route_CV -> "CV"
      Route_Article _ -> toHtml $ title $ getMeta val
      Route_Feed -> "Feed"
    content :: Html ()
    content = case route of
      Route_Index -> do
        section_ [id_ "greeting"] $ do
          CV.md2Html SiteData.greeting
          div_ [class_ "icons"] $ do
            img_ [src_ "assets/images/noun_Book_1593490.svg"]
            span_ [] "+"
            img_ [src_ "assets/images/noun_retro computer_1905469.svg"]
            span_ [] "="
            img_ [src_ "assets/images/noun_education_1909997.svg"]
        main_ [class_ "container" ] $ forM_ val $ \(r, src) -> do
          section_ [id_ "postList"] $ do
            li_ [class_ "post" ] $ do
              let meta = getMeta src
              div_ [vocab_ "https://schema.org", typeof_ "blogPosting"] $ do
                h2_ [class_ "postTitle", property_ "headline"] $ a_ [href_ (Rib.routeUrl r)] $ toHtml $ title meta
                p_ [class_ "meta"] $ do
                  span_ [class_ "date", property_ "datePublished", content_ (date meta)] $ toHtml $ T.concat ["(", date meta, ")"]
                  span_ [class_ "tags", property_ "keywords", content_ (T.intercalate "," (tags meta))] $ do
                    " in"
                    mapM_ (a_ [class_ "chip", rel_ "tag", href_ ""] . toHtml) (tags meta)
      Route_Tags -> do
        h1_ routeTitle
        div_ $ forM_ (sortOn (T.toLower . fst) $ Map.toList val) $ \(tag, rs) -> do
          a_ [id_ tag] mempty
          h2_ $ toHtml tag
          ul_ $ forM_ rs $ \(r, src) -> do
            li_ [class_ "pages"] $ do
              let meta = getMeta src
              b_ $ a_ [href_ (Rib.routeUrl r)] $ toHtml $ title meta
      Route_CV -> do
        main_ [class_ "container" ] $ do
          h1_ "Curriculum Vitae"
          h2_ "Jonathan Reeve"
          CV.cv
      Route_Article srcPath -> do
        h1_ routeTitle
        let (y, m, d, _) = parseJekyllFilename srcPath
        p_ [fmt|Posted {y}-{m}-{d}|]
        article_ $
          Pandoc.render val
        script_ [src_ "https://hypothes.is/embed.js" ] T.empty
      Route_Feed -> h1_ "RSS feed in development. Coming soon."

-- | Metadata in our markdown sources
renderPage route val = html_ [lang_ "en"] $ do
  head_ $ do
    meta_ [httpEquiv_ "Content-Type", content_ "text/html; charset=utf-8"]
    title_ routeTitle
    mapM_ stylesheet [ "/assets/css/spectre.min.css"
                     , "//fonts.googleapis.com/css?family=Montserrat|Raleway"
                     , "//cdn.jsdelivr.net/gh/highlightjs/cdn-release@10.2.0/build/styles/default.min.css"
                     ]
    link_ [ rel_ "icon", href_ "/images/favicon.svg", sizes_ "any", type_ "image/svg+xml" ]
    -- <link rel="icon" href="images/favicon.svg" sizes="any" type="image/svg+xml">
    style_ [type_ "text/css"] $ C.render CSS.pageStyle
    style_ [type_ "text/css"] ("@page{margin: 3cm;}" :: Html ())
  body_ $ do
    div_ [id_ "headerWrapper"] $ do
      header_ [class_ "navbar"] $ do
        section_ [class_ "navbar-section"] $ do
          a_ [class_ "navbar-brand", href_ $ Rib.routeUrl Route_Index] $ do
            "Jonathan Reeve: "
            span_ [] "Computational Literary Analysis"
        section_ [class_ "navbar-section"] $ do
          ul_ [class_ "nav"] $ do
            navItem Route_Index "posts"
            navItem Route_CV "cv"
            navItem Route_Tags "tags"
            navItem Route_Feed "feed"
    div_ [class_ "container"] $ do
      content
    footer_ [ ] $ do
      div_ [ class_ "container" ] $ do
        div_ [ class_ "columns" ] $ do
          div_ [ class_ "column col-8" ] $ CV.md2Html coda
          div_ [ class_ "column col-4" ] $ do
            div_ [ class_ "icons" ] $ do
              a_ [href_ "http://github.com/JonathanReeve"] gitHubIcon
              a_ [href_ "http://twitter.com/j0_0n"] twitterIcon
              a_ [href_ "mailto:jonathan@jonreeve.com"] emailIcon
        script_ [ makeAttribute "data-goatcounter" "https://jonreeve.goatcounter.com/count"
                , async_ T.empty, src_ "//gc.zgo.at/count.js" ] T.empty
        script_ [ src_ "/assets/js/jquery-3.5.1.min.js" ] T.empty
        script_ [ src_ "/assets/js/main.js" ] T.empty
        script_ [src_ "//cdn.jsdelivr.net/gh/highlightjs/cdn-release@10.2.0/build/highlight.min.js"] T.empty
        script_ [] ("hljs.initHighlightingOnLoad();" :: Html ())
  where
    navItem :: Route a -> Html () -> Html ()
    navItem navRoute label = li_ [class_ "nav-item"] $ a_ [href_ $ Rib.routeUrl navRoute ] label

    routeTitle :: Html ()
    routeTitle = case route of
      Route_Index -> "Posts"
      Route_Tags -> "Tags"
      Route_CV -> "CV"
      Route_Article _ -> toHtml $ title $ getMeta val
      Route_Feed -> "Feed"
    content :: Html ()
    content = case route of
      Route_Index -> do
        section_ [id_ "greeting"] $ do
          CV.md2Html SiteData.greeting
          div_ [class_ "icons"] $ do
            img_ [src_ "assets/images/noun_Book_1593490.svg"]
            span_ [] "+"
            img_ [src_ "assets/images/noun_retro computer_1905469.svg"]
            span_ [] "="
            img_ [src_ "assets/images/noun_education_1909997.svg"]
        main_ [class_ "container" ] $ forM_ val $ \(r, src) -> do
          section_ [id_ "postList"] $ do
            li_ [class_ "post" ] $ do
              let meta = getMeta src
              div_ [vocab_ "https://schema.org", typeof_ "blogPosting"] $ do
                h2_ [class_ "postTitle", property_ "headline"] $ a_ [href_ (Rib.routeUrl r)] $ toHtml $ title meta
                p_ [class_ "meta"] $ do
                  span_ [class_ "date", property_ "datePublished", content_ (date meta)] $ toHtml $ T.concat ["(", date meta, ")"]
                  span_ [class_ "tags", property_ "keywords", content_ (T.intercalate "," (tags meta))] $ do
                    " in"
                    mapM_ (a_ [class_ "chip", rel_ "tag", href_ ""] . toHtml) (tags meta)
      Route_Tags -> do
        h1_ routeTitle
        div_ $ forM_ (sortOn (T.toLower . fst) $ Map.toList val) $ \(tag, rs) -> do
          a_ [id_ tag] mempty
          h2_ $ toHtml tag
          ul_ $ forM_ rs $ \(r, src) -> do
            li_ [class_ "pages"] $ do
              let meta = getMeta src
              b_ $ a_ [href_ (Rib.routeUrl r)] $ toHtml $ title meta
      Route_CV -> do
        main_ [class_ "container" ] $ do
          h1_ "Curriculum Vitae"
          h2_ "Jonathan Reeve"
          CV.cv
      Route_Article srcPath -> do
        h1_ routeTitle
        let (y, m, d, _) = parseJekyllFilename srcPath
        p_ [fmt|Posted {y}-{m}-{d}|]
        article_ $
          Pandoc.render val
        script_ [src_ "https://hypothes.is/embed.js" ] T.empty
      Route_Feed -> h1_ "RSS feed in development. Coming soon."

-- | Metadata in our markdown sources