renderedHomepage
  :: Site
  -> SiteTemplates
  -> Template
  -> Set Page
  -> String
renderedHomepage site templates homeTemplate pages =
  P.renderTemplate
    (_templateBase templates)
    (object [ "body" .= renderedContent ])
  where
    renderedContent :: Text
    renderedContent =
        either (panic . show) identity
      . P.runPure
      . P.writeHtml5String writerOptions
      . readMarkdown
      . P.renderTemplate homeTemplate
      $ object [ "page" .= pageHm ]

    pageHm :: HashMap Text Value
    pageHm = HM.fromList (pageEntry <$> Set.toList pages)

    -- The 'Text' is Pandoc template variable, prefixed with "id-"
    -- because they must start with a letter.
    pageEntry :: Page -> (Text, Value)
    pageEntry page =
      ( "id-" <> _metaId (_pageMeta page)
      , object
          [ "title" .= _metaTitle (_pageMeta page)
          , "url"   .= ("/" </> pageUrl site page)
          ]
      )
renderedHomepage
  :: Site
  -> SiteTemplates
  -> Template
  -> Set Page
  -> String
renderedHomepage site templates homeTemplate pages =
  P.renderTemplate
    (_templateBase templates)
    (object [ "body" .= renderedContent ])
  where
    renderedContent :: Text
    renderedContent =
        either (panic . show) identity
      . P.runPure
      . P.writeHtml5String writerOptions
      . readMarkdown
      . P.renderTemplate homeTemplate
      $ object [ "page" .= pageHm ]

    pageHm :: HashMap Text Value
    pageHm = HM.fromList (pageEntry <$> Set.toList pages)

    -- The 'Text' is Pandoc template variable, prefixed with "id-"
    -- because they must start with a letter.
    pageEntry :: Page -> (Text, Value)
    pageEntry page =
      ( "id-" <> _metaId (_pageMeta page)
      , object
          [ "title" .= _metaTitle (_pageMeta page)
          , "url"   .= ("/" </> pageUrl site page)
          ]
      )
renderedHomepage site templates homeTemplate pages =
  P.renderTemplate
    (_templateBase templates)
    (object [ "body" .= renderedContent ])
  where
    renderedContent :: Text
    renderedContent =
        either (panic . show) identity
      . P.runPure
      . P.writeHtml5String writerOptions
      . readMarkdown
      . P.renderTemplate homeTemplate
      $ object [ "page" .= pageHm ]

    pageHm :: HashMap Text Value
    pageHm = HM.fromList (pageEntry <$> Set.toList pages)

    -- The 'Text' is Pandoc template variable, prefixed with "id-"
    -- because they must start with a letter.
    pageEntry :: Page -> (Text, Value)
    pageEntry page =
      ( "id-" <> _metaId (_pageMeta page)
      , object
          [ "title" .= _metaTitle (_pageMeta page)
          , "url"   .= ("/" </> pageUrl site page)
          ]
      )