default title

This commit is contained in:
Jacky Zhao 2023-02-25 13:00:05 -08:00
parent 55ee3ce9c7
commit e45dd6c7c8

View File

@ -60,10 +60,17 @@ func walk(root, ext string, index bool, ignorePaths map[string]struct{}) (res []
info, _ := os.Stat(s) info, _ := os.Stat(s)
source := processSource(trim(s, root, ".md")) source := processSource(trim(s, root, ".md"))
// default title
title := matter.Title
if title == "" {
fileName := d.Name()
title = strings.TrimSuffix(filepath.Base(fileName), filepath.Ext(fileName))
}
// add to content and link index // add to content and link index
i[source] = Content{ i[source] = Content{
LastModified: info.ModTime(), LastModified: info.ModTime(),
Title: matter.Title, Title: title,
Content: body, Content: body,
} }
res = append(res, parse(s, root)...) res = append(res, parse(s, root)...)