hakyll
hakyll copied to clipboard
Absolute provider filepaths
I have noticed that Hakyll rules cannot locate absolute filepaths outside of the configuration providerDirectory. Is this a premeditated choice or a misfeature? If so, I believe that it would be helpful to generalize providerDirectory to be a list.
I was trying to build a package with built-in hakyll templates, hence it would be useful to refer to those package-dependent files.
This would also be useful for vendoring: I have a provider directory ./root/
but want to copy the bootstrap js from ./vendor/bootstrap
to ./root/js/
.
I'm not Hakyll's author, so I can't provide you a rationale, but if providerDirectory
was a list, how would Hakyll resolve relative paths? For example:
- suppose
providerDirectory
is[ "./root/", "./vendor/" ]
- both
./root/bootstrap
and./vendor/bootstrap
exist - I have a
match "bootstrap/*" $ …
in my Hakyll rules — how would Hakyll figure out which of the two "bootstrap" directories to use?
Also, in @lukasstevens's case, why not move the provider directory up a level, so it incudes both "root" and "vendor" as sub-directories?
Hm, for me it would be enough if you could escape from the providerDirectory
if you use a relative path that leaves the directory. Moving providerDirectory
up is inconvenient because you have to always delete the directory root/
from the route using gsubRoute
.
Moving providerDirectory up is inconvenient because you have to always delete the directory root/ from the route using gsubRoute.
You have Haskell at your disposal, surely you could abstract this away ;)
You are correct, of course :). Nevertheless, I find it a bit surprising that you can't access paths outside the directory.
Yeah, would agree that the provider abstraction isn't great. I think there may be some ways to fix this but I want to be careful about backward-compatibility. As a workaround, you can always do something like:
create ["foo.html"] $ do
compile $ do
content <- unsafeCompile $ readFile "/some/absolute/path/...
...
The drawback of this is that changes to /some/absolute/path/...
will not be tracked be the provider abstraction, so you may need to do a full rebuild of your site once in a while.