mirror of
https://github.com/gohugoio/hugo.git
synced 2026-08-26 00:08:53 +00:00
Compare commits
11 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 518eefee9b | |||
| 3aa22b0942 | |||
| 40c3d8233d | |||
| 7ff5ec734c | |||
| 3937ab24d0 | |||
| 9c57af1351 | |||
| d240a705d6 | |||
| bbcc2a7973 | |||
| 98ba786f2f | |||
| 6f42cfbc9b | |||
| a84beee429 |
@@ -962,7 +962,7 @@ func (c *hugoBuilder) handleEvents(watcher *watcher.Batcher,
|
||||
lrl.Logf("no page to navigate to, force refresh")
|
||||
livereload.ForceRefresh()
|
||||
}
|
||||
} else if len(otherChanges) > 0 {
|
||||
} else if len(otherChanges) > 0 || len(cssChanges) > 0 {
|
||||
if len(otherChanges) == 1 {
|
||||
// Allow single changes to be refreshed without a full page reload.
|
||||
pathToRefresh := h.PathSpec.RelURL(paths.ToSlashTrimLeading(otherChanges[0]), false)
|
||||
|
||||
@@ -640,7 +640,7 @@ func (p *Path) Base() string {
|
||||
// For pages with Type set, we treat that as the section.
|
||||
func (p *Path) BaseReTyped(typ string) (d string) {
|
||||
base := p.Base()
|
||||
if p.Section() == typ {
|
||||
if typ == "" || p.Section() == typ {
|
||||
return base
|
||||
}
|
||||
d = "/" + typ
|
||||
|
||||
@@ -54,7 +54,7 @@ require (
|
||||
github.com/mattn/go-isatty v0.0.20
|
||||
github.com/mitchellh/mapstructure v1.5.1-0.20231216201459-8508981c8b6c
|
||||
github.com/muesli/smartcrop v0.3.0
|
||||
github.com/niklasfasching/go-org v1.9.0
|
||||
github.com/niklasfasching/go-org v1.8.0
|
||||
github.com/olekukonko/tablewriter v1.0.8
|
||||
github.com/pbnjay/memory v0.0.0-20210728143218-7b4eea64cf58
|
||||
github.com/pelletier/go-toml/v2 v2.2.4
|
||||
|
||||
@@ -420,6 +420,8 @@ github.com/muesli/smartcrop v0.3.0/go.mod h1:i2fCI/UorTfgEpPPLWiFBv4pye+YAG78Rwc
|
||||
github.com/neurosnap/sentences v1.0.6/go.mod h1:pg1IapvYpWCJJm/Etxeh0+gtMf1rI1STY9S7eUCPbDc=
|
||||
github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646 h1:zYyBkD/k9seD2A7fsi6Oo2LfFZAehjjQMERAvZLEDnQ=
|
||||
github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646/go.mod h1:jpp1/29i3P1S/RLdc7JQKbRpFeM1dOBd8T9ki5s+AY8=
|
||||
github.com/niklasfasching/go-org v1.8.0 h1:WyGLaajLLp8JbQzkmapZ1y0MOzKuKV47HkZRloi+HGY=
|
||||
github.com/niklasfasching/go-org v1.8.0/go.mod h1:e2A9zJs7cdONrEGs3gvxCcaAEpwwPNPG7csDpXckMNg=
|
||||
github.com/niklasfasching/go-org v1.9.0 h1:4/Sr68Qx06hjC9MVDB/4etGP67JionLHGscLMOClpnk=
|
||||
github.com/niklasfasching/go-org v1.9.0/go.mod h1:ZAGFFkWvUQcpazmi/8nHqwvARpr1xpb+Es67oUGX/48=
|
||||
github.com/oasdiff/yaml v0.0.0-20250309154309-f31be36b4037 h1:G7ERwszslrBzRxj//JalHPu/3yz+De2J+4aLtSRlHiY=
|
||||
|
||||
@@ -965,3 +965,27 @@ All.
|
||||
|
||||
b.AssertLogContains("! WARN")
|
||||
}
|
||||
|
||||
func TestCascadeNilMapIssue13853(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
files := `
|
||||
-- hugo.toml --
|
||||
-- content/test/_index.md --
|
||||
---
|
||||
title: Test
|
||||
cascade:
|
||||
- build:
|
||||
list: local
|
||||
target:
|
||||
path: '{/test/**}'
|
||||
- params:
|
||||
title: 'Test page'
|
||||
target:
|
||||
path: '{/test/**}'
|
||||
---
|
||||
`
|
||||
|
||||
// Just verify that it does not panic.
|
||||
_ = Test(t, files)
|
||||
}
|
||||
|
||||
+1
-1
@@ -479,7 +479,7 @@ func (ps *pageState) initCommonProviders(pp pagePaths) error {
|
||||
func (po *pageOutput) GetInternalTemplateBasePathAndDescriptor() (string, tplimpl.TemplateDescriptor) {
|
||||
p := po.p
|
||||
f := po.f
|
||||
base := p.PathInfo().BaseReTyped(p.m.Type())
|
||||
base := p.PathInfo().BaseReTyped(p.m.pageConfig.Type)
|
||||
return base, tplimpl.TemplateDescriptor{
|
||||
Kind: p.Kind(),
|
||||
Lang: p.Language().Lang,
|
||||
|
||||
+2
-59
@@ -23,6 +23,7 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/bep/clocks"
|
||||
"github.com/gohugoio/hugo/htesting"
|
||||
"github.com/gohugoio/hugo/markup/asciidocext"
|
||||
"github.com/gohugoio/hugo/markup/rst"
|
||||
"github.com/gohugoio/hugo/tpl"
|
||||
@@ -368,7 +369,7 @@ func testAllMarkdownEnginesForPages(t *testing.T,
|
||||
}{
|
||||
{"md", func() bool { return true }},
|
||||
{"ad", func() bool { return asciidocext.Supports() }},
|
||||
{"rst", func() bool { return rst.Supports() }},
|
||||
{"rst", func() bool { return !htesting.IsRealCI() && rst.Supports() }},
|
||||
}
|
||||
|
||||
for _, e := range engines {
|
||||
@@ -2000,61 +2001,3 @@ title: home en
|
||||
b.AssertLogContains("Using index.de.md in your content's root directory is usually incorrect for your home page. You should use _index.de.md instead.")
|
||||
b.AssertLogContains("Using index.en.org in your content's root directory is usually incorrect for your home page. You should use _index.en.org instead.")
|
||||
}
|
||||
|
||||
// Issue 13826
|
||||
func TestTemplateSelectionIssue13826(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
files := `
|
||||
-- hugo.toml --
|
||||
disableKinds = ['home','rss','section','sitemap','taxonomy','term']
|
||||
-- content/p1.md --
|
||||
---
|
||||
title: p1 (type implicitly set to page)
|
||||
---
|
||||
-- content/p2.md --
|
||||
---
|
||||
title: p2 (type explicitly set to page)
|
||||
type: page
|
||||
---
|
||||
-- content/p3.md --
|
||||
---
|
||||
title: p3 (type explicitly set to foo)
|
||||
type: foo
|
||||
---
|
||||
-- content/foo/p4.md --
|
||||
---
|
||||
title: p4 (type implicitly set to foo)
|
||||
---
|
||||
-- content/bar/p5.md --
|
||||
---
|
||||
title: p5 (type explicitly set to foo)
|
||||
type: foo
|
||||
---
|
||||
-- layouts/page/page.html --
|
||||
layouts/page/page.html
|
||||
-- layouts/foo/page.html --
|
||||
layouts/foo/page.html
|
||||
-- layouts/page.html --
|
||||
layouts/page.html
|
||||
`
|
||||
|
||||
b := Test(t, files)
|
||||
|
||||
b.AssertFileContent("public/p1/index.html", "layouts/page/page.html")
|
||||
b.AssertFileContent("public/p2/index.html", "layouts/page/page.html")
|
||||
b.AssertFileContent("public/p3/index.html", "layouts/foo/page.html")
|
||||
b.AssertFileContent("public/foo/p4/index.html", "layouts/foo/page.html")
|
||||
b.AssertFileContent("public/bar/p5/index.html", "layouts/foo/page.html")
|
||||
|
||||
files = strings.ReplaceAll(files, "-- layouts/page/page.html --", "-- delete-me-1.txt --")
|
||||
files = strings.ReplaceAll(files, "-- layouts/foo/page.html --", "-- delete-me-2.txt --")
|
||||
|
||||
b = Test(t, files)
|
||||
|
||||
b.AssertFileContent("public/p1/index.html", "layouts/page.html")
|
||||
b.AssertFileContent("public/p2/index.html", "layouts/page.html")
|
||||
b.AssertFileContent("public/p3/index.html", "layouts/page.html")
|
||||
b.AssertFileContent("public/foo/p4/index.html", "layouts/page.html")
|
||||
b.AssertFileContent("public/bar/p5/index.html", "layouts/page.html")
|
||||
}
|
||||
|
||||
+4
-2
@@ -1,7 +1,9 @@
|
||||
# Release env.
|
||||
# These will be replaced by script before release.
|
||||
HUGORELEASER_TAG=v0.148.0
|
||||
HUGORELEASER_COMMITISH=c0d9bebacc6bf42a91a74d8bb0de7bc775c8e573
|
||||
HUGORELEASER_TAG=v0.148.2
|
||||
HUGORELEASER_COMMITISH=40c3d8233d4b123eff74725e5766fc6272f0a84d
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -177,6 +177,9 @@ func mapToPageMatcherParamsConfig(m map[string]any) (PageMatcherParamsConfig, er
|
||||
if pcfg.Fields == nil {
|
||||
pcfg.Fields = make(maps.Params)
|
||||
}
|
||||
if pcfg.Params == nil {
|
||||
pcfg.Params = make(maps.Params)
|
||||
}
|
||||
for k, v := range m {
|
||||
switch strings.ToLower(k) {
|
||||
case "_target", "target":
|
||||
@@ -186,9 +189,6 @@ func mapToPageMatcherParamsConfig(m map[string]any) (PageMatcherParamsConfig, er
|
||||
}
|
||||
pcfg.Target = target
|
||||
case "params":
|
||||
if pcfg.Params == nil {
|
||||
pcfg.Params = make(maps.Params)
|
||||
}
|
||||
params := maps.ToStringMap(v)
|
||||
for k, v := range params {
|
||||
if _, found := pcfg.Params[k]; !found {
|
||||
@@ -196,7 +196,6 @@ func mapToPageMatcherParamsConfig(m map[string]any) (PageMatcherParamsConfig, er
|
||||
}
|
||||
}
|
||||
default:
|
||||
|
||||
pcfg.Fields[k] = v
|
||||
}
|
||||
}
|
||||
|
||||
@@ -89,6 +89,7 @@ func TestPageMatcher(t *testing.T) {
|
||||
return v
|
||||
}
|
||||
c.Assert(fn(map[string]any{"_target": map[string]any{"kind": "page"}, "foo": "bar"}), qt.DeepEquals, PageMatcherParamsConfig{
|
||||
Params: maps.Params{},
|
||||
Fields: maps.Params{
|
||||
"foo": "bar",
|
||||
},
|
||||
|
||||
@@ -1762,15 +1762,18 @@ func (s *TemplateStore) toKeyCategoryAndDescriptor(p *paths.Path) (string, strin
|
||||
if category == CategoryMarkup {
|
||||
// We store all template nodes for a given directory on the same level.
|
||||
k1 = strings.TrimSuffix(k1, "/_markup")
|
||||
parts := strings.Split(d.LayoutFromTemplate, "-")
|
||||
if len(parts) < 2 {
|
||||
v, found := strings.CutPrefix(d.LayoutFromTemplate, "render-")
|
||||
if !found {
|
||||
return "", "", 0, TemplateDescriptor{}, fmt.Errorf("unrecognized render hook template")
|
||||
}
|
||||
// Either 2 or 3 parts, e.g. render-codeblock-go.
|
||||
d.Variant1 = parts[1]
|
||||
if len(parts) > 2 {
|
||||
d.Variant2 = parts[2]
|
||||
hyphenIdx := strings.Index(v, "-")
|
||||
|
||||
d.Variant1 = v
|
||||
if hyphenIdx > 0 {
|
||||
d.Variant1 = v[:hyphenIdx]
|
||||
d.Variant2 = v[hyphenIdx+1:]
|
||||
}
|
||||
|
||||
d.LayoutFromTemplate = "" // This allows using page layout as part of the key for lookups.
|
||||
}
|
||||
|
||||
|
||||
@@ -393,6 +393,61 @@ Link: [Foo](/foo)
|
||||
}
|
||||
}
|
||||
|
||||
func TestCodeblockIssue13864(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
files := `
|
||||
-- hugo.toml --
|
||||
disableKinds = ['page','rss','section','sitemap','taxonomy','term']
|
||||
-- content/_index.md --
|
||||
---
|
||||
title: home
|
||||
---
|
||||
|
||||
~~~
|
||||
LANG: none
|
||||
~~~
|
||||
|
||||
~~~go
|
||||
LANG: go
|
||||
~~~
|
||||
|
||||
~~~go-html-template
|
||||
LANG: go-html-template
|
||||
~~~
|
||||
|
||||
~~~xy
|
||||
LANG: xy
|
||||
~~~
|
||||
|
||||
~~~x-y
|
||||
LANG: x-y
|
||||
~~~
|
||||
-- layouts/home.html --
|
||||
{{ .Content }}
|
||||
-- layouts/_markup/render-codeblock.html --
|
||||
{{ .Inner }} LAYOUT: render-codeblock.html|
|
||||
-- layouts/_markup/render-codeblock-go.html --
|
||||
{{ .Inner }} LAYOUT: render-codeblock-go.html|
|
||||
-- layouts/_markup/render-codeblock-go-html-template.html --
|
||||
{{ .Inner }} LAYOUT: render-codeblock-go-html-template.html|
|
||||
-- layouts/_markup/render-codeblock-xy.html --
|
||||
{{ .Inner }} LAYOUT: render-codeblock-xy.html|
|
||||
-- layouts/_markup/render-codeblock-x-y.html.html --
|
||||
{{ .Inner }} LAYOUT: render-codeblock-x-y.html|
|
||||
`
|
||||
|
||||
b := hugolib.Test(t, files)
|
||||
|
||||
b.AssertFileContent("public/index.html",
|
||||
"LANG: none LAYOUT: render-codeblock.html|", // pass
|
||||
"LANG: go LAYOUT: render-codeblock-go.html|", // fail: uses render-codeblock-go-html-template.html
|
||||
"LANG: go-html-template LAYOUT: render-codeblock-go-html-template.html|", // fail: uses render-codeblock.html
|
||||
"LANG: xy LAYOUT: render-codeblock-xy.html|", // pass
|
||||
"LANG: x-y LAYOUT: render-codeblock-x-y.html|", // fail: uses render-codeblock.html
|
||||
)
|
||||
}
|
||||
|
||||
func TestRenderCodeblockSpecificity(t *testing.T) {
|
||||
files := `
|
||||
-- hugo.toml --
|
||||
@@ -1548,3 +1603,24 @@ a|b
|
||||
b.AssertFileContent("public/index.html", "<table>")
|
||||
b.AssertFileContent("public/index.json", "<table>")
|
||||
}
|
||||
|
||||
func TestPageKindIssue13868(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
files := `
|
||||
-- hugo.toml --
|
||||
disableKinds = ['home','rss','section','sitemap','taxonomy','term']
|
||||
-- content/p1.md --
|
||||
---
|
||||
title: p1
|
||||
---
|
||||
-- layouts/page.html --
|
||||
layouts/page.html
|
||||
-- layouts/p1/page.html --
|
||||
layouts/p1/page.html
|
||||
`
|
||||
|
||||
b := hugolib.Test(t, files)
|
||||
|
||||
b.AssertFileContent("public/p1/index.html", "layouts/p1/page.html")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user