diff options
author | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2019-05-03 09:16:58 +0200 |
---|---|---|
committer | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2019-07-24 09:35:53 +0200 |
commit | 9f5a92078a3f388b52d597b5a59af5c933a112d2 (patch) | |
tree | 0b2b07e5b3a3f21877bc5585a4bdd76306a09dde /resources/resource_transformers | |
parent | 47953148b6121441d0147c960a99829c53b5a5ba (diff) |
Add Hugo Modules
This commit implements Hugo Modules.
This is a broad subject, but some keywords include:
* A new `module` configuration section where you can import almost anything. You can configure both your own file mounts nd the file mounts of the modules you import. This is the new recommended way of configuring what you earlier put in `configDir`, `staticDir` etc. And it also allows you to mount folders in non-Hugo-projects, e.g. the `SCSS` folder in the Bootstrap GitHub project.
* A module consists of a set of mounts to the standard 7 component types in Hugo: `static`, `content`, `layouts`, `data`, `assets`, `i18n`, and `archetypes`. Yes, Theme Components can now include content, which should be very useful, especially in bigger multilingual projects.
* Modules not in your local file cache will be downloaded automatically and even "hot replaced" while the server is running.
* Hugo Modules supports and encourages semver versioned modules, and uses the minimal version selection algorithm to resolve versions.
* A new set of CLI commands are provided to manage all of this: `hugo mod init`, `hugo mod get`, `hugo mod graph`, `hugo mod tidy`, and `hugo mod vendor`.
All of the above is backed by Go Modules.
Fixes #5973
Fixes #5996
Fixes #6010
Fixes #5911
Fixes #5940
Fixes #6074
Fixes #6082
Fixes #6092
Diffstat (limited to 'resources/resource_transformers')
-rw-r--r-- | resources/resource_transformers/postcss/postcss.go | 4 | ||||
-rw-r--r-- | resources/resource_transformers/tocss/scss/client.go | 3 | ||||
-rw-r--r-- | resources/resource_transformers/tocss/scss/tocss.go | 11 |
3 files changed, 12 insertions, 6 deletions
diff --git a/resources/resource_transformers/postcss/postcss.go b/resources/resource_transformers/postcss/postcss.go index d26ffad54..125989a10 100644 --- a/resources/resource_transformers/postcss/postcss.go +++ b/resources/resource_transformers/postcss/postcss.go @@ -130,7 +130,7 @@ func (t *postcssTransformation) Transform(ctx *resources.ResourceTransformationC if !filepath.IsAbs(configFile) { // We resolve this against the virtual Work filesystem, to allow // this config file to live in one of the themes if needed. - fi, err := t.rs.BaseFs.Work.Fs.Stat(configFile) + fi, err := t.rs.BaseFs.Work.Stat(configFile) if err != nil { if t.options.Config != "" { // Only fail if the user specificed config file is not found. @@ -138,7 +138,7 @@ func (t *postcssTransformation) Transform(ctx *resources.ResourceTransformationC } configFile = "" } else { - configFile = fi.(hugofs.RealFilenameInfo).RealFilename() + configFile = fi.(hugofs.FileMetaInfo).Meta().Filename() } } diff --git a/resources/resource_transformers/tocss/scss/client.go b/resources/resource_transformers/tocss/scss/client.go index 41ff67433..e69af2f74 100644 --- a/resources/resource_transformers/tocss/scss/client.go +++ b/resources/resource_transformers/tocss/scss/client.go @@ -19,6 +19,7 @@ import ( "github.com/gohugoio/hugo/hugolib/filesystems" "github.com/gohugoio/hugo/resources" "github.com/gohugoio/hugo/resources/resource" + "github.com/spf13/afero" "github.com/mitchellh/mapstructure" ) @@ -26,7 +27,7 @@ import ( type Client struct { rs *resources.Spec sfs *filesystems.SourceFilesystem - workFs *filesystems.SourceFilesystem + workFs afero.Fs } func New(fs *filesystems.SourceFilesystem, rs *resources.Spec) (*Client, error) { diff --git a/resources/resource_transformers/tocss/scss/tocss.go b/resources/resource_transformers/tocss/scss/tocss.go index 17c32ea8e..ad581d681 100644 --- a/resources/resource_transformers/tocss/scss/tocss.go +++ b/resources/resource_transformers/tocss/scss/tocss.go @@ -55,7 +55,11 @@ func (t *toCSSTransformation) Transform(ctx *resources.ResourceTransformationCtx // Append any workDir relative include paths for _, ip := range options.from.IncludePaths { - options.to.IncludePaths = append(options.to.IncludePaths, t.c.workFs.RealDirs(filepath.Clean(ip))...) + info, err := t.c.workFs.Stat(filepath.Clean(ip)) + if err == nil { + filename := info.(hugofs.FileMetaInfo).Meta().Filename() + options.to.IncludePaths = append(options.to.IncludePaths, filename) + } } // To allow for overrides of SCSS files anywhere in the project/theme hierarchy, we need @@ -74,6 +78,7 @@ func (t *toCSSTransformation) Transform(ctx *resources.ResourceTransformationCtx prevDir = baseDir } else { prevDir = t.c.sfs.MakePathRelative(filepath.Dir(prev)) + if prevDir == "" { // Not a member of this filesystem. Let LibSASS handle it. return "", "", false @@ -100,8 +105,8 @@ func (t *toCSSTransformation) Transform(ctx *resources.ResourceTransformationCtx filenameToCheck := filepath.Join(basePath, fmt.Sprintf(namePattern, name)) fi, err := t.c.sfs.Fs.Stat(filenameToCheck) if err == nil { - if fir, ok := fi.(hugofs.RealFilenameInfo); ok { - return fir.RealFilename(), "", true + if fim, ok := fi.(hugofs.FileMetaInfo); ok { + return fim.Meta().Filename(), "", true } } } |