ソースを参照

feat: added title-line-limit for horizontal-cards style

ralphocdol 10 ヶ月 前
コミット
b4d49ecf34

+ 10 - 9
docs/configuration.md

@@ -465,15 +465,16 @@ Example:
 ```
 
 #### Properties
-| Name | Type | Required | Default |
-| ---- | ---- | -------- | ------- |
-| style | string | no | vertical-list |
-| feeds | array | yes |
-| thumbnail-height | float | no | 10 |
-| card-height | float | no | 27 |
-| limit | integer | no | 25 |
-| single-line-titles | boolean | no | false |
-| collapse-after | integer | no | 5 |
+| Name | Type | Required | Default | Note
+| ---- | ---- | -------- | ------- | ------- |
+| style | string | no | vertical-list | |
+| feeds | array | yes | |
+| thumbnail-height | float | no | 10 | |
+| card-height | float | no | 27 | |
+| limit | integer | no | 25 | |
+| single-line-titles | boolean | no | false | |
+| collapse-after | integer | no | 5 | |
+| title-line-limit | integer | no | 3 | Only applicable for `horizontal-cards` style. Max is 3 |
 
 ##### `style`
 Used to change the appearance of the widget. Possible values are:

+ 2 - 1
internal/assets/templates/rss-horizontal-cards.html

@@ -16,7 +16,8 @@
             </svg>
             {{ end }}
             <div class="margin-bottom-widget padding-inline-widget flex flex-column grow">
-                <a href="{{ .Link }}" title="{{ .Title }}" class="text-truncate-3-lines color-primary-if-not-visited margin-top-10 margin-bottom-auto" target="_blank" rel="noreferrer">{{ .Title }}</a>
+                <a href="{{ .Link }}" title="{{ .Title }}" 
+                    class="{{ if eq $.TitleLineLimit 1 }}text-truncate{{ else }}text-truncate-{{ $.TitleLineLimit }}-lines{{ end }} color-primary-if-not-visited margin-top-10 margin-bottom-auto" target="_blank" rel="noreferrer">{{ .Title }}</a>
                 <ul class="list-horizontal-text flex-nowrap margin-top-7">
                     <li class="shrink-0" {{ dynamicRelativeTimeAttrs .PublishedAt }}></li>
                     <li class="min-width-0 text-truncate">{{ .ChannelName }}</li>

+ 5 - 0
internal/widget/rss.go

@@ -15,6 +15,7 @@ type RSS struct {
 	Style            string                `yaml:"style"`
 	ThumbnailHeight  float64               `yaml:"thumbnail-height"`
 	CardHeight       float64               `yaml:"card-height"`
+	TitleLineLimit   int                   `yaml:"title-line-limit"`
 	Items            feed.RSSFeedItems     `yaml:"-"`
 	Limit            int                   `yaml:"limit"`
 	CollapseAfter    int                   `yaml:"collapse-after"`
@@ -41,6 +42,10 @@ func (widget *RSS) Initialize() error {
 		widget.CardHeight = 0
 	}
 
+	if widget.TitleLineLimit <= 0 || widget.TitleLineLimit > 3 {
+		widget.TitleLineLimit = 3
+	}
+
 	if widget.Style == "detailed-list" {
 		for i := range widget.FeedRequests {
 			widget.FeedRequests[i].IsDetailed = true