diff options
| author | Christine Dodrill <me@christine.website> | 2019-09-12 18:49:03 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-09-12 18:49:03 -0400 |
| commit | 7a302eb69bfef1ecd0a17e16085bd4359a0ae717 (patch) | |
| tree | fc6d777b3c4f2af57951f0921de8a334ad4cfee8 /internal | |
| parent | 2007492c492be3c32b19fbfcc6b6c1a5cc5ef0e0 (diff) | |
| download | xesite-7a302eb69bfef1ecd0a17e16085bd4359a0ae717.tar.xz xesite-7a302eb69bfef1ecd0a17e16085bd4359a0ae717.zip | |
Series and tags (#74)
* initial support for tags and series
* tagging support
* oops
* Update main.go
Diffstat (limited to 'internal')
| -rw-r--r-- | internal/blog/blog.go | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/internal/blog/blog.go b/internal/blog/blog.go index eac5d64..7d4f93c 100644 --- a/internal/blog/blog.go +++ b/internal/blog/blog.go @@ -20,6 +20,8 @@ type Post struct { Summary string `json:"summary,omitifempty"` Body string `json:"-"` BodyHTML template.HTML `json:"body"` + Series string `json:"series"` + Tags []string `json:"tags"` SlidesLink string `json:"slides_link"` Date time.Time DateString string `json:"date"` @@ -28,6 +30,24 @@ type Post struct { // Posts implements sort.Interface for a slice of Post objects. type Posts []Post +func (p Posts) Series() []string { + names := map[string]struct{}{} + + for _, ps := range p { + if ps.Series != "" { + names[ps.Series] = struct{}{} + } + } + + var result []string + + for name := range names { + result = append(result, name) + } + + return result +} + func (p Posts) Len() int { return len(p) } func (p Posts) Less(i, j int) bool { iDate := p[i].Date @@ -42,6 +62,8 @@ func LoadPosts(path string, prepend string) (Posts, error) { type postFM struct { Title string Date string + Series string + Tags []string SlidesLink string `yaml:"slides_link"` } var result Posts @@ -91,6 +113,8 @@ func LoadPosts(path string, prepend string) (Posts, error) { Body: string(remaining), BodyHTML: template.HTML(output), SlidesLink: fm.SlidesLink, + Series: fm.Series, + Tags: fm.Tags, } result = append(result, p) |
