~jack/jackkelly-name

eb82bb0dae35f3a3d12b37cf598096a8582c3956 — Jack Kelly 1 year, 9 months ago 47f1e6e
Add Talks section to site
5 files changed, 50 insertions(+), 4 deletions(-)

M bin/Main.hs
M jackkelly-name.cabal
M src/Blog/Archives.hs
M src/Navigation.hs
A src/Talks.hs
M bin/Main.hs => bin/Main.hs +3 -1
@@ 5,6 5,7 @@ import GHC.IO.Encoding (setLocaleEncoding, utf8)
import Hakyll
import Navigation (navigationContext, navigation)
import Site (baseSiteContext, sectionLabel)
import Talks (talks)

main :: IO ()
main = do


@@ 27,6 28,7 @@ main = do
        >>= relativizeUrls

    blog
    talks

    -- Temp
    match "garagesale.md" $ do


@@ 38,7 40,7 @@ main = do
      route $ constRoute "garagesale/index.html"
      compile $
        blogPostCompiler
          >>= loadAndApplyTemplate "templates/panel.html" context
          >>= loadAndApplyTemplate "templates/_panel.html" context
          >>= loadAndApplyTemplate "templates/default.html" context
          >>= relativizeUrls


M jackkelly-name.cabal => jackkelly-name.cabal +1 -0
@@ 34,6 34,7 @@ library
                    , Blog.Util
                    , Navigation
                    , Site
                    , Talks
  ghc-options:        -Wall
  build-depends:      base >= 4.11.1 && < 4.13
                    , aeson >= 1.3.1.1 && < 1.5

M src/Blog/Archives.hs => src/Blog/Archives.hs +2 -3
@@ 9,10 9,9 @@ import           Data.Aeson (Value(..))
import           Data.Foldable (for_)
import           Data.Functor ((<&>))
import           Data.HashMap.Lazy ((!))
import           Data.List (sortBy)
import           Data.List (sortOn)
import           Data.Map.Monoidal (MonoidalMap)
import qualified Data.Map.Monoidal as MM
import           Data.Ord (comparing)
import qualified Data.Text as T
import           Data.Time (defaultTimeLocale, months, toGregorian)
import           Formatting ((%), (%.), formatToString, int, left)


@@ 33,7 32,7 @@ blogArchives tags = do
  monthArchives postsByDay tags

splitByDay :: [(Identifier, Metadata)] -> PostsByDay
splitByDay = foldMap postToMap . sortBy (comparing postDate)
splitByDay = foldMap postToMap . sortOn postDate
  where
    postDate (_, meta) =
      let String date = meta ! "date"

M src/Navigation.hs => src/Navigation.hs +1 -0
@@ 18,6 18,7 @@ type NavItem = (String, Url)
navigation :: Navigation
navigation = Navigation [] Nothing
  [ ("Blog", Url "/blog")
  , ("Talks", Url "/talks")
  ]

navigationContext :: Navigation -> Context a

A src/Talks.hs => src/Talks.hs +43 -0
@@ 0,0 1,43 @@
module Talks (talks) where

import Hakyll
import Navigation (navigation, navigationContext, select)
import Site (baseSiteContext, sectionLabel)

talks :: Rules ()
talks = do
  match "talks/*.markdown" . compile $
    let
      talkContext = mconcat
        [ dateField "date" "%B %e, %Y"
        , bodyField "body"
        , metadataField
        ]
    in
      pandocCompiler
        >>= loadAndApplyTemplate "templates/talks/_talk.html" talkContext
        >>= loadAndApplyTemplate "templates/_panel.html" talkContext

  match "talks/*.pdf" $ do
    route idRoute
    compile copyFileCompiler

  create [ "talks/index.html" ] $ do
    route idRoute
    compile $ do
      let
        talkFiles :: Compiler [Item String]
        talkFiles = recentFirst =<< loadAll "talks/*.markdown"

        title = sectionLabel [ "Talks" ]
        context = mconcat
          [ constField "title" title
          , listField "talks" (bodyField "talk") talkFiles
          , navigationContext (select "Talks" navigation)
          , baseSiteContext
          ]

      makeItem ""
        >>= loadAndApplyTemplate "templates/talks/index.html" context
        >>= loadAndApplyTemplate "templates/default.html" context
        >>= relativizeUrls