Sha256: e01d587f2a414bbac1baa8ed51b98cd7229c3386f4aba1a3d930014f0a3134f7

Contents?: true

Size: 1.32 KB

Versions: 3

Compression:

Stored size: 1.32 KB

Contents

module Octopress
  module Docs
    class Page < Jekyll::Page
      include Jekyll::Convertible

      # Purpose: Configs can override a page's permalink
      #
      # url - Path relative to destination directory.
      #       examples: 
      #         - '/' for the _site/index.html page
      #         - '/archive/' for the _site/archive/index.html page
      #
      def initialize(site, base, dir, name, config={})
        @config = config
        super(site, base, dir, name)
        post_init if respond_to?(:post_init)
      end

      def hooks
        Octopress.site.page_hooks
      end

      def destination(dest)
        unless @dest
          if @config['path']
            dest = File.join(dest, @config['path'])
          end
          @dest = File.join(dest, self.url)
        end
        @dest
      end

      def relative_asset_path
        site_source = Pathname.new Octopress.site.source
        page_source = Pathname.new @base
        page_source.relative_path_from(site_source).to_s
      end

      # Allow pages to read url from plugin configuration
      #
      def url
        unless @url
          super

          if @url && @url =~ /\/$/
            ext = (self.ext == '.xml'? 'xml' : 'html')
            @url = File.join(@url, "index.#{ext}")
          end
        end

        @url
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
octopress-docs-0.0.11 lib/octopress-docs/page.rb
octopress-docs-0.0.10 lib/octopress-docs/page.rb
octopress-docs-0.0.9 lib/octopress-docs/page.rb