fix: fixed post templates in go
f45a18ba
1 file(s) · +10 −10
| 44 | 44 | UpdatedAt string |
|
| 45 | 45 | } |
|
| 46 | 46 | ||
| 47 | - | func (p *Post) DisplayTitle() string { |
|
| 47 | + | func (p Post) DisplayTitle() string { |
|
| 48 | 48 | if p.Title != nil { |
|
| 49 | 49 | if t := strings.TrimSpace(*p.Title); t != "" { |
|
| 50 | 50 | return t |
|
| 66 | 66 | return snip |
|
| 67 | 67 | } |
|
| 68 | 68 | ||
| 69 | - | func (p *Post) TitleStr() string { |
|
| 69 | + | func (p Post) TitleStr() string { |
|
| 70 | 70 | if p.Title != nil { |
|
| 71 | 71 | return *p.Title |
|
| 72 | 72 | } |
|
| 73 | 73 | return "" |
|
| 74 | 74 | } |
|
| 75 | 75 | ||
| 76 | - | func (p *Post) HasTitle() bool { |
|
| 76 | + | func (p Post) HasTitle() bool { |
|
| 77 | 77 | return p.Title != nil && strings.TrimSpace(*p.Title) != "" |
|
| 78 | 78 | } |
|
| 79 | 79 | ||
| 80 | - | func (p *Post) PublishedDateStr() string { |
|
| 80 | + | func (p Post) PublishedDateStr() string { |
|
| 81 | 81 | if p.PublishedDate != nil { |
|
| 82 | 82 | return *p.PublishedDate |
|
| 83 | 83 | } |
|
| 84 | 84 | return "" |
|
| 85 | 85 | } |
|
| 86 | 86 | ||
| 87 | - | func (p *Post) AliasStr() string { |
|
| 87 | + | func (p Post) AliasStr() string { |
|
| 88 | 88 | if p.Alias != nil { |
|
| 89 | 89 | return *p.Alias |
|
| 90 | 90 | } |
|
| 91 | 91 | return "" |
|
| 92 | 92 | } |
|
| 93 | 93 | ||
| 94 | - | func (p *Post) MetaDescriptionStr() string { |
|
| 94 | + | func (p Post) MetaDescriptionStr() string { |
|
| 95 | 95 | if p.MetaDescription != nil { |
|
| 96 | 96 | return *p.MetaDescription |
|
| 97 | 97 | } |
|
| 98 | 98 | return "" |
|
| 99 | 99 | } |
|
| 100 | 100 | ||
| 101 | - | func (p *Post) MetaImageStr() string { |
|
| 101 | + | func (p Post) MetaImageStr() string { |
|
| 102 | 102 | if p.MetaImage != nil { |
|
| 103 | 103 | return *p.MetaImage |
|
| 104 | 104 | } |
|
| 105 | 105 | return "" |
|
| 106 | 106 | } |
|
| 107 | 107 | ||
| 108 | - | func (p *Post) CanonicalURLStr() string { |
|
| 108 | + | func (p Post) CanonicalURLStr() string { |
|
| 109 | 109 | if p.CanonicalURL != nil { |
|
| 110 | 110 | return *p.CanonicalURL |
|
| 111 | 111 | } |
|
| 112 | 112 | return "" |
|
| 113 | 113 | } |
|
| 114 | 114 | ||
| 115 | - | func (p *Post) TagsStr() string { |
|
| 115 | + | func (p Post) TagsStr() string { |
|
| 116 | 116 | if p.Tags != nil { |
|
| 117 | 117 | return *p.Tags |
|
| 118 | 118 | } |
|
| 119 | 119 | return "" |
|
| 120 | 120 | } |
|
| 121 | 121 | ||
| 122 | - | func (p *Post) TagList() []string { |
|
| 122 | + | func (p Post) TagList() []string { |
|
| 123 | 123 | if p.Tags == nil { |
|
| 124 | 124 | return nil |
|
| 125 | 125 | } |
|