This library adds the support of the
in the static website generator library —
That being said, it means that you can use shortcuts from
library or custom ones in your markdown files which would be extended into
complete URLs during the Hakyll site compilation process.
Here is the example of how links could look like before expansion:
Here is going to be a link to the [hakyll-shortcut-links](@hackage) library on Hackage.
And another link to the [GitHub sources](@github(kowainik):hakyll-shortcut-links).
which is going to be transformed into the ordinary links automatically by the
Here is going to be a link to the [hakyll-shortcut-links](http://hackage.haskell.org/package/hakyll-shortcut-links) library on Hackage.
And another link to the [GitHub sources](https://github.com/kowainik/hakyll-shortcut-links).
For the full list of the supported shortcuts, you can check
How to use in a Hakyll project
hakyll-shortcut-links in your ready Hakyll project, you would need to
go through the following steps:
Add the dependency
hakyll-shortcut-links under the
build-depends section in your
If you use
Stack build tool, you would need to add the library into
extra-deps list in the
Change a standard pandocCompiler
Here we assume that you already have a Hakyll project. If not then you can use
these tutorials to create one.
Anyway, you would eventually have the code that uses
pandocCompiler that could
look like this function:
pandocCompiler >>= loadAndApplyTemplate "templates/post.html" postCtx
All you need to change is to use
shortcutLinksCompiler function from this library instead of the standard
import Hakyll.ShortcutLinks (allShortcutLinksCompiler)
allShortcutLinksCompiler >>= loadAndApplyTemplate "templates/post.html" postCtx
There could be another situation. You could already have some custom Compiler
-- | A pandoc compiler which makes all entries of "42" bold automatically.
bold42Compiler :: Compiler (Item String)
bold42Compiler = pandocCompilerWithTransform
In this case, you can use the
applyAllShortcuts function directly. All you
need is to combine two transformations:
myCompiler :: Compiler (Item String)
myCompiler = pandocCompilerWithTransformM
(applyAllShortcuts . make42Bold)
Use shortcuts in your docs
The hardest part is done, now you can create links using the shortcuts, and the
Hakyll is going to build full URLs for them. Happy coding!
Here is an example of the pull request that introduces the
hakyll-shortcut-links library into the scope:
As you can see by the diff the only actual change needed for that was replacing
Examples of the
Link to a user :
[foo Github profile](@github(foo))
[foo Github profile](https://github.com/foo)
Link to a repository :
Icons made by Freepik from www.flaticon.com is licensed by CC 3.0 BY.