diff --git a/pkg/parser/parser.go b/pkg/parser/parser.go index 354dde0..fa0f893 100644 --- a/pkg/parser/parser.go +++ b/pkg/parser/parser.go @@ -7,6 +7,7 @@ import ( "log" "os" "path/filepath" + "reflect" "regexp" "strings" "time" @@ -36,18 +37,19 @@ type LayoutConfig struct { } type Frontmatter struct { - Title string `yaml:"title"` - Date string `yaml:"date"` - Draft bool `yaml:"draft"` - JSFiles []string `yaml:"scripts"` - Type string `yaml:"type"` - Description string `yaml:"description"` - PreviewImage string `yaml:"previewimage"` - Tags []string `yaml:"tags"` - TOC bool `yaml:"toc"` - Authors []string `yaml:"authors"` - Collections []string `yaml:"collections"` - Layout string `yaml:"layout"` + Title string `yaml:"title"` + Date string `yaml:"date"` + Draft bool `yaml:"draft"` + JSFiles []string `yaml:"scripts"` + Type string `yaml:"type"` + Description string `yaml:"description"` + PreviewImage string `yaml:"previewimage"` + Tags []string `yaml:"tags"` + TOC bool `yaml:"toc"` + Authors []string `yaml:"authors"` + Collections []string `yaml:"collections"` + Layout string `yaml:"layout"` + CustomFields []map[string]string `yaml:"customFields"` // Head is specifically used for // mentioning the head of the notes @@ -400,7 +402,15 @@ func (p *Parser) collectionsParser(page TemplateData) { } collectionKey += ".html" - p.CollectionsMap[template.URL(collectionKey)] = append(p.CollectionsMap[template.URL(collectionKey)], page) + var found bool + for _, map_page := range p.CollectionsMap[template.URL(collectionKey)] { + if reflect.DeepEqual(map_page, page) { + found = true + } + } + if !found { + p.CollectionsMap[template.URL(collectionKey)] = append(p.CollectionsMap[template.URL(collectionKey)], page) + } } } diff --git a/site/layout/all-posts.html b/site/layout/all-posts.html index 4dd5096..c431e9d 100644 --- a/site/layout/all-posts.html +++ b/site/layout/all-posts.html @@ -8,7 +8,7 @@
{{range $Post := index .DeepDataMerge.CollectionsMap .PageURL}} - +

{{$Post.Frontmatter.Title}}

{{$Post.Frontmatter.Description}}

diff --git a/test/engine/json_index_test/want_index.json b/test/engine/json_index_test/want_index.json index ce1dea5..2cadee5 100644 --- a/test/engine/json_index_test/want_index.json +++ b/test/engine/json_index_test/want_index.json @@ -1 +1 @@ -{"docs.md":{"CompleteURL":"docs.html","Frontmatter":{"Title":"Anna Documentation","Date":"","Draft":false,"JSFiles":null,"Type":"","Description":"","PreviewImage":"","Tags":null,"TOC":false,"Authors":null,"Collections":null,"Layout":"","Head":false},"Tags":null}} \ No newline at end of file +{"docs.md":{"CompleteURL":"docs.html","Frontmatter":{"Title":"Anna Documentation","Date":"","Draft":false,"JSFiles":null,"Type":"","Description":"","PreviewImage":"","Tags":null,"TOC":false,"Authors":null,"Collections":null,"Layout":"","CustomFields":null,"Head":false},"Tags":null}} \ No newline at end of file