b.Assert(contentTypes.Markdown.Suffixes(), qt.DeepEquals, []string{"md", "mdown", "markdown"})
}
-func TestPaginationConfigOld(t *testing.T) {
- files := `
--- hugo.toml --
- [languages.en]
- weight = 1
- paginatePath = "page-en"
-
- [languages.de]
- weight = 2
- paginatePath = "page-de"
- paginate = 20
-`
-
- b := hugolib.Test(t, files)
-
- confEn := b.H.Sites[0].Conf.Pagination()
- confDe := b.H.Sites[1].Conf.Pagination()
-
- b.Assert(confEn.Path, qt.Equals, "page-en")
- b.Assert(confEn.PagerSize, qt.Equals, 10)
- b.Assert(confDe.Path, qt.Equals, "page-de")
- b.Assert(confDe.PagerSize, qt.Equals, 20)
-}
-
-func TestPaginationConfigNew(t *testing.T) {
+func TestPaginationConfig(t *testing.T) {
files := `
-- hugo.toml --
[languages.en]
// Add a random config variable for testing.
// side = page in Norwegian.
configContentBase := `
- Paginate = 32
- PaginatePath = "side"
+ [pagination]
+ pagerSize = 32
+ path = "side"
`
configContentSub := `
- PaginatePath = "top"
+ [pagination]
+ path = "top"
`
mm := afero.NewMemMapFs()
c.Assert(err, qt.IsNil)
cfg := all.Base
- c.Assert(cfg.PaginatePath, qt.Equals, "top")
- c.Assert(cfg.Paginate, qt.Equals, 32)
+ c.Assert(cfg.Pagination.Path, qt.Equals, "top")
+ c.Assert(cfg.Pagination.PagerSize, qt.Equals, 32)
}
func TestLoadConfigFromThemes(t *testing.T) {
filesTemplate := `
-- hugo.toml --
theme = "mytheme"
-[social]
-twitter = "bepsays"
-[author]
-name = "bep"
[params]
rootparam = "rootvalue"
-- config/_default/hugo.toml --
rootconfigparam: {{ site.Params.rootconfigparam }}
themeparam: {{ site.Params.themeparam }}
themeconfigdirparam: {{ site.Params.themeconfigdirparam }}
-social: {{ site.Social }}
-author: {{ site.Author }}
-
`
"rootconfigparam: rootconfigvalue",
"themeparam: themevalue",
"themeconfigdirparam: themeconfigdirvalue",
- "social: map[twitter:bepsays]",
- "author: map[name:bep]",
)
})
}
-- layouts/index.html --
LanguageCode: {{ eq site.LanguageCode site.Language.LanguageCode }}|{{ site.Language.LanguageCode }}|
{{ range $i, $e := (slice site .Site) }}
-{{ $i }}|AllPages: {{ len .AllPages }}|Sections: {{ if .Sections }}true{{ end }}| Author: {{ .Authors }}|BuildDrafts: {{ .BuildDrafts }}|IsMultilingual: {{ .IsMultiLingual }}|Param: {{ .Language.Params.myparam }}|Language string: {{ .Language }}|Languages: {{ .Languages }}
+{{ $i }}|AllPages: {{ len .AllPages }}|Sections: {{ if .Sections }}true{{ end }}|BuildDrafts: {{ .BuildDrafts }}|Param: {{ .Language.Params.myparam }}|Language string: {{ .Language }}|Languages: {{ .Languages }}
{{ end }}
-
-
`
b := NewIntegrationTestBuilder(
IntegrationTestConfig{
Sections: true|
Param: enParamValue
Param: enParamValue
-IsMultilingual: true
LanguageCode: true|en-US|
`)
test := func(variant string, expectedOutput string) {
b := newTestSitesBuilder(t)
- b.WithConfigFile("toml", `paginate = 1`)
+ b.WithConfigFile("toml", `pagination.pagerSize = 1`)
b.WithContent(
"s1/p01.md", "---\ntitle: p01\n---",
"s1/p02.md", "---\ntitle: p02\n---",
files := `
-- hugo.toml --
-paginate = 1
defaultContentLanguage = "fr"
defaultContentLanguageInSubdir = false
staticDir = ["s1", "s2"]
enableRobotsTXT = true
+[pagination]
+pagerSize = 1
+
[permalinks]
other = "/somewhere/else/:filename"
baseURL = "https://example.com"
title = "Smoke Site"
rssLimit = 3
-paginate = 1
defaultContentLanguage = "en"
defaultContentLanguageInSubdir = true
enableRobotsTXT = true
+
+[pagination]
+pagerSize = 1
+
[taxonomies]
category = 'categories'
tag = 'tags'
---
title: "The Page"
outputs: ["HTML", "JSON"]
----
+---
The content.
-
+
`
---
title: "The Home"
outputs: ["HTML", "JSON", "CSV", "RSS"]
----
+---
The content.
-
+
`)
func TestPaginator(t *testing.T) {
configFile := `
baseURL = "https://example.com/foo/"
-paginate = 3
-paginatepath = "thepage"
+
+[pagination]
+pagerSize = 3
+path = "thepage"
[languages.en]
weight = 1
func TestPaginatorNodePagesOnly(t *testing.T) {
files := `
-- hugo.toml --
-paginate = 1
+[pagination]
+pagerSize = 1
-- content/p1.md --
-- layouts/_default/single.html --
-Paginator: {{ .Paginator }}
+Paginator: {{ .Paginator }}
`
b, err := TestE(t, files)
b.Assert(err, qt.IsNotNil)
disableKinds = ["term", "taxonomy"]
disableLiveReload = true
defaultContentLanguage = "nn"
-paginate = 20
+[pagination]
+pagerSize = 20
[security]
enableInlineShortcodes = true
[languages]
---
title: "P%d"
---
-P%d Content.
+P%d Content.
`
for i := 0; i < count; i++ {
c.Skip()
}
cb := func(b *sitesBuilder) {
- b.WithTemplatesAdded("index.html", `{{ $scss := "body { color: #333; }" | resources.FromString "foo.scss" | resources.ToCSS (dict "transpiler" "dartsass") }}`)
+ b.WithTemplatesAdded("index.html", `{{ $scss := "body { color: #333; }" | resources.FromString "foo.scss" | css.Sass (dict "transpiler" "dartsass") }}`)
}
testVariant(c, cb, "")
})
b.WithConfigFile("toml", `
[security]
[security.exec]
-allow="none"
-
+allow="none"
+
`)
- b.WithTemplatesAdded("index.html", `{{ $scss := "body { color: #333; }" | resources.FromString "foo.scss" | resources.ToCSS (dict "transpiler" "dartsass") }}`)
+ b.WithTemplatesAdded("index.html", `{{ $scss := "body { color: #333; }" | resources.FromString "foo.scss" | css.Sass (dict "transpiler" "dartsass") }}`)
}
testVariant(c, cb, `(?s).*sass(-embedded)?" is not whitelisted in policy "security\.exec\.allow".*`)
})
httpTestVariant(c, `{{ $json := resources.GetRemote "%[1]s/fruits.json" }}{{ $json.Content }}`, `(?s).*is not whitelisted in policy "security\.http\.urls".*`,
func(b *sitesBuilder) {
b.WithConfigFile("toml", `
-[security]
+[security]
[security.http]
urls="none"
`)
httpTestVariant(c, `{{ $json := resources.GetRemote "%[1]s/fakejson.json" }}{{ $json.Content }}`, ``,
func(b *sitesBuilder) {
b.WithConfigFile("toml", `
-[security]
+[security]
[security.http]
mediaTypes=["application/json"]
siteConfig := `
baseURL = "http://example.com/blog"
-paginate = 1
-
disableKinds = ["section", "term", "taxonomy", "RSS", "sitemap", "robotsTXT", "404"]
+[pagination]
+pagerSize = 1
+
[outputs]
home = [ "HTML", "AMP", "Calendar" ]
page = [ "HTML", "AMP", "JSON" ]
import (
"fmt"
- "html/template"
"strings"
"testing"
siteConfig := `
baseURL = "http://example.com/blog"
-paginate = 1
defaultContentLanguage = "en"
disableKinds = ["section", "term", "taxonomy", "RSS", "sitemap", "robotsTXT", "404"]
+[pagination]
+pagerSize = 1
+
[Taxonomies]
tag = "tags"
category = "categories"
siteConfig := `
baseURL = "http://example.com/blog"
-paginate = 1
defaultContentLanguage = "en"
disableKinds = ["page", "section", "term", "taxonomy", "sitemap", "robotsTXT", "404"]
+[pagination]
+pagerSize = 1
+
[outputFormats]
[outputFormats.RSS]
mediatype = "application/rss"
s := h.Sites[0]
// Issue #3450
- c.Assert(s.RSSLink(), qt.Equals, template.URL("http://example.com/blog/feed.xml"))
+ c.Assert(s.Home().OutputFormats().Get("rss").Permalink(), qt.Equals, "http://example.com/blog/feed.xml")
}
// Issue #3614
siteConfig := `
baseURL = "http://example.com/blog"
-paginate = 1
defaultContentLanguage = "en"
disableKinds = ["page", "section", "term", "taxonomy", "sitemap", "robotsTXT", "404"]
+[pagination]
+pagerSize = 1
+
[mediaTypes]
[mediaTypes."text/nodot"]
delimiter = ""
{{ $sections := (.Site.GetPage "section" .Section).Sections.ByWeight }}
</html>`)
- cfg.Set("paginate", 2)
+ cfg.Set("pagination.pagerSize", 2)
th, configs := newTestHelperFromProvider(cfg, fs, t)
siteConfig := `
baseURL = "http://example.com/blog"
-paginate = 1
defaultContentLanguage = "nn"
+[pagination]
+pagerSize = 1
+
[languages]
[languages.nn]
languageName = "Nynorsk"
`
cfg, fs := newTestCfg()
- cfg.Set("paginate", 1)
+ cfg.Set("pagination.pagerSize", 1)
th, configs := newTestHelperFromProvider(cfg, fs, t)
writeSource(t, fs, filepath.Join("content", "sect1", "_index.md"), fmt.Sprintf(st, "/ss1/"))
baseURL = "http://example.com/blog"
titleCaseStyle = "firstupper"
uglyURLs = %t
-paginate = 1
defaultContentLanguage = "en"
+[pagination]
+pagerSize = 1
[Taxonomies]
tag = "tags"
category = "categories"
b := newTestSitesBuilder(t).WithDefaultMultiSiteConfig()
homeTpl := `Site: {{ site.Language.Lang }} / {{ .Site.Language.Lang }} / {{ site.BaseURL }}
-Sites: {{ site.Sites.First.Home.Language.Lang }}
+Sites: {{ site.Sites.Default.Home.Language.Lang }}
Hugo: {{ hugo.Generator }}
`
func TestPartialWithZeroedArgs(t *testing.T) {
b := newTestSitesBuilder(t)
b.WithTemplatesAdded("index.html",
- `
+ `
X{{ partial "retval" dict }}X
X{{ partial "retval" slice }}X
X{{ partial "retval" "" }}X
b.WithTemplates(
"index.html", `
-{{ $b := slice " a " " b " " c" }}
+{{ $b := slice " a " " b " " c" }}
{{ $a := apply $b "strings.Trim" "." " " }}
a: {{ $a }}
`,
defaultMultiSiteConfig := `
baseURL = "http://example.com/blog"
-paginate = 1
disablePathToLower = true
defaultContentLanguage = "en"
defaultContentLanguageInSubdir = true
+[pagination]
+pagerSize = 1
+
[permalinks]
other = "/somewhere/else/:filename"
weight = 30
title = "På nynorsk"
languageName = "Nynorsk"
-paginatePath = "side"
+[Languages.nn.pagination]
+path = "side"
[Languages.nn.Taxonomies]
lag = "lag"
[[Languages.nn.menu.main]]
weight = 40
title = "På bokmål"
languageName = "Bokmål"
-paginatePath = "side"
+[Languages.nb.pagination]
+path = "side"
[Languages.nb.Taxonomies]
lag = "lag"
` + commonConfigSections
{{ range $stylesheets }}
- {{ with . | resources.ToCSS | fingerprint }}
+ {{ with . | css.Sass | fingerprint }}
<link as="style" href="{{ .RelPermalink }}" rel="preload stylesheet">
{{ end }}
{{ end }}
baseURL = 'http://example.com/'
disableKinds = ["taxonomy", "term"]
enableInlineShortcodes = true
-paginate = 1
enableRobotsTXT = true
+[pagination]
+pagerSize = 1
LANG_CONFIG
-- content/_index.md --
---
# Heading 1
-- layouts/shortcodes/toc.html --
-{{ page.TableOfContents }}
+{{ page.TableOfContents }}
-- layouts/_default/single.html --
{{ .Content }}
`