coreContent :: Site -> Page -> Text
coreContent site page =
    siteRelativize ("/" </> pageUrl site page)
  . either (panic . show :: P.PandocError -> Text) identity
  . P.runPure
  . P.writeHtml5String writerOptions
  . addDate
  $ _pageContent page
  where
    addDate :: Pandoc -> Pandoc
    addDate (P.Pandoc a blocks) =
      case blocks of
        header@(P.Header _ _ _) : rest ->
          let date = TM.formatTime TM.defaultTimeLocale fmtTime (_metaDate (_pageMeta page))
          in P.Pandoc a (header : P.Para [P.Str date] : rest)
        _ -> panic "coreContent: page doesn't start with header"

    fmtTime :: String
    fmtTime = concat
      [ "%B" -- month name, long form (fst from months locale), January - December
      , " "
      , dropWhile (== ' ') "%e" -- day of month, space-padded to two chars, 1 - 31
      , ", "
      , "%Y" -- year
      ]
coreContent :: Site -> Page -> Text
coreContent site page =
    siteRelativize ("/" </> pageUrl site page)
  . either (panic . show :: P.PandocError -> Text) identity
  . P.runPure
  . P.writeHtml5String writerOptions
  . addDate
  $ _pageContent page
  where
    addDate :: Pandoc -> Pandoc
    addDate (P.Pandoc a blocks) =
      case blocks of
        header@(P.Header _ _ _) : rest ->
          let date = TM.formatTime TM.defaultTimeLocale fmtTime (_metaDate (_pageMeta page))
          in P.Pandoc a (header : P.Para [P.Str date] : rest)
        _ -> panic "coreContent: page doesn't start with header"

    fmtTime :: String
    fmtTime = concat
      [ "%B" -- month name, long form (fst from months locale), January - December
      , " "
      , dropWhile (== ' ') "%e" -- day of month, space-padded to two chars, 1 - 31
      , ", "
      , "%Y" -- year
      ]
coreContent site page =
    siteRelativize ("/" </> pageUrl site page)
  . either (panic . show :: P.PandocError -> Text) identity
  . P.runPure
  . P.writeHtml5String writerOptions
  . addDate
  $ _pageContent page
  where
    addDate :: Pandoc -> Pandoc
    addDate (P.Pandoc a blocks) =
      case blocks of
        header@(P.Header _ _ _) : rest ->
          let date = TM.formatTime TM.defaultTimeLocale fmtTime (_metaDate (_pageMeta page))
          in P.Pandoc a (header : P.Para [P.Str date] : rest)
        _ -> panic "coreContent: page doesn't start with header"

    fmtTime :: String
    fmtTime = concat
      [ "%B" -- month name, long form (fst from months locale), January - December
      , " "
      , dropWhile (== ' ') "%e" -- day of month, space-padded to two chars, 1 - 31
      , ", "
      , "%Y" -- year
      ]