These were added to the page meta object when we implemented "pages from data", but were not meant to be used in front matter.
That is not supported, so we might as well add validation.
Fixes #12484
return err
}
// Set up the global logger early to allow info deprecations during config load.
- loggers.InitGlobalLogger(r.logger.Level(), false)
+ loggers.SetGlobalLogger(r.logger)
r.changesFromBuild = make(chan []identity.Identity, 10)
DeprecateLevel(item, alternative, version, level)
}
+// DeprecateLevelMin informs about a deprecation starting at the given version, but with a minimum log level.
+func DeprecateLevelMin(item, alternative string, version string, minLevel logg.Level) {
+ level := deprecationLogLevelFromVersion(version)
+ if level < minLevel {
+ level = minLevel
+ }
+ DeprecateLevel(item, alternative, version, level)
+}
+
// DeprecateLevel informs about a deprecation logging at the given level.
func DeprecateLevel(item, alternative, version string, level logg.Level) {
var msg string
"github.com/bep/logg"
)
-func InitGlobalLogger(level logg.Level, panicOnWarnings bool) {
+// SetGlobalLogger sets the global logger.
+// This is used in a few places in Hugo, e.g. deprecated functions.
+func SetGlobalLogger(logger Logger) {
+ logMu.Lock()
+ defer logMu.Unlock()
+ log = logger
+}
+
+func initGlobalLogger(level logg.Level, panicOnWarnings bool) {
logMu.Lock()
defer logMu.Unlock()
var logHookLast func(e *logg.Entry) error
var log Logger
func init() {
- InitGlobalLogger(logg.LevelWarn, false)
+ initGlobalLogger(logg.LevelWarn, false)
}
return nil, fmt.Errorf("failed to init config: %w", err)
}
- loggers.InitGlobalLogger(d.Logger.Level(), configs.Base.PanicOnWarning)
+ loggers.SetGlobalLogger(d.Logger)
return configs, nil
}
[privacy.instagram]
disable = true
simple = true
-[privacy.twitter]
-disable = true
-enableDNT = true
-simple = true
[privacy.x]
disable = true
enableDNT = true
got := []bool{
pc.Disqus.Disable, pc.GoogleAnalytics.Disable,
pc.GoogleAnalytics.RespectDoNotTrack, pc.Instagram.Disable,
- pc.Instagram.Simple, pc.Twitter.Disable, pc.Twitter.EnableDNT,
- pc.Twitter.Simple, pc.Vimeo.Disable, pc.Vimeo.EnableDNT, pc.Vimeo.Simple,
+ pc.Instagram.Simple,
+ pc.Vimeo.Disable, pc.Vimeo.EnableDNT, pc.Vimeo.Simple,
pc.YouTube.PrivacyEnhanced, pc.YouTube.Disable, pc.X.Disable, pc.X.EnableDNT,
pc.X.Simple,
}
"strings"
"time"
+ "github.com/bep/logg"
"github.com/gobuffalo/flect"
"github.com/gohugoio/hugo/langs"
"github.com/gohugoio/hugo/markup/converter"
"github.com/gohugoio/hugo/common/constants"
"github.com/gohugoio/hugo/common/hashing"
+ "github.com/gohugoio/hugo/common/hugo"
"github.com/gohugoio/hugo/common/loggers"
"github.com/gohugoio/hugo/common/maps"
"github.com/gohugoio/hugo/common/paths"
continue
}
+ if loki == "path" || loki == "kind" || loki == "lang" {
+ // See issue 12484.
+ hugo.DeprecateLevelMin(loki+" in front matter", "", "v0.144.0", logg.LevelWarn)
+ }
+
switch loki {
case "title":
pcfg.Title = cast.ToString(v)
`,
)
}
+
+// See #12484
+func TestPageFrontMatterDeprecatePathKindLang(t *testing.T) {
+ // This cannot be parallel as it depends on output from the global logger.
+
+ files := `
+-- hugo.toml --
+disableKinds = ["taxonomy", "term", "home", "section"]
+-- content/p1.md --
+---
+title: "p1"
+kind: "page"
+lang: "en"
+path: "mypath"
+---
+-- layouts/_default/single.html --
+Title: {{ .Title }}
+`
+ b := Test(t, files, TestOptWarn())
+ b.AssertFileContent("public/mypath/index.html", "p1")
+ b.AssertLogContains(
+ "deprecated: kind in front matter was deprecated",
+ "deprecated: lang in front matter was deprecated",
+ "deprecated: path in front matter was deprecated",
+ )
+}
respectDoNotTrack = true
[privacy.instagram]
simple = true
-[privacy.twitter]
-enableDNT = true
[privacy.x]
enableDNT = true
[privacy.vimeo]
)
func TestCommentShortcode(t *testing.T) {
- t.Parallel()
+ // This cannot be parallel as it depends on output from the global logger.
files := `
-- hugo.toml --