feat: add group title to video bundles

This commit is contained in:
Shashank S 2024-05-05 18:03:35 +02:00
parent e204029d3c
commit eb33adb7ae
2 changed files with 14 additions and 1 deletions

View file

@ -434,6 +434,7 @@ Preview:
| ---- | ---- | -------- | ------- |
| channels | array | yes | |
| limit | integer | no | 25 |
| group-title | string | no | VIDEOS |
| video-url-template | string | no | https://www.youtube.com/watch?v={VIDEO-ID} |
##### `channels`
@ -459,6 +460,13 @@ Placeholders:
`{VIDEO-ID}` - the ID of the video
##### `group-title`
Add a separate title for the group of videos in the widget, defaults to "VIDEOS". Useful when you have to group videos by categories. Example:
```yaml
group-title: "Reviews"
```
### Hacker News
Display a list of posts from [Hacker News](https://news.ycombinator.com/).

View file

@ -12,13 +12,18 @@ import (
type Videos struct {
widgetBase `yaml:",inline"`
Videos feed.Videos `yaml:"-"`
GroupTitle string `yaml:"group-title"`
VideoUrlTemplate string `yaml:"video-url-template"`
Channels []string `yaml:"channels"`
Limit int `yaml:"limit"`
}
func (widget *Videos) Initialize() error {
widget.withTitle("Videos").withCacheDuration(time.Hour)
if widget.GroupTitle == "" {
widget.GroupTitle = "VIDEOS"
}
widget.withTitle(widget.GroupTitle).withCacheDuration(time.Hour)
if widget.Limit <= 0 {
widget.Limit = 25