source

package
v0.134.0 Latest Latest
Warning

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

Go to latest
Published: Sep 3, 2024 License: Apache-2.0 Imports: 14 Imported by: 194

Documentation

Overview

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

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type File

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

File describes a source file.

func NewFileInfo added in v0.123.0

func NewFileInfo(fi hugofs.FileMetaInfo) *File

func NewFileInfoFrom added in v0.123.0

func NewFileInfoFrom(path, filename string) *File

func (*File) BaseFileName

func (fi *File) BaseFileName() string

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

func (*File) ContentBaseName added in v0.54.0

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) Extension

func (fi *File) Extension() string

Extension is an alias to Ext(). Deprecated: Use Ext() instead.

func (*File) FileInfo added in v0.32.1

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

FileInfo returns a file's underlying os.FileInfo.

func (*File) Filename added in v0.32.1

func (fi *File) Filename() string

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

func (*File) IsContentAdapter added in v0.126.0

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 added in v0.123.0

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 added in v0.123.0

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 added in v0.110.0

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 added in v0.110.0

func NewGitInfo(info gitmap.GitInfo) GitInfo

func (GitInfo) IsZero added in v0.110.0

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 added in v0.20.1

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 added in v0.20.1

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 added in v0.32.1

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

IgnoreFile returns whether a given file should be ignored.

Jump to

Keyboard shortcuts

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