package source

import "github.com/gohugoio/hugo/source"

Package source contains the types and functions related to source files.

Index

Types

type File

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

File describes a source file.

func NewContentFileInfoFrom

func NewContentFileInfoFrom(path, filename string) *File

Used in tests.

func NewFileInfo

func NewFileInfo(fi hugofs.FileMetaInfo) *File

func (*File) BaseFileName

func (fi *File) BaseFileName() string

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

func (*File) ContentBaseName

func (fi *File) ContentBaseName() string

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

func (*File) Dir

func (fi *File) Dir() string

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

func (*File) Ext

func (fi *File) Ext() string

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

func (*File) FileInfo

func (fi *File) FileInfo() hugofs.FileMetaInfo

FileInfo returns a file's underlying os.FileInfo.

func (*File) Filename

func (fi *File) Filename() string

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

func (*File) IsContentAdapter

func (fi *File) IsContentAdapter() bool

IsContentAdapter returns whether the file represents a content adapter. This means that there may be more than one Page associated with this file.

func (*File) IsZero

func (fi *File) IsZero() bool

func (*File) Lang

func (fi *File) Lang() string

Lang returns a file's language (e.g. "sv"). Deprecated: Use .Page.Language.Lang instead.

func (*File) LogicalName

func (fi *File) LogicalName() string

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

func (*File) Open

func (fi *File) Open() (hugio.ReadSeekCloser, error)

Open implements ReadableFile.

func (*File) Path

func (fi *File) Path() string

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

func (*File) Section

func (fi *File) Section() string

Section returns a file's section.

func (*File) String

func (fi *File) String() string

func (*File) TranslationBaseName

func (fi *File) TranslationBaseName() string

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

func (*File) UniqueID

func (fi *File) UniqueID() string

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

type GitInfo

type GitInfo struct {
	// Commit hash.
	Hash string `json:"hash"`
	// Abbreviated commit hash.
	AbbreviatedHash string `json:"abbreviatedHash"`
	// The commit message's subject/title line.
	Subject string `json:"subject"`
	// The author name, respecting .mailmap.
	AuthorName string `json:"authorName"`
	// The author email address, respecting .mailmap.
	AuthorEmail string `json:"authorEmail"`
	// The author date.
	AuthorDate time.Time `json:"authorDate"`
	// The commit date.
	CommitDate time.Time `json:"commitDate"`
	// The commit message's body.
	Body string `json:"body"`
}

GitInfo provides information about a version controlled source file.

func NewGitInfo

func NewGitInfo(info gitmap.GitInfo) GitInfo

func (GitInfo) IsZero

func (g GitInfo) IsZero() bool

IsZero returns true if the GitInfo is empty, meaning it will also be falsy in the Go templates.

type SourceSpec

type SourceSpec struct {
	*helpers.PathSpec

	SourceFs afero.Fs
	// contains filtered or unexported fields
}

SourceSpec abstracts language-specific file creation. TODO(bep) rename to Spec

func NewSourceSpec

func NewSourceSpec(ps *helpers.PathSpec, inclusionFilter *glob.FilenameFilter, fs afero.Fs) *SourceSpec

NewSourceSpec initializes SourceSpec using languages the given filesystem and PathSpec.

func (*SourceSpec) IgnoreFile

func (s *SourceSpec) IgnoreFile(filename string) bool

IgnoreFile returns whether a given file should be ignored.

Source Files

fileInfo.go sourceSpec.go

Version
v0.144.2 (latest)
Published
Feb 19, 2025
Platform
linux/amd64
Imports
14 packages
Last checked
13 hours ago

Tools for package owners.