Alternative to "relativizeUrls"?
bdoering opened this issue ยท 2 comments
Hi!
I was just exploring Slick for a small project and comparing it to Hakyll. I like the approach around Shake! My goal is to build a documentation site so that I can send around a bunch of pages by email (e.g. as a zip archive). The site should be usable without having a web server running, so URLs of referenced images, JS, and CSS files should be relative. In Hakyll-land there is relativizeUrls
. It looks like there is no alternative for Slick, correct? Without having Hakyll's Context
around, it seems to be quite tedious to get this working, or am I missing something?
Thank you!
Hi! Sorry it's taken so long to get around to this!
You're correct that slick doesn't have anything built in for this, but that's actually by design ๐
Slick is built to be a set of tools to make building your own static site the way that YOU want to; which means it should actually be pretty easy whip up a version of relativeUrls
which works however you want it to ๐
Slick doesn't do anything "clever" with urls, you can pass them around and manage them yourself. Slick doesn't have a "Context", but it's compatible with Monad Transformers, so you can wrap your monad in a Reader String
which contains your URL prefix and write a relativize
function which adapts a filepath however you want it to after referencing your global path.
If you need to scope pieces of your app differently you can simply use local
from ReaderT. Relying on "standard" tools like this helps keep the slick core simple, and avoids re-inventing the wheel for things that Haskell already has tools for ๐๐ผ
Good luck! I'll close this for now, but let me know if you have other questions ๐
@ChrisPenner Sorry for the necropost, but how do you recommend one should implement it?