~jack/jackkelly-name

ref: 8de6f1521045b2fbc086cb30d9fc901d7170ab5a jackkelly-name/src/Site.hs -rw-r--r-- 702 bytes
8de6f152Jack Kelly Import site code from unified repo 2 years ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
module Site (Url(..), baseSiteContext, sectionLabel) where

import Control.Lens (_1, view)
import Data.List (intercalate)
import Data.Time.Calendar (toGregorian)
import Data.Time.Clock (getCurrentTime)
import Data.Time.LocalTime (getCurrentTimeZone, localDay, utcToLocalTime)
import Hakyll

newtype Url = Url { unUrl :: String } deriving Show

baseSiteContext :: Context String
baseSiteContext = field "current_year" currentYear <> defaultContext where
  currentYear = const . unsafeCompiler $ show . view _1 . toGregorian . localDay
    <$> (utcToLocalTime <$> getCurrentTimeZone <*> getCurrentTime)

sectionLabel :: [String] -> String
sectionLabel = intercalate " | " . reverse . ("jackkelly.name":)