diff --git a/README.md b/README.md index b316389..503ebbe 100644 --- a/README.md +++ b/README.md @@ -14,18 +14,9 @@ main = do encodeUtf8 $ "Hello, from " <> name ``` -## Quick Preview - -If you have Nix installed, give Ema a test-drive by running it to serve its own documentation: - -```bash -git clone https://github.com/srid/ema.git -cd ema && PORT=8000 nix run . -- -C ./docs -``` - ## Hacking -Run `bin/run` (or Ctrl+Shift+B in VSCode). This runs the documentation example; modify `./.ghcid` to run a different example. +Run `bin/run` (or Ctrl+Shift+B in VSCode). This runs the documentation example; modify `./.ghcid` to run a different example, such as the clock example - which updates every second, demonstrating hot reload. ## TODO @@ -44,6 +35,7 @@ pre-announce, - CLI UX - [x] opts - [ ] logging + - Expose it to apps (inc/ helpers) in a simple way - [x] [deal with errors](https://github.com/srid/memoir/issues/1) - [x] How to serve non-generated files (css, img, etc.) - [ ] Publish Data.LVar to Hackage diff --git a/src/Ema/Example/Ex03_Documentation.hs b/src/Ema/Example/Ex03_Documentation.hs index 28c741d..b9b6f5c 100644 --- a/src/Ema/Example/Ex03_Documentation.hs +++ b/src/Ema/Example/Ex03_Documentation.hs @@ -145,14 +145,17 @@ render emaAction srcs spath = do renderBreadcrumbs srcs spath renderPandoc $ doc - & rewriteLinks - ( \url -> - if "://" `T.isInfixOf` url - then url - else -- TODO: If referring to static files, we will have to be more lenient here. - maybe (error $ "Broken link? " <> url) routeUrl $ mkSourcePath $ toString url - ) & applyClassLibrary (\c -> fromMaybe c $ Map.lookup c emaMarkdownStyleLibrary) + & rewriteLinks + -- Rewrite .md links to @SourcePath@ + ( \url -> fromMaybe url $ do + guard $ not $ "://" `T.isInfixOf` url + target <- mkSourcePath $ toString url + -- Check that .md links are not broken + if Map.member target (untag srcs) + then pure $ routeUrl target + else throw $ BadRoute target + ) H.footer ! A.class_ "mt-8 text-center text-gray-500" $ do "Powered by " H.a ! A.class_ "font-bold" ! A.target "blank" ! A.href "https://github.com/srid/ema" $ "Ema"