summaryrefslogtreecommitdiffstats
path: root/resources/resource_transformers/tocss
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2023-01-04 18:24:36 +0100
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2023-05-16 18:01:29 +0200
commit241b21b0fd34d91fccb2ce69874110dceae6f926 (patch)
treed4e0118eac7e9c42f065815447a70805f8d6ad3e /resources/resource_transformers/tocss
parent6aededf6b42011c3039f5f66487a89a8dd65e0e7 (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')
-rw-r--r--resources/resource_transformers/tocss/dartsass/transform.go4
-rw-r--r--resources/resource_transformers/tocss/scss/tocss.go10
2 files changed, 7 insertions, 7 deletions
diff --git a/resources/resource_transformers/tocss/dartsass/transform.go b/resources/resource_transformers/tocss/dartsass/transform.go
index fdf4d8ef3..61ea54437 100644
--- a/resources/resource_transformers/tocss/dartsass/transform.go
+++ b/resources/resource_transformers/tocss/dartsass/transform.go
@@ -59,7 +59,7 @@ func (t *transform) Key() internal.ResourceTransformationKey {
}
func (t *transform) Transform(ctx *resources.ResourceTransformationCtx) error {
- ctx.OutMediaType = media.CSSType
+ ctx.OutMediaType = media.Builtin.CSSType
opts, err := decodeOptions(t.optsm)
if err != nil {
@@ -102,7 +102,7 @@ func (t *transform) Transform(ctx *resources.ResourceTransformationCtx) error {
}
}
- if ctx.InMediaType.SubType == media.SASSType.SubType {
+ if ctx.InMediaType.SubType == media.Builtin.SASSType.SubType {
args.SourceSyntax = godartsass.SourceSyntaxSASS
}
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.