mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-28 22:19:59 +02:00
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
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
|
@@ -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.
|
||||
|
Reference in New Issue
Block a user