mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-17 21:01:26 +02:00
hugolib: Refactor/-work the permalink/target path logic
This is a pretty fundamental change in Hugo, but absolutely needed if we should have any hope of getting "multiple outputs" done. This commit's goal is to say: * Every file target path is created by `createTargetPath`, i.e. one function for all. * That function takes every page and site parameter into account, to avoid fragile string parsing to uglify etc. later on. * The path creation logic has full test coverage. * All permalinks, paginator URLs etc. are then built on top of that same logic. Fixes #1252 Fixes #2110 Closes #2374 Fixes #1885 Fixes #3102 Fixes #3179 Fixes #1641 Fixes #1989
This commit is contained in:
@@ -22,11 +22,12 @@ import (
|
||||
"fmt"
|
||||
|
||||
"github.com/spf13/hugo/output"
|
||||
"github.com/spf13/viper"
|
||||
)
|
||||
|
||||
func TestDefaultOutputDefinitions(t *testing.T) {
|
||||
t.Parallel()
|
||||
defs := defaultOutputDefinitions
|
||||
defs := createSiteOutputDefinitions(viper.New())
|
||||
|
||||
tests := []struct {
|
||||
name string
|
||||
@@ -69,7 +70,9 @@ outputs: ["json"]
|
||||
# Doc
|
||||
`
|
||||
|
||||
th, h := newTestSitesFromConfigWithDefaultTemplates(t, siteConfig)
|
||||
th, h := newTestSitesFromConfig(t, siteConfig,
|
||||
"layouts/_default/list.json", "List JSON|{{ .Title }}|{{ .Content }}",
|
||||
)
|
||||
require.Len(t, h.Sites, 1)
|
||||
|
||||
fs := th.Fs
|
||||
@@ -87,6 +90,8 @@ outputs: ["json"]
|
||||
|
||||
require.Len(t, home.outputTypes, 1)
|
||||
|
||||
th.assertFileContent("public/index.json", "TODO")
|
||||
// TODO(bep) output assert template/text
|
||||
|
||||
th.assertFileContent("public/index.json", "List JSON")
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user