Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix content dir resolution when main project is a Hugo Module #9178

Merged
merged 1 commit into from
Nov 16, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions hugofs/fileinfo.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ type FileMeta struct {
IsOrdered bool
IsSymlink bool
IsRootFile bool
IsProject bool
Watch bool

Classifier files.ContentClass
Expand Down
2 changes: 2 additions & 0 deletions hugofs/rootmapping_fs.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ func NewRootMappingFs(fs afero.Fs, rms ...RootMapping) (*RootMappingFs, error) {
rm.Meta.BaseDir = rm.ToBasedir
rm.Meta.MountRoot = rm.path
rm.Meta.Module = rm.Module
rm.Meta.IsProject = rm.IsProject

meta := rm.Meta.Copy()

Expand Down Expand Up @@ -118,6 +119,7 @@ type RootMapping struct {
To string // The source directory or file.
ToBasedir string // The base of To. May be empty if an absolute path was provided.
Module string // The module path/ID.
IsProject bool // Whether this is a mount in the main project.
Meta *FileMeta // File metadata (lang etc.)

fi FileMetaInfo
Expand Down
5 changes: 3 additions & 2 deletions hugolib/filesystems/basefs.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ func (b *BaseFs) AbsProjectContentDir(filename string) (string, string, error) {
isAbs := filepath.IsAbs(filename)
for _, dir := range b.SourceFilesystems.Content.Dirs {
meta := dir.Meta()
if meta.Module != "project" {
if !meta.IsProject {
continue
}
if isAbs {
Expand All @@ -161,7 +161,7 @@ func (b *BaseFs) AbsProjectContentDir(filename string) (string, string, error) {
contentDirs := b.SourceFilesystems.Content.Dirs
for i := len(contentDirs) - 1; i >= 0; i-- {
meta := contentDirs[i].Meta()
if meta.Module == "project" {
if meta.IsProject {
return filename, filepath.Join(meta.Filename, filename), nil
}
}
Expand Down Expand Up @@ -645,6 +645,7 @@ func (b *sourceFilesystemsBuilder) createModFs(
To: filename,
ToBasedir: base,
Module: md.Module.Path(),
IsProject: md.isMainProject,
Meta: &hugofs.FileMeta{
Watch: md.Watch(),
Weight: mountWeight,
Expand Down