mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-30 22:39:58 +02:00
Misc permalinks adjustments
* Move config loading to the page package * Fix a lower bound panic for the `:sections` slice syntax. * Always return the `:title` * Add some permalinks integration tests * Also see issues below Fixes #9448 Fixes #11184 See #8523
This commit is contained in:
@@ -680,7 +680,14 @@ func (m *contentMap) splitKey(k string) []string {
|
||||
return nil
|
||||
}
|
||||
|
||||
return strings.Split(k, "/")[1:]
|
||||
parts := strings.Split(k, "/")[1:]
|
||||
if len(parts) == 0 {
|
||||
return nil
|
||||
}
|
||||
if parts[len(parts)-1] == "" {
|
||||
parts = parts[:len(parts)-1]
|
||||
}
|
||||
return parts
|
||||
}
|
||||
|
||||
func (m *contentMap) testDump() string {
|
||||
|
@@ -205,6 +205,10 @@ func (s *IntegrationTestBuilder) Build() *IntegrationTestBuilder {
|
||||
return s
|
||||
}
|
||||
|
||||
func (s *IntegrationTestBuilder) LogString() string {
|
||||
return s.logBuff.String()
|
||||
}
|
||||
|
||||
func (s *IntegrationTestBuilder) BuildE() (*IntegrationTestBuilder, error) {
|
||||
s.Helper()
|
||||
if err := s.initBuilder(); err != nil {
|
||||
|
@@ -109,13 +109,13 @@ func createTargetPathDescriptor(s *Site, p page.Page, pm *pageMeta) (page.Target
|
||||
)
|
||||
|
||||
d := s.Deps
|
||||
classifier := files.ContentClassZero
|
||||
var classifier files.ContentClass
|
||||
|
||||
if !p.File().IsZero() {
|
||||
dir = p.File().Dir()
|
||||
baseName = p.File().TranslationBaseName()
|
||||
contentBaseName = p.File().ContentBaseName()
|
||||
classifier = p.File().Classifier()
|
||||
classifier = p.File().FileInfo().Meta().Classifier
|
||||
}
|
||||
|
||||
if classifier == files.ContentClassLeaf {
|
||||
|
@@ -160,3 +160,25 @@ Do not go gentle into that good night.
|
||||
th.assertFileContent(filepath.Join("public", "ss1", "index.html"), "P1|URL: /ss1/|Next: /ss1/page/2/")
|
||||
th.assertFileContent(filepath.Join("public", "ss1", "page", "2", "index.html"), "P2|URL: /ss1/page/2/|Next: /ss1/page/3/")
|
||||
}
|
||||
|
||||
func TestSectionsEntries(t *testing.T) {
|
||||
files := `
|
||||
-- hugo.toml --
|
||||
-- content/withfile/_index.md --
|
||||
-- content/withoutfile/p1.md --
|
||||
-- layouts/_default/list.html --
|
||||
SectionsEntries: {{ .SectionsEntries }}
|
||||
|
||||
|
||||
`
|
||||
|
||||
b := NewIntegrationTestBuilder(
|
||||
IntegrationTestConfig{
|
||||
T: t,
|
||||
TxtarString: files,
|
||||
},
|
||||
).Build()
|
||||
|
||||
b.AssertFileContent("public/withfile/index.html", "SectionsEntries: [withfile]")
|
||||
b.AssertFileContent("public/withoutfile/index.html", "SectionsEntries: [withoutfile]")
|
||||
}
|
||||
|
Reference in New Issue
Block a user