Last active
February 5, 2021 12:54
-
-
Save jonsage/82bea8bc62389b3c45485fe5b12a6534 to your computer and use it in GitHub Desktop.
Registers :build permalink placeholder that is replaced with the site build time (useful for cache-busting files)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# https://articles.inqk.net/2020/02/10/jekyll-permalinks.html | |
# place in `_plugins` directory | |
module Jekyll | |
module Drops | |
class UrlDrop < Drop | |
def build | |
@context.registers[:site].time.strftime("%s") | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hmmm, have had a look around the Jekyll codebase and I think there should be a
.site
method accessible on@obj
that will get you the site. I don't know if that object has a.time
method on it but maybe give that a try and see how it goes.To be clear, rather than:
you'd have: