Skip to content

Commit eb11c3d

Browse files
committed
Replace deprecated :filename with :contentbasename in the permalinks test
1 parent fa86581 commit eb11c3d

File tree

7 files changed

+16
-11
lines changed

7 files changed

+16
-11
lines changed

check.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ run_staticcheck() {
5252
run_tests() {
5353
echo "==> Running tests..."
5454
local output
55-
if ! output=$(go test $PACKAGES 2>&1); then
55+
if ! output=$(go test -failfast $PACKAGES 2>&1); then
5656
echo "$output"
5757
exit 1
5858
fi

common/hugo/hugo.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,8 @@ func deprecateLevel(item, alternative, version string, level logg.Level) {
336336
func deprecateLevelWithLogger(item, alternative, version string, level logg.Level, log logg.Logger) {
337337
var msg string
338338
if level == logg.LevelError {
339+
// Useful to debug deprecation errors that needs to be removedor fixed. Comment out when done debugging.
340+
// hdebug.Panicf("deprecation error: %s was removed in Hugo %s. %s", item, version, alternative)
339341
msg = fmt.Sprintf("%s was deprecated in Hugo %s and subsequently removed. %s", item, version, alternative)
340342
} else {
341343
msg = fmt.Sprintf("%s was deprecated in Hugo %s and will be removed in a future release. %s", item, version, alternative)

hugolib/hugo_modules_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ title = "French Title"
8686
{{ range .Site.RegularPages }}
8787
|{{ .Title }}|{{ .RelPermalink }}|{{ .Plain }}
8888
{{ end }}
89-
{{ $data := .Site.Data }}
89+
{{ $data := hugo.Data }}
9090
Data Common: {{ $data.common.value }}
9191
Data C: {{ $data.c.value }}
9292
Data D: {{ $data.d.value }}

hugolib/hugo_sites_multihost_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ enableRobotsTXT = true
2020
pagerSize = 1
2121
2222
[permalinks]
23-
other = "/somewhere/else/:filename"
23+
other = "/somewhere/else/:contentbasename"
2424
2525
[taxonomies]
2626
tag = "tags"

hugolib/page_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1691,7 +1691,7 @@ func TestPagePathDisablePathToLower(t *testing.T) {
16911691
baseURL = "http://example.com"
16921692
disablePathToLower = true
16931693
[permalinks]
1694-
sect2 = "/:section/:filename/"
1694+
sect2 = "/:section/:contentbasename/"
16951695
sect3 = "/:section/:title/"
16961696
-- content/sect/p1.md --
16971697
---

hugolib/pagebundler_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -635,7 +635,7 @@ func TestHTMLFilesIsue11999(t *testing.T) {
635635
-- hugo.toml --
636636
disableKinds = ["taxonomy", "term", "rss", "sitemap", "robotsTXT", "404"]
637637
[permalinks]
638-
posts = "/myposts/:slugorfilename"
638+
posts = "/myposts/:slugorcontentbasename"
639639
-- content/posts/markdown-without-frontmatter.md --
640640
-- content/posts/html-without-frontmatter.html --
641641
<html>hello</html>

resources/page/permalinks_integration_test.go

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,11 @@ withallbutlastsectionslug = '/:sectionslugs[:last]/:slug/'
4141
withsectionslug = '/sectionslug/:sectionslug/:slug/'
4242
withsectionslugs = '/sectionslugs/:sectionslugs/:slug/'
4343
[permalinks.section]
44-
withfilefilename = '/sectionwithfilefilename/:filename/'
44+
withfilefilename = '/sectionwithfilefilename/:contentbasename/'
4545
withfilefiletitle = '/sectionwithfilefiletitle/:title/'
4646
withfileslug = '/sectionwithfileslug/:slug/'
4747
nofileslug = '/sectionnofileslug/:slug/'
48-
nofilefilename = '/sectionnofilefilename/:filename/'
48+
nofilefilename = '/sectionnofilefilename/:contentbasename/'
4949
nofiletitle1 = '/sectionnofiletitle1/:title/'
5050
nofiletitle2 = '/sectionnofiletitle2/:sections[:last]/'
5151
[permalinks.term]
@@ -125,9 +125,12 @@ slug: "mytagslug"
125125
b.AssertFileContent("public/pageslug/p1slugvalue/index.html", "Single|page|/pageslug/p1slugvalue/|")
126126
b.AssertFileContent("public/sectionslug/section-root-slug/page1-slug/index.html", "Single|page|/sectionslug/section-root-slug/page1-slug/|")
127127
b.AssertFileContent("public/sectionslugs/sections-root-slug/level1-slug/page1-slug/index.html", "Single|page|/sectionslugs/sections-root-slug/level1-slug/page1-slug/|")
128-
b.AssertFileContent("public/sectionwithfilefilename/index.html", "List|section|/sectionwithfilefilename/|")
128+
129+
b.AssertFileContent("public/sectionwithfilefilename/withfilefilename/index.html", "List|section|/sectionwithfilefilename/withfilefilename/|")
130+
129131
b.AssertFileContent("public/sectionwithfileslug/withfileslugvalue/index.html", "List|section|/sectionwithfileslug/withfileslugvalue/|")
130-
b.AssertFileContent("public/sectionnofilefilename/index.html", "List|section|/sectionnofilefilename/|")
132+
133+
b.AssertFileContent("public/sectionnofilefilename/nofilefilename/index.html", "List|section|/sectionnofilefilename/nofilefilename/|")
131134
b.AssertFileContent("public/sectionnofileslug/nofileslugs/index.html", "List|section|/sectionnofileslug/nofileslugs/|")
132135
b.AssertFileContent("public/sectionnofiletitle1/nofiletitle1s/index.html", "List|section|/sectionnofiletitle1/nofiletitle1s/|")
133136
b.AssertFileContent("public/sectionnofiletitle2/index.html", "List|section|/sectionnofiletitle2/|")
@@ -138,7 +141,7 @@ slug: "mytagslug"
138141
permalinksConf := b.H.Configs.Base.Permalinks
139142
b.Assert(permalinksConf, qt.DeepEquals, map[string]map[string]string{
140143
"page": {"withallbutlastsection": "/:sections[:last]/:slug/", "withallbutlastsectionslug": "/:sectionslugs[:last]/:slug/", "withpageslug": "/pageslug/:slug/", "withsectionslug": "/sectionslug/:sectionslug/:slug/", "withsectionslugs": "/sectionslugs/:sectionslugs/:slug/"},
141-
"section": {"nofilefilename": "/sectionnofilefilename/:filename/", "nofileslug": "/sectionnofileslug/:slug/", "nofiletitle1": "/sectionnofiletitle1/:title/", "nofiletitle2": "/sectionnofiletitle2/:sections[:last]/", "withfilefilename": "/sectionwithfilefilename/:filename/", "withfilefiletitle": "/sectionwithfilefiletitle/:title/", "withfileslug": "/sectionwithfileslug/:slug/"},
144+
"section": {"nofilefilename": "/sectionnofilefilename/:contentbasename/", "nofileslug": "/sectionnofileslug/:slug/", "nofiletitle1": "/sectionnofiletitle1/:title/", "nofiletitle2": "/sectionnofiletitle2/:sections[:last]/", "withfilefilename": "/sectionwithfilefilename/:contentbasename/", "withfilefiletitle": "/sectionwithfilefiletitle/:title/", "withfileslug": "/sectionwithfileslug/:slug/"},
142145
"taxonomy": {"tags": "/tagsslug/:slug/"},
143146
"term": {"tags": "/tagsslug/tag/:slug/"},
144147
})
@@ -192,7 +195,7 @@ func TestPermalinksNestedSections(t *testing.T) {
192195
files := `
193196
-- hugo.toml --
194197
[permalinks.page]
195-
books = '/libros/:sections[1:]/:filename'
198+
books = '/libros/:sections[1:]/:contentbasename'
196199
197200
[permalinks.section]
198201
books = '/libros/:sections[1:]'

0 commit comments

Comments
 (0)