mirror of
https://github.com/gohugoio/hugo.git
synced 2025-04-27 22:21:07 +03: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:
parent
6aededf6b4
commit
241b21b0fd
337 changed files with 13377 additions and 14898 deletions
|
@ -16,12 +16,11 @@ package hugolib
|
|||
import (
|
||||
"fmt"
|
||||
"html/template"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
|
||||
qt "github.com/frankban/quicktest"
|
||||
|
||||
"github.com/gohugoio/hugo/deps"
|
||||
"github.com/gohugoio/hugo/config"
|
||||
)
|
||||
|
||||
func TestPermalink(t *testing.T) {
|
||||
|
@ -68,28 +67,38 @@ func TestPermalink(t *testing.T) {
|
|||
t.Run(fmt.Sprintf("%s-%d", test.file, i), func(t *testing.T) {
|
||||
t.Parallel()
|
||||
c := qt.New(t)
|
||||
cfg, fs := newTestCfg()
|
||||
|
||||
cfg := config.New()
|
||||
cfg.Set("uglyURLs", test.uglyURLs)
|
||||
cfg.Set("canonifyURLs", test.canonifyURLs)
|
||||
cfg.Set("baseURL", test.base)
|
||||
|
||||
pageContent := fmt.Sprintf(`---
|
||||
files := fmt.Sprintf(`
|
||||
-- hugo.toml --
|
||||
baseURL = %q
|
||||
-- content/%s --
|
||||
---
|
||||
title: Page
|
||||
slug: %q
|
||||
url: %q
|
||||
url: %q
|
||||
output: ["HTML"]
|
||||
---
|
||||
Content
|
||||
`, test.slug, test.url)
|
||||
`, test.base, test.file, test.slug, test.url)
|
||||
|
||||
writeSource(t, fs, filepath.Join("content", filepath.FromSlash(test.file)), pageContent)
|
||||
if i > 0 {
|
||||
t.Skip()
|
||||
}
|
||||
|
||||
s := buildSingleSite(t, deps.DepsCfg{Fs: fs, Cfg: cfg}, BuildCfg{SkipRender: true})
|
||||
b := NewIntegrationTestBuilder(
|
||||
IntegrationTestConfig{
|
||||
T: t,
|
||||
TxtarString: files,
|
||||
BaseCfg: cfg,
|
||||
},
|
||||
)
|
||||
|
||||
b.Build()
|
||||
s := b.H.Sites[0]
|
||||
c.Assert(len(s.RegularPages()), qt.Equals, 1)
|
||||
|
||||
p := s.RegularPages()[0]
|
||||
|
||||
u := p.Permalink()
|
||||
|
||||
expected := test.expectedAbs
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue