mirror of
https://github.com/gohugoio/hugo.git
synced 2025-02-20 18:33:52 +00:00
hugolib: Correctly identify "my_index_page.md"
The above example was earlier identified as a section page and not a regular page. Fixes #3234
This commit is contained in:
parent
7f68e3199e
commit
17b21e0af1
2 changed files with 22 additions and 1 deletions
|
@ -1859,8 +1859,15 @@ func sectionsFromFilename(filename string) []string {
|
||||||
return sections
|
return sections
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const (
|
||||||
|
regularPageFileNameDoesNotStartWith = "_index"
|
||||||
|
|
||||||
|
// There can be "my_regular_index_page.md but not /_index_file.md
|
||||||
|
regularPageFileNameDoesNotContain = helpers.FilePathSeparator + regularPageFileNameDoesNotStartWith
|
||||||
|
)
|
||||||
|
|
||||||
func kindFromFilename(filename string) string {
|
func kindFromFilename(filename string) string {
|
||||||
if !strings.Contains(filename, "_index") {
|
if !strings.HasPrefix(filename, regularPageFileNameDoesNotStartWith) && !strings.Contains(filename, regularPageFileNameDoesNotContain) {
|
||||||
return KindPage
|
return KindPage
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -201,6 +201,20 @@ func TestLastChange(t *testing.T) {
|
||||||
require.Equal(t, 2017, s.Info.LastChange.Year(), "Site.LastChange should be set to the page with latest Lastmod (year 2017)")
|
require.Equal(t, 2017, s.Info.LastChange.Year(), "Site.LastChange should be set to the page with latest Lastmod (year 2017)")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Issue #_index
|
||||||
|
func TestPageWithUnderScoreIndexInFilename(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
|
|
||||||
|
cfg, fs := newTestCfg()
|
||||||
|
|
||||||
|
writeSource(t, fs, filepath.Join("content", "sect/my_index_file.md"), "---\ntitle: doc1\nweight: 1\ndate: 2014-05-29\n---\n# doc1\n*some content*")
|
||||||
|
|
||||||
|
s := buildSingleSite(t, deps.DepsCfg{Fs: fs, Cfg: cfg}, BuildCfg{SkipRender: true})
|
||||||
|
|
||||||
|
require.Len(t, s.RegularPages, 1)
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
// Issue #957
|
// Issue #957
|
||||||
func TestCrossrefs(t *testing.T) {
|
func TestCrossrefs(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
|
|
Loading…
Reference in a new issue