ruby [Jekyll补充数据模块]将jekyll post的补充数据文件复制到帖子的内置html附近的位置#data #jekyll

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了ruby [Jekyll补充数据模块]将jekyll post的补充数据文件复制到帖子的内置html附近的位置#data #jekyll相关的知识,希望对你有一定的参考价值。

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

以上是关于ruby [Jekyll补充数据模块]将jekyll post的补充数据文件复制到帖子的内置html附近的位置#data #jekyll的主要内容,如果未能解决你的问题,请参考以下文章