1
1
mirror of https://github.com/srid/rib.git synced 2024-07-14 16:30:35 +03:00

Update guide example

This commit is contained in:
Sridhar Ratnakumar 2020-04-10 12:52:31 -04:00
parent 4a62472fff
commit 2dcd4205a2
2 changed files with 7 additions and 9 deletions

3
.gitignore vendored
View File

@ -1,5 +1,4 @@
dist-newstyle
dist
result
.shake
guide.output
guide/.neuron

View File

@ -27,17 +27,16 @@ using Rib:
-- generate the final page text.
data Route a where
Route_Index :: Route [(Route Pandoc, Pandoc)]
Route_Article :: Path Rel File -> Route Pandoc
Route_Article :: FilePath -> Route Pandoc
-- | The `IsRoute` instance allows us to determine the target .html path for
-- each route. This affects what `routeUrl` will return.
instance IsRoute Route where
routeFile = \case
Route_Index ->
pure [relfile|index.html|]
pure "index.html"
Route_Article srcPath ->
fmap ([reldir|article|] </>) $
replaceExtension ".html" srcPath
pure $ "article" </> srcPath -<.> ".html"
-- | Main entry point to our generator.
--
@ -51,18 +50,18 @@ instance IsRoute Route where
-- provided by Rib to do the actual generation of your static site.
main :: IO ()
main = withUtf8 $ do
Rib.run [reldir|content|] [reldir|dest|] generateSite
Rib.run "content" "dest" generateSite
-- | Shake action for generating the static site
generateSite :: Action ()
generateSite = do
-- Copy over the static files
Rib.buildStaticFiles [[relfile|static/**|]]
Rib.buildStaticFiles ["static/**"]
let writeHtmlRoute :: Route a -> a -> Action ()
writeHtmlRoute r = Rib.writeRoute r . Lucid.renderText . renderPage r
-- Build individual sources, generating .html for each.
articles <-
Rib.forEvery [[relfile|*.md|]] $ \srcPath -> do
Rib.forEvery ["*.md"] $ \srcPath -> do
let r = Route_Article srcPath
doc <- Pandoc.parse Pandoc.readMarkdown srcPath
writeHtmlRoute r doc