1
0
mirror of https://github.com/danog/gojekyll.git synced 2025-01-23 02:11:17 +01:00
gojekyll/pages/interfaces.go

59 lines
1.5 KiB
Go
Raw Normal View History

package pages
import (
"io"
2017-07-03 10:39:55 -04:00
"time"
2017-06-24 14:00:19 -04:00
"github.com/osteele/gojekyll/pipelines"
2017-07-03 09:37:14 -04:00
"github.com/osteele/liquid"
"gopkg.in/yaml.v2"
)
// Document is a Jekyll page or file.
type Document interface {
2017-07-03 09:37:14 -04:00
liquid.Drop
yaml.Marshaler
// Paths
SiteRelPath() string // relative to the site source directory
Permalink() string // relative URL path
OutputExt() string
// Output
Published() bool
Static() bool
Write(RenderingContext, io.Writer) error
2017-07-03 09:37:14 -04:00
Categories() []string
Tags() []string
2017-07-03 09:37:14 -04:00
// Document initialization
setPermalink() error
}
2017-07-03 10:39:55 -04:00
// Page is a document with frontmatter.
type Page interface {
Document
// Content asks a page to compute its content.
// This has the side effect of causing the content to subsequently appear in the drop.
Content(rc RenderingContext) ([]byte, error)
// PostDate returns the date computed from the filename or frontmatter.
// It is an uncaught error to call this on a page that is not a Post.
// TODO Should posts have their own interface?
PostDate() time.Time
}
// RenderingContext provides context information for rendering.
type RenderingContext interface {
2017-06-24 14:00:19 -04:00
RenderingPipeline() pipelines.PipelineInterface
2017-07-03 10:39:55 -04:00
// Site is the value of the "site" template variable.
Site() interface{} // used as a drop in the rendering context
2017-06-24 11:58:12 -04:00
}
// Container is the document container.
// It's either the Site or Collection that immediately contains the document.
type Container interface {
2017-06-24 11:58:12 -04:00
OutputExt(pathname string) string
PathPrefix() string // PathPrefix is the relative prefix, "" for the site and "_coll/" for a collection
}