Unify page lookups

This commit unifies the core internal page index for all page kinds.

This enables the `ref` and `relref` shortcodes to support all pages kinds, and adds a new page-relative  `.GetPage` method with simplified signature.

See #4147
See #4727
See #4728
See #4728
See #4726
See #4652
This commit is contained in:
Vas Sudanagunta 2018-05-29 21:35:27 -04:00 committed by Bjørn Erik Pedersen
parent fd1f4a7860
commit b93417aa1d
16 changed files with 294 additions and 153 deletions

View file

@ -117,12 +117,12 @@ Do not go gentle into that good night.
assert.Len(s.RegularPages, 2)
notUgly := s.getPage(KindPage, "sect1/p1.md")
notUgly, _ := s.getPage(nil, "sect1/p1.md")
assert.NotNil(notUgly)
assert.Equal("sect1", notUgly.Section())
assert.Equal("/sect1/p1/", notUgly.RelPermalink())
ugly := s.getPage(KindPage, "sect2/p2.md")
ugly, _ := s.getPage(nil, "sect2/p2.md")
assert.NotNil(ugly)
assert.Equal("sect2", ugly.Section())
assert.Equal("/sect2/p2.html", ugly.RelPermalink())
@ -175,7 +175,7 @@ Do not go gentle into that good night.
assert.Len(s.RegularPages, 10)
sect1 := s.getPage(KindSection, "sect1")
sect1, _ := s.getPage(nil, "sect1")
assert.NotNil(sect1)
assert.Equal("/ss1/", sect1.RelPermalink())
th.assertFileContent(filepath.Join("public", "ss1", "index.html"), "P1|URL: /ss1/|Next: /ss1/page/2/")