Sha256: e98887f1ecd355d42b56080bfab48fff1ac2f78521b9cec98bcb3ec02b7c9f9d
Contents?: true
Size: 1.52 KB
Versions: 1
Compression:
Stored size: 1.52 KB
Contents
# frozen_string_literal: true require "fileutils" module Jekyll class FuturePostReader < Jekyll::PostReader def read_publishable(dir, magic_dir, matcher) future_posts = [] read_content(dir, magic_dir, matcher).tap { |docs| docs.each(&:read) } .each do |doc| next unless doc.content.valid_encoding? site.publisher.publish?(doc).tap do |will_publish| future_posts << doc if !will_publish && site.publisher.hidden_in_the_future?(doc) end end future_posts end end class JekyllCloudCannonSchedule < Jekyll::Generator safe true priority :lowest # Main plugin action, called by Jekyll-core def generate(site) @site = site @site.pages << schedule unless file_exists?("_schedule.txt") end private def source_path(file = "_schedule.txt") File.expand_path "../#{file}", __dir__ end def future_posts FuturePostReader.new(@site).read_posts("") end def schedule schedule = PageWithoutAFile.new(@site, __dir__, "", "_schedule.txt") schedule.content = File.read(source_path) schedule.data["layout"] = nil schedule.data["future_posts"] = future_posts.map(&:to_liquid) schedule end # Checks if a file already exists in the site source def file_exists?(file_path) if @site.respond_to?(:in_source_dir) File.exist? @site.in_source_dir(file_path) else File.exist? Jekyll.sanitized_path(@site.source, file_path) end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
jekyll-cloudcannon-schedule-0.1.3 | lib/jekyll/jekyll-cloudcannon-schedule.rb |