package source
import "github.com/gohugoio/hugo/source"
Package source contains the types and functions related to source files.
Index ¶
- type File
- func NewContentFileInfoFrom(path, filename string) *File
- func NewFileInfo(fi hugofs.FileMetaInfo) *File
- func (fi *File) BaseFileName() string
- func (fi *File) ContentBaseName() string
- func (fi *File) Dir() string
- func (fi *File) Ext() string
- func (fi *File) FileInfo() hugofs.FileMetaInfo
- func (fi *File) Filename() string
- func (fi *File) IsContentAdapter() bool
- func (fi *File) IsZero() bool
- func (fi *File) Lang() string
- func (fi *File) LogicalName() string
- func (fi *File) Open() (hugio.ReadSeekCloser, error)
- func (fi *File) Path() string
- func (fi *File) Section() string
- func (fi *File) String() string
- func (fi *File) TranslationBaseName() string
- func (fi *File) UniqueID() string
- type GitInfo
- type SourceSpec
Types ¶
type File ¶
type File struct {
// contains filtered or unexported fields
}
File describes a source file.
func NewContentFileInfoFrom ¶
Used in tests.
func NewFileInfo ¶
func NewFileInfo(fi hugofs.FileMetaInfo) *File
func (*File) BaseFileName ¶
BaseFileName returns a file's name without extension (e.g. "page.sv").
func (*File) ContentBaseName ¶
ContentBaseName is a either TranslationBaseName or name of containing folder if file is a bundle.
func (*File) Dir ¶
Dir gets the name of the directory that contains this file. The directory is relative to the content root.
func (*File) Ext ¶
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 ¶
Filename returns a file's absolute path and filename on disk.
func (*File) IsContentAdapter ¶
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 (*File) Lang ¶
Lang returns a file's language (e.g. "sv"). Deprecated: Use .Page.Language.Lang instead.
func (*File) LogicalName ¶
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 ¶
Path gets the relative path including file name and extension. The directory is relative to the content root.
func (*File) Section ¶
Section returns a file's section.
func (*File) String ¶
func (*File) TranslationBaseName ¶
TranslationBaseName returns a file's translation base name without the language segment (e.g. "page").
func (*File) UniqueID ¶
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 (GitInfo) IsZero ¶
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 ¶
- Version
- v0.144.2 (latest)
- Published
- Feb 19, 2025
- Platform
- linux/amd64
- Imports
- 14 packages
- Last checked
- 13 hours ago –
Tools for package owners.