Last active
May 5, 2021 15:58
-
-
Save thespacedoctor/7a6d081f76830913daea6340f28fabc0 to your computer and use it in GitHub Desktop.
[Jekyll supplementary data module] copy jekyll post's supplementary data files to a location adjacent to the post's built html #data #jekyll
This file contains 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
module Jekyll | |
Jekyll::Hooks.register :site, :post_write do |site| | |
build = site.config["destination"] | |
site.posts.each {|post| | |
source = post.path.split("/")[0..-2].join("/") | |
# SKIP POSTS THAT ARE SINGLE FILES NOT DIRECTORIES | |
if source.split("/")[-1] == "_posts" | |
next | |
end | |
destination = post.url.split("/")[0..-2].join("/") | |
# MOVE EACH ITEM IN DIRECTORY INTO BUILD | |
Dir.entries(source).each {|item| | |
if not [".","..",".DS_Store"].include?(item) | |
src = source+"/"+item | |
des = build+destination+"/"+item | |
FileUtils.copy_entry(src, des) | |
end | |
} | |
} | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment