hugo: github.com/gohugoio/hugo/source Index | Files

package source

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

Index

Package Files

fileInfo.go filesystem.go sourceSpec.go

type File Uses

type File interface {
    FileWithoutOverlap
    // contains filtered or unexported methods
}

File represents a source file. This is a temporary construct until we resolve page.Page conflicts. TODO(bep) remove this construct once we have resolved page deprecations

type FileInfo Uses

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

FileInfo describes a source file.

func NewTestFile Uses

func NewTestFile(filename string) *FileInfo

NewTestFile creates a partially filled File used in unit tests. TODO(bep) improve this package

func (*FileInfo) BaseFileName Uses

func (fi *FileInfo) BaseFileName() string

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

func (*FileInfo) ContentBaseName Uses

func (fi *FileInfo) ContentBaseName() string

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

func (*FileInfo) Dir Uses

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 Uses

func (fi *FileInfo) Ext() string

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

func (*FileInfo) Extension Uses

func (fi *FileInfo) Extension() string

Extension is an alias to Ext().

func (*FileInfo) FileInfo Uses

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

FileInfo returns a file's underlying os.FileInfo.

func (*FileInfo) Filename Uses

func (fi *FileInfo) Filename() string

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

func (*FileInfo) IsZero Uses

func (fi *FileInfo) IsZero() bool

func (*FileInfo) Lang Uses

func (fi *FileInfo) Lang() string

Lang returns a file's language (ie. "sv").

func (*FileInfo) LogicalName Uses

func (fi *FileInfo) LogicalName() string

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

func (*FileInfo) Open Uses

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

Open implements ReadableFile.

func (*FileInfo) Path Uses

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 Uses

func (fi *FileInfo) Section() string

Section returns a file's section.

func (*FileInfo) String Uses

func (fi *FileInfo) String() string

func (*FileInfo) TranslationBaseName Uses

func (fi *FileInfo) TranslationBaseName() string

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

func (*FileInfo) UniqueID Uses

func (fi *FileInfo) UniqueID() string

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

type FileWithoutOverlap Uses

type FileWithoutOverlap interface {

    // Filename gets the full path and filename to the file.
    Filename() string

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

    // Extension gets the file extension, i.e "myblogpost.md" will return "md".
    Extension() string

    // Ext is an alias for Extension.
    Ext() string // Hmm... Deprecate Extension

    // LogicalName is filename and extension of the file.
    LogicalName() string

    // BaseFileName is a filename without extension.
    BaseFileName() string

    // TranslationBaseName is a filename with no extension,
    // not even the optional language extension part.
    TranslationBaseName() string

    // ContentBaseName is a either TranslationBaseName or name of containing folder
    // if file is a leaf bundle.
    ContentBaseName() string

    // UniqueID is the MD5 hash of the file's path and is for most practical applications,
    // Hugo content files being one of them, considered to be unique.
    UniqueID() string

    FileInfo() hugofs.FileMetaInfo
}

type Filesystem Uses

type Filesystem struct {
    Base string

    SourceSpec
    // contains filtered or unexported fields
}

Filesystem represents a source filesystem.

func (*Filesystem) Files Uses

func (f *Filesystem) Files() ([]File, error)

Files returns a slice of readable files.

type SourceSpec Uses

type SourceSpec struct {
    *helpers.PathSpec

    SourceFs afero.Fs

    Languages              map[string]interface{}
    DefaultContentLanguage string
    DisabledLanguages      map[string]bool
    // contains filtered or unexported fields
}

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

func NewSourceSpec Uses

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

NewSourceSpec initializes SourceSpec using languages the given filesystem and PathSpec.

func (*SourceSpec) IgnoreFile Uses

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

IgnoreFile returns whether a given file should be ignored.

func (*SourceSpec) IsRegularSourceFile Uses

func (s *SourceSpec) IsRegularSourceFile(filename string) (bool, error)

IsRegularSourceFile returns whether filename represents a regular file in the source filesystem.

func (*SourceSpec) NewFileInfo Uses

func (sp *SourceSpec) NewFileInfo(fi hugofs.FileMetaInfo) (*FileInfo, error)

func (*SourceSpec) NewFileInfoFrom Uses

func (sp *SourceSpec) NewFileInfoFrom(path, filename string) (*FileInfo, error)

func (SourceSpec) NewFilesystem Uses

func (sp SourceSpec) NewFilesystem(base string) *Filesystem

NewFilesystem returns a new filesytem for a given source spec.

func (SourceSpec) NewFilesystemFromFileMetaInfo Uses

func (sp SourceSpec) NewFilesystemFromFileMetaInfo(fi hugofs.FileMetaInfo) *Filesystem

Package source imports 14 packages (graph) and is imported by 242 packages. Updated 2019-08-23. Refresh now. Tools for package owners.