output

package
Version: v0.20.7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 3, 2017 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// An ordered list of built-in output formats
	//
	// See https://www.ampproject.org/learn/overview/
	AMPFormat = Format{
		Name:      "AMP",
		MediaType: media.HTMLType,
		BaseName:  "index",
		Path:      "amp",
		Rel:       "amphtml",
		IsHTML:    true,
	}

	CalendarFormat = Format{
		Name:        "Calendar",
		MediaType:   media.CalendarType,
		IsPlainText: true,
		Protocol:    "webcal://",
		BaseName:    "index",
		Rel:         "alternate",
	}

	CSSFormat = Format{
		Name:           "CSS",
		MediaType:      media.CSSType,
		BaseName:       "styles",
		IsPlainText:    true,
		Rel:            "stylesheet",
		NotAlternative: true,
	}
	CSVFormat = Format{
		Name:        "CSV",
		MediaType:   media.CSVType,
		BaseName:    "index",
		IsPlainText: true,
		Rel:         "alternate",
	}

	HTMLFormat = Format{
		Name:      "HTML",
		MediaType: media.HTMLType,
		BaseName:  "index",
		Rel:       "canonical",
		IsHTML:    true,
	}

	JSONFormat = Format{
		Name:        "JSON",
		MediaType:   media.JSONType,
		BaseName:    "index",
		IsPlainText: true,
		Rel:         "alternate",
	}

	RSSFormat = Format{
		Name:      "RSS",
		MediaType: media.RSSType,
		BaseName:  "index",
		NoUgly:    true,
		Rel:       "alternate",
	}
)

Functions

This section is empty.

Types

type Format

type Format struct {
	// The Name is used as an identifier. Internal output formats (i.e. HTML and RSS)
	// can be overridden by providing a new definition for those types.
	Name string

	MediaType media.Type

	// Must be set to a value when there are two or more conflicting mediatype for the same resource.
	Path string

	// The base output file name used when not using "ugly URLs", defaults to "index".
	BaseName string

	// The value to use for rel links
	//
	// See https://www.w3schools.com/tags/att_link_rel.asp
	//
	// AMP has a special requirement in this department, see:
	// https://www.ampproject.org/docs/guides/deploy/discovery
	// I.e.:
	// <link rel="amphtml" href="https://www.example.com/url/to/amp/document.html">
	Rel string

	// The protocol to use, i.e. "webcal://". Defaults to the protocol of the baseURL.
	Protocol string

	// IsPlainText decides whether to use text/template or html/template
	// as template parser.
	IsPlainText bool

	// IsHTML returns whether this format is int the HTML family. This includes
	// HTML, AMP etc. This is used to decide when to create alias redirects etc.
	IsHTML bool

	// Enable to ignore the global uglyURLs setting.
	NoUgly bool

	// Enable if it doesn't make sense to include this format in an alternative
	// format listing, CSS being one good example.
	// Note that we use the term "alternative" and not "alternate" here, as it
	// does not necessarily replace the other format, it is an alternative representation.
	NotAlternative bool
}

Format represents an output representation, usually to a file on disk.

func (Format) BaseFilename

func (f Format) BaseFilename() string

func (Format) MarshalJSON

func (f Format) MarshalJSON() ([]byte, error)

type Formats

type Formats []Format

func DecodeFormats

func DecodeFormats(mediaTypes media.Types, maps ...map[string]interface{}) (Formats, error)

DecodeFormats takes a list of output format configurations and merges those, in the order given, with the Hugo defaults as the last resort.

func (Formats) FromFilename

func (formats Formats) FromFilename(filename string) (f Format, found bool)

FromFilename gets a Format given a filename.

func (Formats) GetByName

func (formats Formats) GetByName(name string) (f Format, found bool)

GetByName gets a format by its identifier name.

func (Formats) GetByNames

func (formats Formats) GetByNames(names ...string) (Formats, error)

GetByNames gets a list of formats given a list of identifiers.

func (Formats) GetBySuffix

func (formats Formats) GetBySuffix(suffix string) (f Format, found bool)

GetBySuffix gets a output format given as suffix, e.g. "html". It will return false if no format could be found, or if the suffix given is ambiguous. The lookup is case insensitive.

func (Formats) Len

func (f Formats) Len() int

func (Formats) Less

func (f Formats) Less(i, j int) bool

func (Formats) Swap

func (f Formats) Swap(i, j int)

type LayoutDescriptor

type LayoutDescriptor struct {
	Type    string
	Section string
	Kind    string
	Layout  string
}

LayoutDescriptor describes how a layout should be chosen. This is typically built from a Page.

type LayoutHandler

type LayoutHandler struct {
	// contains filtered or unexported fields
}

Layout calculates the layout template to use to render a given output type.

func NewLayoutHandler

func NewLayoutHandler(hasTheme bool) *LayoutHandler

func (*LayoutHandler) For

func (l *LayoutHandler) For(d LayoutDescriptor, layoutOverride string, f Format) ([]string, error)

type TemplateLookupDescriptor

type TemplateLookupDescriptor struct {
	// TemplateDir is the project or theme root of the current template.
	// This will be the same as WorkingDir for non-theme templates.
	TemplateDir string

	// The full path to the site root.
	WorkingDir string

	// Main project layout dir, defaults to "layouts"
	LayoutDir string

	// The path to the template relative the the base.
	//  I.e. shortcodes/youtube.html
	RelPath string

	// The template name prefix to look for, i.e. "theme".
	Prefix string

	// The theme dir if theme active.
	ThemeDir string

	// All the output formats in play. This is used to decide if text/template or
	// html/template.
	OutputFormats Formats

	FileExists  func(filename string) (bool, error)
	ContainsAny func(filename string, subslices [][]byte) (bool, error)
}

type TemplateNames

type TemplateNames struct {
	// The name used as key in the template map. Note that this will be
	// prefixed with "_text/" if it should be parsed with text/template.
	Name string

	OverlayFilename string
	MasterFilename  string
}

func CreateTemplateNames

func CreateTemplateNames(d TemplateLookupDescriptor) (TemplateNames, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL