Kaynağa Gözat

feat: add group title to video bundles

Shashank S 1 yıl önce
ebeveyn
işleme
eb33adb7ae
2 değiştirilmiş dosya ile 14 ekleme ve 1 silme
  1. 8 0
      docs/configuration.md
  2. 6 1
      internal/widget/videos.go

+ 8 - 0
docs/configuration.md

@@ -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/).
 

+ 6 - 1
internal/widget/videos.go

@@ -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