Sha256: 5884e2acdc8aa4b19e0067e3bf1f2d88128a64d06532583f1c203dbbb035a689

Contents?: true

Size: 990 Bytes

Versions: 1

Compression:

Stored size: 990 Bytes

Contents

# frozen_string_literal: true

require "fileutils"

module Jekyll
  class JekyllRobots < Jekyll::Generator
    safe true
    priority :lowest

    # Main plugin action, called by Jekyll-core
    def generate(site)
      @site = site
      @site.pages << robots
    end

    # Path to robots.txt template file
    def source_path(file = "robots.txt")
      File.expand_path "../#{file}", __dir__
    end

    # Destination for robots.txt file within the site source directory
    def destination_path(file = "robots.txt")
      @site.in_dest_dir(file)
    end

    def robots
      robots = PageWithoutAFile.new(@site, __dir__, "", "robots.txt")
      robots.data["layout"] = nil
      robots
    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-robotstxt-0.3.2 lib/jekyll/jekyll-robotstxt.rb