-load :: FilePath -> IO (Maybe Post)
-load file = do
- liftIO $ guard (takeExtension file == ".md")
- md <- liftIO (T.readFile file)
- modTime <- getModificationTime file
- let title = T.pack $ takeBaseName file
- return $ Just (Post md title modTime)
+load :: String -> IO (Maybe Post)
+load name = do
+ let file = "posts" </> name
+ guard =<< doesFileExist file
+ readMaybe <$> readFile file