mirror of
https://github.com/srid/ema.git
synced 2024-11-25 20:12:20 +03:00
Fix broken links checking
This commit is contained in:
parent
b80a9327a6
commit
f6438774f9
12
README.md
12
README.md
@ -14,18 +14,9 @@ main = do
|
||||
encodeUtf8 $ "<b>Hello</b>, 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 <kbd>Ctrl+Shift+B</kbd> in VSCode). This runs the documentation example; modify `./.ghcid` to run a different example.
|
||||
Run `bin/run` (or <kbd>Ctrl+Shift+B</kbd> 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
|
||||
|
@ -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"
|
||||
|
Loading…
Reference in New Issue
Block a user