entity

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Feb 4, 2024 License: Apache-2.0 Imports: 33 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddTrailingSlash

func AddTrailingSlash(path string) string

AddTrailingSlash adds a trailing Unix styled slash (/) if not already there.

func BytesToHTML

func BytesToHTML(b []byte) template.HTML

BytesToHTML converts bytes to type template.HTML.

func MD5String

func MD5String(f string) string

MD5String takes a string and returns its MD5 hash.

func NewZeroFile

func NewZeroFile() hugosites.File

func OpenFileForWriting

func OpenFileForWriting(fs afero.Fs, filename string) (afero.File, error)

OpenFileForWriting opens or creates the given file. If the target directory does not exist, it gets created.

Types

type ContentMap

type ContentMap struct {
	// View of regular pages, sections, and taxonomies.
	PageTrees ContentTrees

	// View of pages, sections, taxonomies, and resources.
	BundleTrees ContentTrees

	// Stores page bundles keyed by its path's directory or the base filename,
	// e.g. "blog/post.md" => "/blog/post", "blog/post/index.md" => "/blog/post"
	// These are the "regular pages" and all of them are bundles.
	Pages *ContentTree

	// Section nodes.
	Sections *ContentTree
}

func (*ContentMap) AddFilesBundle

func (m *ContentMap) AddFilesBundle(header fsVO.FileMetaInfo) error

func (*ContentMap) CreateMissingNodes

func (m *ContentMap) CreateMissingNodes() error

type ContentTree

type ContentTree struct {
	Name string
	*radixtree.Tree
}

type ContentTrees

type ContentTrees []*ContentTree

func (ContentTrees) Walk

func (c ContentTrees) Walk(fn contentTreeNodeCallback)

type DestinationPublisher

type DestinationPublisher struct {
	Fs afero.Fs
}

DestinationPublisher is the default and currently only publisher in Hugo. This publisher prepares and publishes an item to the defined destination, e.g. /public.

func (*DestinationPublisher) Publish

Publish applies any relevant transformations and writes the file to its destination, e.g. /public.

type FileInfo

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

FileInfo describes a source file.

func NewFileInfo

func NewFileInfo(fi fsVO.FileMetaInfo) (*FileInfo, error)

func (*FileInfo) BaseFileName

func (fi *FileInfo) BaseFileName() string

BaseFileName returns a file's name without extension (ie. "page.sv").

func (*FileInfo) ContentBaseName

func (fi *FileInfo) ContentBaseName() string

ContentBaseName is a either TranslationBaseName or name of containing folder if file is a leaf bundle.

func (*FileInfo) Dir

func (fi *FileInfo) Dir() string

Dir gets the name of the directory that contains this file. The directory is relative to the content root.

func (*FileInfo) Ext

func (fi *FileInfo) Ext() string

Ext returns a file's extension without the leading period (ie. "md").

func (*FileInfo) Extension

func (fi *FileInfo) Extension() string

Extension is an alias to Ext().

func (*FileInfo) FileInfo

func (fi *FileInfo) FileInfo() fsVO.FileMetaInfo

FileInfo returns a file's underlying os.FileInfo.

func (*FileInfo) Filename

func (fi *FileInfo) Filename() string

Filename returns a file's absolute path and filename on disk.

func (*FileInfo) IsZero

func (fi *FileInfo) IsZero() bool

func (*FileInfo) LogicalName

func (fi *FileInfo) LogicalName() string

LogicalName returns a file's name and extension (ie. "page.sv.md").

func (*FileInfo) Path

func (fi *FileInfo) Path() string

Path gets the relative path including file name and extension. The directory is relative to the content root.

func (*FileInfo) Section

func (fi *FileInfo) Section() string

Section returns a file's section.

func (*FileInfo) TranslationBaseName

func (fi *FileInfo) TranslationBaseName() string

TranslationBaseName returns a file's translation base name without the language segment (ie. "page").

func (*FileInfo) UniqueID

func (fi *FileInfo) UniqueID() string

UniqueID returns a file's unique, MD5 hash identifier.

type HugoSites

type HugoSites struct {
	deps.Deps

	Sites      []*Site
	NumWorkers int

	// Render output formats for all sites.
	RenderFormats valueobject.Formats
	// contains filtered or unexported fields
}

func (*HugoSites) Build

func (h *HugoSites) Build() error

type PageCollections

type PageCollections struct {
	PageMap *PageMap
}

PageCollections contains the page collections for a site.

type PageMap

type PageMap struct {
	S *Site
	*ContentMap
}

func (*PageMap) AssemblePages

func (m *PageMap) AssemblePages() error

func (*PageMap) AssembleSections

func (m *PageMap) AssembleSections() error

type Site

type Site struct {
	deps.Deps

	// The owning container. When multiple languages, there will be multiple
	// sites .
	H *HugoSites

	Language *langEntity.Language

	// Output formats defined in site config per Page Kind, or some defaults
	// if not set.
	// Output formats defined in Page front matter will override these.
	OutputFormats map[string]valueobject.Formats

	// The output formats that we need to render this site in. This slice
	// will be fixed once set.
	// This will be the union of Site.Pages' outputFormats.
	// This slice will be sorted.
	RenderFormats valueobject.Formats

	// All the output formats and media types available for this site.
	// These values will be merged from the Hugo defaults, the site config and,
	// finally, the language settings.
	OutputFormatsConfig valueobject.Formats
	MediaTypesConfig    valueobject.Types

	Publisher hugosites.Publisher

	*PageCollections
}

type TargetPathDescriptor

type TargetPathDescriptor struct {
	Type valueobject.Format
	Kind string

	Sections []string

	// For regular content pages this is either
	// 1) the Slug, if set,
	// 2) the file base name (TranslationBaseName).
	BaseName string

	// Source directory.
	Dir string

	// Typically a language prefix added to file paths.
	PrefixFilePath string

	// Typically a language prefix added to links.
	PrefixLink string

	// If in multihost mode etc., every link/path needs to be prefixed, even
	// if set in URL.
	ForcePrefix bool

	// URL from front matter if set. Will override any Slug etc.
	URL string

	// The expanded permalink if defined for the section, ready to use.
	ExpandedPermalink string
}

TargetPathDescriptor describes how a file path for a given resource should look like on the file system. The same descriptor is then later used to create both the permalinks and the relative links, paginator URLs etc.

The big motivating behind this is to have only one source of truth for URLs, and by that also get rid of most of the fragile string parsing/encoding etc.

Jump to

Keyboard shortcuts

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