Documentation ¶
Index ¶
- Variables
- func LstatIfPossible(fs afero.Fs, path string) (os.FileInfo, bool, error)
- func NewBasePathFs(source afero.Fs, path string) afero.Fs
- func NewReadOnlyFs(source afero.Fs) afero.Fs
- func WrapFilesystem(container, content afero.Fs) afero.Fs
- type BaseFileDecoratorFs
- type BaseFs
- type ContentClass
- type DirNameOnlyFileInfo
- type FileMeta
- type FileMetaInfo
- type FilesystemsCollector
- type RootMapping
- type RootMappingFs
- type SourceFilesystem
- type SourceFilesystems
- type WalkFunc
- type Walkway
Constants ¶
This section is empty.
Variables ¶
var AppendDirsMerger overlayfs.DirsMerger = func(lofi, bofi []fs.DirEntry) []fs.DirEntry { for _, fi1 := range bofi { var found bool if fi1.IsDir() { for _, fi2 := range lofi { if fi2.IsDir() && fi2.Name() == fi1.Name() { found = true break } } } if !found { lofi = append(lofi, fi1) } } return lofi }
AppendDirsMerger merges two directories keeping all regular files with the first slice as the base. Duplicate directories in the second slice will be ignored. This strategy is used for the i18n and data fs where we need all entries.
var LanguageDirsMerger overlayfs.DirsMerger = func(lofi, bofi []fs.DirEntry) []fs.DirEntry { for _, fi1 := range bofi { fim1 := fi1.(FileMetaInfo) var found bool for _, fi2 := range lofi { fim2 := fi2.(FileMetaInfo) if fi1.Name() == fi2.Name() && fim1.Meta().Lang == fim2.Meta().Lang { found = true break } } if !found { lofi = append(lofi, fi1) } } return lofi }
LanguageDirsMerger implements the overlayfs.DirsMerger func, which is used to merge two directories.
Functions ¶
func LstatIfPossible ¶
LstatIfPossible if the filesystem supports it, use Lstat, else use fs.Stat
func NewBasePathFs ¶
NewBasePathFs creates a new BasePathFs.
func NewReadOnlyFs ¶
NewReadOnlyFs creates a new ReadOnlyFs.
Types ¶
type BaseFileDecoratorFs ¶
type BaseFileDecoratorFs struct { afero.Fs Decorate func(fi os.FileInfo, filename string) (os.FileInfo, error) }
func (*BaseFileDecoratorFs) LstatIfPossible ¶
func (*BaseFileDecoratorFs) Open ¶
func (fs *BaseFileDecoratorFs) Open(name string) (afero.File, error)
func (*BaseFileDecoratorFs) Stat ¶
func (fs *BaseFileDecoratorFs) Stat(name string) (os.FileInfo, error)
func (*BaseFileDecoratorFs) UnwrapFilesystem ¶
func (fs *BaseFileDecoratorFs) UnwrapFilesystem() afero.Fs
type BaseFs ¶
type BaseFs struct { // SourceFilesystems contains the different source file systems. *SourceFilesystems TheBigFs *FilesystemsCollector }
BaseFs contains the core base filesystems used by Hugo. The name "base" is used to underline that even if they can be composites, they all have a base path set to a specific resource folder, e.g "/my-project/content". So, no absolute filenames needed.
type ContentClass ¶
type ContentClass string
const ( ContentClassLeaf ContentClass = "leaf" ContentClassBranch ContentClass = "branch" ContentClassFile ContentClass = "zfile" // Sort below ContentClassContent ContentClass = "zcontent" )
type DirNameOnlyFileInfo ¶
type DirNameOnlyFileInfo struct {
// contains filtered or unexported fields
}
func NewDirNameOnlyFI ¶
func NewDirNameOnlyFI(name string, modTime time.Time) *DirNameOnlyFileInfo
func (*DirNameOnlyFileInfo) IsDir ¶
func (fi *DirNameOnlyFileInfo) IsDir() bool
func (*DirNameOnlyFileInfo) ModTime ¶
func (fi *DirNameOnlyFileInfo) ModTime() time.Time
func (*DirNameOnlyFileInfo) Mode ¶
func (fi *DirNameOnlyFileInfo) Mode() os.FileMode
func (*DirNameOnlyFileInfo) Name ¶
func (fi *DirNameOnlyFileInfo) Name() string
func (*DirNameOnlyFileInfo) Size ¶
func (fi *DirNameOnlyFileInfo) Size() int64
func (*DirNameOnlyFileInfo) Sys ¶
func (fi *DirNameOnlyFileInfo) Sys() any
type FileMeta ¶
type FileMeta struct { PathInfo *paths.Path Name string Filename string Path string PathWalk string OriginalFilename string BaseDir string SourceRoot string MountRoot string Module string Weight int IsOrdered bool IsSymlink bool IsRootFile bool IsProject bool Watch bool Classifier ContentClass SkipDir bool Lang string TranslationBaseName string TranslationBaseNameWithExt string Translations []string Fs afero.Fs OpenFunc func() (afero.File, error) JoinStatFunc func(name string) (FileMetaInfo, error) }
func NewFileMeta ¶
func NewFileMeta() *FileMeta
type FileMetaInfo ¶
func DecorateFileInfo ¶
func NewFileMetaInfo ¶
func NewFileMetaInfo(fi os.FileInfo, m *FileMeta) FileMetaInfo
type FilesystemsCollector ¶
type FilesystemsCollector struct { SourceProject afero.Fs // Source for project folders OverlayMounts *overlayfs.OverlayFs OverlayMountsContent *overlayfs.OverlayFs OverlayResources *overlayfs.OverlayFs // Maps component type (layouts, static, content etc.) an ordered list of // directories representing the overlay filesystems above. OverlayDirs map[string][]FileMetaInfo }
func (*FilesystemsCollector) AddDirs ¶
func (c *FilesystemsCollector) AddDirs(rfs *RootMappingFs)
type RootMapping ¶
type RootMapping struct { // The virtual mount. From string // The source directory or file. To string // The base of To. May be empty if an // absolute path was provided. ToBasedir string // Whether this is a mount in the main project. IsProject bool Meta *FileMeta // File metadata (lang etc.) Fi FileMetaInfo // contains filtered or unexported fields }
RootMapping describes a virtual file or directory mount.
func (RootMapping) Filename ¶
func (r RootMapping) Filename(name string) string
type RootMappingFs ¶
A RootMappingFs maps several roots into one. Note that the root of this filesystem is directories only, and they will be returned in Readdir and Readdirnames in the order given.
func (*RootMappingFs) Dirs ¶
func (m *RootMappingFs) Dirs(base string) ([]FileMetaInfo, error)
func (*RootMappingFs) LstatIfPossible ¶
LstatIfPossible returns the os.FileInfo structure describing a given file.
type SourceFilesystem ¶
type SourceFilesystem struct { // Name matches one in files.ComponentFolders Name string // This is a virtual composite filesystem. It expects path relative to a context. Fs afero.Fs // This filesystem as separate root directories, starting from project and down // to the themes/modules. Dirs []FileMetaInfo // When syncing a source folder to the target (e.g. /public), this may // be set to publish into a subfolder. This is used for static syncing // in multihost mode. PublishFolder string }
A SourceFilesystem holds the filesystem for a given source type in Hugo (data, i18n, layouts, static) and additional metadata to be able to use that filesystem in server mode.
type SourceFilesystems ¶
type SourceFilesystems struct { Content *SourceFilesystem // set Data *SourceFilesystem I18n *SourceFilesystem Layouts *SourceFilesystem // set Archetypes *SourceFilesystem Assets *SourceFilesystem // Writable filesystem on top the project's resources directory, // with any sub module's resource fs layered below. ResourcesCache afero.Fs // The work folder (may be a composite of project and theme components). Work afero.Fs // When in multihost we have one static filesystem per language. The sync // static files is currently done outside of the Hugo build (where there is // a concept of a site per language). // When in non-multihost mode there will be one entry in this map with a blank key. Static map[string]*SourceFilesystem // All the /static dirs (including themes/modules). StaticDirs []FileMetaInfo }
SourceFilesystems contains the different source file systems. These can be composite file systems (theme and project etc.), and they have all root set to the source type the provides: data, i18n, static, layouts.