hugolib: Add the last lookup variant for the GetPage index
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Wed, 24 Jan 2018 12:36:06 +0000 (13:36 +0100)
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Wed, 24 Jan 2018 12:36:06 +0000 (13:36 +0100)
Now, even for nun-bundles it is possible to do lookup without path or extension.

So, given `blog/my-blog-post.en.md` these lookups will succeed:

* `blog/my-blog-post.en.md`
* `blog/my-blog-post`
* `my-blog-post.en.md`
* `my-blog-post`

See #4312
See https://github.com/gohugoio/hugoDocs/issues/307

hugolib/page_bundler_test.go
hugolib/page_collections.go

index bb4980c0436cff3407cde8fd81f8dc81ede1cfa7..474f6676deb04021ef14a04b79b88be1bba695e4 100644 (file)
@@ -80,6 +80,9 @@ func TestPageBundlerSite(t *testing.T) {
                                singlePage := s.getPage(KindPage, "a/1.md")
 
                                assert.NotNil(singlePage)
+                               assert.Equal(singlePage, s.getPage("page", "a/1"))
+                               assert.Equal(singlePage, s.getPage("page", "1"))
+
                                assert.Contains(singlePage.Content, "TheContent")
 
                                if ugly {
index c9104de3b0310796d72a685a1c56bd5be56e2335..03b606955d092922ac2ab283a822d9e3c2e0977e 100644 (file)
@@ -86,6 +86,9 @@ func (c *PageCollections) refreshPageCaches() {
                                                                _, name := path.Split(dir)
                                                                cache[name] = p
                                                                cache[dir] = p
+                                                       } else {
+                                                               // Again, ambigous
+                                                               cache[translasionBaseName] = p
                                                        }
 
                                                        // We need a way to get to the current language version.