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:
Bjørn Erik Pedersen
2017-03-09 19:19:29 +01:00
parent c8fff9501d
commit 6bf010fed4
26 changed files with 912 additions and 400 deletions

View File

@@ -30,7 +30,7 @@ import (
)
const (
baseURL = "http://foo/bar"
testBaseURL = "http://foo/bar"
)
func TestShortcodeCrossrefs(t *testing.T) {
@@ -46,7 +46,7 @@ func doTestShortcodeCrossrefs(t *testing.T, relative bool) {
cfg, fs = newTestCfg()
)
cfg.Set("baseURL", baseURL)
cfg.Set("baseURL", testBaseURL)
var refShortcode string
var expectedBase string
@@ -56,7 +56,7 @@ func doTestShortcodeCrossrefs(t *testing.T, relative bool) {
expectedBase = "/bar"
} else {
refShortcode = "ref"
expectedBase = baseURL
expectedBase = testBaseURL
}
path := filepath.FromSlash("blog/post.md")