loadWebsiteContent :: FilePath -> IO WebsiteContent
loadWebsiteContent dir = do
    wcHomepage <- readHtml "homepage.html"
    wcAuthors <- readHtml "authors.html"
    wcOlderReleases <- readHtml "older-releases.html" `catchIO`
                    \_ -> readMarkdown "older-releases.md"
    wcGhcLinks <- readGhcLinks $ dir </> "stackage-cli"
    wcStackReleases <- decodeFileEither (dir </> "stack" </> "releases.yaml")
        >>= either throwIO return
    wcPosts <- loadPosts (dir </> "posts") `catchAny` \e -> do
      putStrLn $ "Error loading posts: " ++ tshow e
      return mempty
    wcSpamPackages <- decodeFileEither (dir </> "spam-packages.yaml")
                  >>= either throwIO (return . setFromList)
    return WebsiteContent {..}
  where
    readHtml fp = fmap preEscapedToMarkup $ readFileUtf8 $ dir </> fp
    readMarkdown fp = fmap (preEscapedToHtml . commonmarkToHtml
                        [optSmart]
                        [extTable, extAutolink])
               $ readFileUtf8 $ dir </> fp
loadWebsiteContent :: FilePath -> IO WebsiteContent
loadWebsiteContent dir = do
    wcHomepage <- readHtml "homepage.html"
    wcAuthors <- readHtml "authors.html"
    wcOlderReleases <- readHtml "older-releases.html" `catchIO`
                    \_ -> readMarkdown "older-releases.md"
    wcGhcLinks <- readGhcLinks $ dir </> "stackage-cli"
    wcStackReleases <- decodeFileEither (dir </> "stack" </> "releases.yaml")
        >>= either throwIO return
    wcPosts <- loadPosts (dir </> "posts") `catchAny` \e -> do
      putStrLn $ "Error loading posts: " ++ tshow e
      return mempty
    wcSpamPackages <- decodeFileEither (dir </> "spam-packages.yaml")
                  >>= either throwIO (return . setFromList)
    return WebsiteContent {..}
  where
    readHtml fp = fmap preEscapedToMarkup $ readFileUtf8 $ dir </> fp
    readMarkdown fp = fmap (preEscapedToHtml . commonmarkToHtml
                        [optSmart]
                        [extTable, extAutolink])
               $ readFileUtf8 $ dir </> fp
loadWebsiteContent dir = do
    wcHomepage <- readHtml "homepage.html"
    wcAuthors <- readHtml "authors.html"
    wcOlderReleases <- readHtml "older-releases.html" `catchIO`
                    \_ -> readMarkdown "older-releases.md"
    wcGhcLinks <- readGhcLinks $ dir </> "stackage-cli"
    wcStackReleases <- decodeFileEither (dir </> "stack" </> "releases.yaml")
        >>= either throwIO return
    wcPosts <- loadPosts (dir </> "posts") `catchAny` \e -> do
      putStrLn $ "Error loading posts: " ++ tshow e
      return mempty
    wcSpamPackages <- decodeFileEither (dir </> "spam-packages.yaml")
                  >>= either throwIO (return . setFromList)
    return WebsiteContent {..}
  where
    readHtml fp = fmap preEscapedToMarkup $ readFileUtf8 $ dir </> fp
    readMarkdown fp = fmap (preEscapedToHtml . commonmarkToHtml
                        [optSmart]
                        [extTable, extAutolink])
               $ readFileUtf8 $ dir </> fp