Add horizontal-cards-2 style for RSS widget

This commit is contained in:
Svilen Markov
2024-05-10 10:10:13 +01:00
parent 57414bdb67
commit 7dd1cca65d
7 changed files with 86 additions and 3 deletions

View File

@@ -14,6 +14,7 @@ type RSS struct {
FeedRequests []feed.RSSFeedRequest `yaml:"feeds"`
Style string `yaml:"style"`
ThumbnailHeight float64 `yaml:"thumbnail-height"`
CardHeight float64 `yaml:"card-height"`
Items feed.RSSFeedItems `yaml:"-"`
Limit int `yaml:"limit"`
CollapseAfter int `yaml:"collapse-after"`
@@ -34,6 +35,10 @@ func (widget *RSS) Initialize() error {
widget.ThumbnailHeight = 0
}
if widget.CardHeight < 0 {
widget.CardHeight = 0
}
return nil
}
@@ -53,7 +58,11 @@ func (widget *RSS) Update(ctx context.Context) {
func (widget *RSS) Render() template.HTML {
if widget.Style == "horizontal-cards" {
return widget.render(widget, assets.RSSCardsTemplate)
return widget.render(widget, assets.RSSHorizontalCardsTemplate)
}
if widget.Style == "horizontal-cards-2" {
return widget.render(widget, assets.RSSHorizontalCards2Template)
}
return widget.render(widget, assets.RSSListTemplate)