|
| 1 | + |
| 2 | + |
| 3 | +## Carousel Style |
| 4 | + |
| 5 | + |
| 6 | + |
| 7 | +```yaml |
| 8 | +- type: custom-api |
| 9 | + title: Seasonal Anime |
| 10 | + frameless: true |
| 11 | + cache: 1d |
| 12 | + url: https://api.jikan.moe/v4/seasons/now |
| 13 | + template: | |
| 14 | + {{ $arr := .JSON.Array "data" }} |
| 15 | + <div style="overflow-x: auto; padding: 8px 0;"> |
| 16 | + <div class="cards-horizontal carousel-items-container" style="display: flex; gap: 16px; padding: 0 8px;"> |
| 17 | + {{ range $i, $el := $arr }} |
| 18 | + {{ if lt $i 15 }} |
| 19 | + {{ $image := $el.String "images.jpg.image_url" }} |
| 20 | + {{ $score := $el.Float "score" }} |
| 21 | + {{ $type := $el.String "type" }} |
| 22 | + {{ $episodes := $el.Int "episodes" }} |
| 23 | + |
| 24 | + <a href="{{ $el.String "url" }}" target="_blank" |
| 25 | + class="card widget-content-frame" |
| 26 | + style="flex: 0 0 auto; width: 150px; min-height: 260px; display: flex; flex-direction: column; border-radius: 8px; overflow: hidden; box-shadow: 0 2px 12px rgba(0,0,0,0.1); background: var(--card-bg); text-decoration: none;"> |
| 27 | + |
| 28 | + <!-- Thumbnail with Score --> |
| 29 | + <div style="height: 190px; overflow: hidden; position: relative;"> |
| 30 | + <img src="{{ $image }}" alt="{{ $el.String "title" }}" |
| 31 | + style="width: 100%; height: 100%; object-fit: cover; object-position: center;" |
| 32 | + onerror="this.style.display='none'"> |
| 33 | + {{ if gt $score 0.0 }} |
| 34 | + <div style="position: absolute; top: 8px; right: 8px; background: rgba(0,0,0,0.9); color: white; padding: 3px 8px; border-radius: 12px; font-weight: bold; backdrop-filter: blur(4px); font-size: 11px;"> |
| 35 | + ⭐ {{ $score }} |
| 36 | + </div> |
| 37 | + {{ end }} |
| 38 | + </div> |
| 39 | + |
| 40 | + <!-- Content --> |
| 41 | + <div style="padding: 12px; flex-grow: 1; display: flex; flex-direction: column; justify-content: space-between; min-height: 70px;"> |
| 42 | + <div class="size-base color-primary" |
| 43 | + style="line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; min-height: 2.6em; margin-bottom: 8px;"> |
| 44 | + {{ $el.String "title" }} |
| 45 | + </div> |
| 46 | + |
| 47 | + <div class="size-h6" style="display: flex; flex-direction: column; gap: 4px;"> |
| 48 | + <div style="display: flex; align-items: center; gap: 6px;"> |
| 49 | + <span>Type:</span> |
| 50 | + <span>{{ $type }}</span> |
| 51 | + </div> |
| 52 | + <div style="display: flex; align-items: center; gap: 6px;"> |
| 53 | + <span>{{ if $episodes }}{{ $episodes }} Episodes{{ else }}Airing{{ end }}</span> |
| 54 | + </div> |
| 55 | + </div> |
| 56 | + </div> |
| 57 | + </a> |
| 58 | + {{ end }} |
| 59 | + {{ end }} |
| 60 | + </div> |
| 61 | + </div> |
| 62 | +``` |
| 63 | +## List Style |
| 64 | +
|
| 65 | + |
| 66 | +
|
| 67 | +```yaml |
| 68 | +- type: custom-api |
| 69 | + title: Seasonal Anime |
| 70 | + cache: 1d |
| 71 | + url: https://api.jikan.moe/v4/seasons/now |
| 72 | + options: |
| 73 | + max_items: 8 |
| 74 | + collapse_after: 5 |
| 75 | + template: | |
| 76 | + {{ $arr := .JSON.Array "data" }} |
| 77 | + {{ $maxItems := (index .Options "max_items") }} |
| 78 | + {{ $collapseAfter := (index .Options "collapse_after") }} |
| 79 | + {{ if not $maxItems }}{{ $maxItems = 25 }}{{ end }} |
| 80 | + |
| 81 | + <ul class="list list-gap-10 collapsible-container" data-collapse-after="{{ $collapseAfter }}" style="list-style: none; padding: 0; margin: 0;"> |
| 82 | + {{ range $i, $el := $arr }} |
| 83 | + {{ if lt $i $maxItems }} |
| 84 | + {{ $image := $el.String "images.jpg.image_url" }} |
| 85 | + {{ $type := $el.String "type" }} |
| 86 | + {{ $episodes := $el.Int "episodes" }} |
| 87 | + {{ $score := $el.Float "score" }} |
| 88 | + |
| 89 | + <a href="{{ $el.String "url" }}" target="_blank" style="text-decoration: none;"> |
| 90 | + <li style="padding: 10px 0; border-bottom: 1px solid var(--border-color);"> |
| 91 | + <div style="display: flex; gap: 12px; align-items: flex-start;"> |
| 92 | + |
| 93 | + <!-- Thumbnail --> |
| 94 | + <div style="flex-shrink: 0; width: 80px; height: 112px;"> |
| 95 | + <img src="{{ $image }}" alt="" |
| 96 | + style="width: 100%; height: 100%; object-fit: cover; border-radius: 4px;" |
| 97 | + onerror="this.style.display='none'"> |
| 98 | + </div> |
| 99 | + |
| 100 | + <!-- Content --> |
| 101 | + <div style="flex: 1; min-width: 0; display: flex; flex-direction: column; height: 112px; justify-content: space-between;"> |
| 102 | + |
| 103 | + <!-- Title --> |
| 104 | + <div class="size-base color-primary" |
| 105 | + style="line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; min-height: 2.6em; margin-bottom: 4px;"> |
| 106 | + {{ $el.String "title" }} |
| 107 | + </div> |
| 108 | + |
| 109 | + <!-- Metadata --> |
| 110 | + <div class="size-h6" style="display: flex; flex-direction: column; gap: 2px;"> |
| 111 | + <div style="display: flex; align-items: center; gap: 6px;"> |
| 112 | + <span>Type:</span> |
| 113 | + <span>{{ $type }}</span> |
| 114 | + </div> |
| 115 | + |
| 116 | + <div style="display: flex; align-items: center; gap: 6px;"> |
| 117 | + <span>Episode:</span> |
| 118 | + <span>{{ if $episodes }}{{ $episodes }}{{ else }}Airing{{ end }}</span> |
| 119 | + </div> |
| 120 | + |
| 121 | + <div style="display: flex; align-items: center; gap: 6px;"> |
| 122 | + <span>Rating:</span> |
| 123 | + <span>{{ if gt $score 0.0 }}{{ $score }}{{ else }}N/A{{ end }}</span> |
| 124 | + </div> |
| 125 | + </div> |
| 126 | + |
| 127 | + </div> |
| 128 | + </div> |
| 129 | + </li> |
| 130 | + </a> |
| 131 | + {{ end }} |
| 132 | + {{ end }} |
| 133 | + </ul> |
| 134 | +``` |
| 135 | +### Configuring: |
| 136 | +- `max_items`: set maximum amount of items to show when expanding list |
| 137 | +- `collapse_after`: collapse after `x` amount of anime |
| 138 | + |
| 139 | +### Notes |
| 140 | +- Ratings are only displayed when available (score > 0.0) |
| 141 | +- Episode count shows "Airing" for currently airing anime without final episode count |
| 142 | + |
| 143 | +## Credits |
| 144 | +These widgets use the [Jikan Api](https://jikan.moe/), an unofficial MyAnimelist API |
0 commit comments