All Projects → kowainik → hakyll-shortcut-links

kowainik / hakyll-shortcut-links

Licence: MPL-2.0 license
✂️ Hakyll shortcut-links in markdown files

Programming Languages

haskell
3896 projects

Projects that are alternatives of or similar to hakyll-shortcut-links

Awesome Maps
There is more than google: A collection of great online maps 🌍🗺🌎
Stars: ✭ 124 (+933.33%)
Mutual labels:  links
Ip Biter
IP-Biter: The Hacker-friendly E-Mail (but not only) Tracking Framework
Stars: ✭ 166 (+1283.33%)
Mutual labels:  links
action-my-broken-link-checker
A GitHub Action for checking broken links
Stars: ✭ 32 (+166.67%)
Mutual labels:  links
Favorite Link
❤️ 每日收集喜欢的开源项目 | RSS 订阅 | 快知 app 订阅
Stars: ✭ 1,741 (+14408.33%)
Mutual labels:  links
Autolink Java
Java library to extract links (URLs, email addresses) from plain text; fast, small and smart
Stars: ✭ 157 (+1208.33%)
Mutual labels:  links
Treehouseshow
TeamTreeHouse's Weekly show notes
Stars: ✭ 171 (+1325%)
Mutual labels:  links
Reading Material
List of some useful blogs, books, courses, papers etc. 📚
Stars: ✭ 116 (+866.67%)
Mutual labels:  links
gh-themes-magick
GitHub Pages Themes Magick: https://tajmone.github.io/gh-themes-magick/
Stars: ✭ 29 (+141.67%)
Mutual labels:  pandoc
Cleanlinks
Converts obfuscated/nested links to genuine clean links.
Stars: ✭ 157 (+1208.33%)
Mutual labels:  links
Helpful Lab Materials
Easily write cover letters for submitting your academic manuscripts
Stars: ✭ 54 (+350%)
Mutual labels:  pandoc
Kissanime Batch Downloader
🇯🇵 📺 KissAnime, KissCartoon and KissAsian batch links generator script
Stars: ✭ 131 (+991.67%)
Mutual labels:  links
React Faq
A collection of links to help answer your questions about React.js
Stars: ✭ 1,845 (+15275%)
Mutual labels:  links
Ounotes
An Application built for students to access Notes , Question Papers , Syllabus and Resources for all Subjects of O.U (Osmania University) 📘👨‍🎓
Stars: ✭ 173 (+1341.67%)
Mutual labels:  links
Filite
A simple, light and standalone pastebin, URL shortener and file-sharing service
Stars: ✭ 125 (+941.67%)
Mutual labels:  links
software-development-resources
Collection of links to great software development resources!
Stars: ✭ 20 (+66.67%)
Mutual labels:  links
Materialabout
It's a material-design about screen to use on your Android apps. A developer profile and application information easy to integrate. 🔖
Stars: ✭ 1,511 (+12491.67%)
Mutual labels:  links
Awesome Anime Sources
A curated list of everything anime.
Stars: ✭ 164 (+1266.67%)
Mutual labels:  links
WonderfulPolishLanguage
This is a repository created for the list of resources for learning and exploring Wonderful Polish language.
Stars: ✭ 31 (+158.33%)
Mutual labels:  links
panvimdoc
Write documentation in pandoc markdown. Generate documentation in vimdoc.
Stars: ✭ 167 (+1291.67%)
Mutual labels:  pandoc
Links-QA
Сборная солянка полезных ссылок для QA/тестировщика. Ссылки будут постоянно пополняться.
Stars: ✭ 42 (+250%)
Mutual labels:  links

hakyll-shortcut-links

scissors GitHub CI Hackage MPL-2.0 license

This library adds the support of the shortcut-links library in the static website generator library — Hakyll.

That being said, it means that you can use shortcuts from shortcut-links 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 library functions:

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 ShortcutLinks.All module of the shortcut-links library.

How to use in a Hakyll project

To use hakyll-shortcut-links in your ready Hakyll project, you would need to go through the following steps:

Add the dependency

Add hakyll-shortcut-links under the build-depends section in your .cabal file. If you use Stack build tool, you would need to add the library into extra-deps list in the stack.yaml file.

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:

compile $
    pandocCompiler >>= loadAndApplyTemplate "templates/post.html" postCtx

All you need to change is to use allShortcutLinksCompiler or shortcutLinksCompiler function from this library instead of the standard pandocCompiler:

import Hakyll.ShortcutLinks (allShortcutLinksCompiler)

...

compile $
    allShortcutLinksCompiler >>= loadAndApplyTemplate "templates/post.html" postCtx

That's all!

There could be another situation. You could already have some custom Compiler function:

-- | A pandoc compiler which makes all entries of "42" bold automatically.
bold42Compiler :: Compiler (Item String)
bold42Compiler = pandocCompilerWithTransform
    myHakyllReaderOptions
    myHakyllWriterOptions
    make42Bold

In this case, you can use the applyAllShortcuts function directly. All you need is to combine two transformations:

myCompiler :: Compiler (Item String)
myCompiler = pandocCompilerWithTransformM
    myHakyllReaderOptions
    myHakyllWriterOptions
    (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!

Example

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 pandocCompiler with allShortcutLinksCompiler.

Examples of the @github shortcut:

  • Link to a user :

    Shortcut Plain markdown
    [foo](@github) [foo](https://github.com/foo)
    [foo Github profile](@github(foo)) [foo Github profile](https://github.com/foo)
  • Link to a repository :

    Shortcut Plain markdown
    [bar](@github:foo) [bar](https://github.com/foo/bar)
    [Github Source](@github(foo):bar) [Github Source](https://github.com/foo/bar)

Acknowledgement

Icons made by Freepik from www.flaticon.com is licensed by CC 3.0 BY.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].