diff options
author | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2023-01-04 18:24:36 +0100 |
---|---|---|
committer | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2023-05-16 18:01:29 +0200 |
commit | 241b21b0fd34d91fccb2ce69874110dceae6f926 (patch) | |
tree | d4e0118eac7e9c42f065815447a70805f8d6ad3e /resources/resource_transformers/tocss/scss/tocss.go | |
parent | 6aededf6b42011c3039f5f66487a89a8dd65e0e7 (diff) |
Create a struct with all of Hugo's config options
Primary motivation is documentation, but it will also hopefully simplify the code.
Also,
* Lower case the default output format names; this is in line with the custom ones (map keys) and how
it's treated all the places. This avoids doing `stringds.EqualFold` everywhere.
Closes #10896
Closes #10620
Diffstat (limited to 'resources/resource_transformers/tocss/scss/tocss.go')
-rw-r--r-- | resources/resource_transformers/tocss/scss/tocss.go | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/resources/resource_transformers/tocss/scss/tocss.go b/resources/resource_transformers/tocss/scss/tocss.go index 7e44f327e..1018ea02e 100644 --- a/resources/resource_transformers/tocss/scss/tocss.go +++ b/resources/resource_transformers/tocss/scss/tocss.go @@ -40,7 +40,7 @@ func Supports() bool { } func (t *toCSSTransformation) Transform(ctx *resources.ResourceTransformationCtx) error { - ctx.OutMediaType = media.CSSType + ctx.OutMediaType = media.Builtin.CSSType var outName string if t.options.from.TargetPath != "" { @@ -124,14 +124,14 @@ func (t *toCSSTransformation) Transform(ctx *resources.ResourceTransformationCtx return "", "", false } - if ctx.InMediaType.SubType == media.SASSType.SubType { + if ctx.InMediaType.SubType == media.Builtin.SASSType.SubType { options.to.SassSyntax = true } if options.from.EnableSourceMap { options.to.SourceMapOptions.Filename = outName + ".map" - options.to.SourceMapOptions.Root = t.c.rs.WorkingDir + options.to.SourceMapOptions.Root = t.c.rs.Cfg.BaseConfig().WorkingDir // Setting this to the relative input filename will get the source map // more correct for the main entry path (main.scss typically), but @@ -159,8 +159,8 @@ func (t *toCSSTransformation) Transform(ctx *resources.ResourceTransformationCtx if options.from.EnableSourceMap && res.SourceMapContent != "" { sourcePath := t.c.sfs.RealFilename(ctx.SourcePath) - if strings.HasPrefix(sourcePath, t.c.rs.WorkingDir) { - sourcePath = strings.TrimPrefix(sourcePath, t.c.rs.WorkingDir+helpers.FilePathSeparator) + if strings.HasPrefix(sourcePath, t.c.rs.Cfg.BaseConfig().WorkingDir) { + sourcePath = strings.TrimPrefix(sourcePath, t.c.rs.Cfg.BaseConfig().WorkingDir+helpers.FilePathSeparator) } // This needs to be Unix-style slashes, even on Windows. |