mirror of
https://github.com/svemagie/indiekit-endpoint-youtube.git
synced 2026-04-02 15:54:59 +02:00
The Indiekit backend UI was broken when using channels array because the dashboard controller only checked for channelId/channelHandle. Now uses getPrimaryChannel() helper to extract the first channel from either single-channel or multi-channel configuration. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
282 lines
7.6 KiB
Plaintext
282 lines
7.6 KiB
Plaintext
{% extends "document.njk" %}
|
|
|
|
{% block content %}
|
|
<style>
|
|
.yt-section { margin-bottom: 2rem; }
|
|
.yt-section h2 { margin-bottom: 1rem; }
|
|
|
|
/* Channel header */
|
|
.yt-channel {
|
|
display: flex;
|
|
gap: 1rem;
|
|
padding: 1rem;
|
|
background: var(--color-offset, #f5f5f5);
|
|
border-radius: 0.5rem;
|
|
align-items: center;
|
|
margin-bottom: 1.5rem;
|
|
}
|
|
.yt-channel__avatar {
|
|
width: 64px;
|
|
height: 64px;
|
|
border-radius: 50%;
|
|
object-fit: cover;
|
|
flex-shrink: 0;
|
|
}
|
|
.yt-channel__info { flex: 1; }
|
|
.yt-channel__name {
|
|
font-weight: 600;
|
|
font-size: 1.125rem;
|
|
margin: 0 0 0.25rem 0;
|
|
}
|
|
.yt-channel__stats {
|
|
display: flex;
|
|
gap: 1rem;
|
|
font-size: 0.875rem;
|
|
color: var(--color-text-secondary, #666);
|
|
}
|
|
|
|
/* Live status badge */
|
|
.yt-live-badge {
|
|
display: inline-flex;
|
|
align-items: center;
|
|
gap: 0.5rem;
|
|
padding: 0.25rem 0.75rem;
|
|
border-radius: 2rem;
|
|
font-size: 0.75rem;
|
|
font-weight: 600;
|
|
text-transform: uppercase;
|
|
}
|
|
.yt-live-badge--live {
|
|
background: #ff0000;
|
|
color: white;
|
|
animation: yt-pulse 2s infinite;
|
|
}
|
|
.yt-live-badge--upcoming {
|
|
background: #065fd4;
|
|
color: white;
|
|
}
|
|
.yt-live-badge--offline {
|
|
background: var(--color-offset, #e5e5e5);
|
|
color: var(--color-text-secondary, #666);
|
|
}
|
|
@keyframes yt-pulse {
|
|
0%, 100% { opacity: 1; }
|
|
50% { opacity: 0.7; }
|
|
}
|
|
.yt-live-dot {
|
|
width: 8px;
|
|
height: 8px;
|
|
border-radius: 50%;
|
|
background: currentColor;
|
|
}
|
|
|
|
/* Live stream card */
|
|
.yt-live-stream {
|
|
display: flex;
|
|
gap: 1rem;
|
|
padding: 1rem;
|
|
background: linear-gradient(135deg, #ff000010, #ff000005);
|
|
border: 1px solid #ff000030;
|
|
border-radius: 0.5rem;
|
|
margin-bottom: 1.5rem;
|
|
}
|
|
.yt-live-stream__thumb {
|
|
width: 160px;
|
|
height: 90px;
|
|
object-fit: cover;
|
|
border-radius: 0.25rem;
|
|
flex-shrink: 0;
|
|
}
|
|
.yt-live-stream__info { flex: 1; }
|
|
.yt-live-stream__title {
|
|
font-weight: 600;
|
|
margin: 0 0 0.5rem 0;
|
|
}
|
|
.yt-live-stream__title a {
|
|
color: inherit;
|
|
text-decoration: none;
|
|
}
|
|
.yt-live-stream__title a:hover { text-decoration: underline; }
|
|
|
|
/* Video grid */
|
|
.yt-video-grid {
|
|
display: grid;
|
|
grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
|
|
gap: 1rem;
|
|
list-style: none;
|
|
padding: 0;
|
|
margin: 0;
|
|
}
|
|
.yt-video {
|
|
display: flex;
|
|
flex-direction: column;
|
|
background: var(--color-offset, #f5f5f5);
|
|
border-radius: 0.5rem;
|
|
overflow: hidden;
|
|
}
|
|
.yt-video__thumb-wrapper {
|
|
position: relative;
|
|
aspect-ratio: 16/9;
|
|
}
|
|
.yt-video__thumb {
|
|
width: 100%;
|
|
height: 100%;
|
|
object-fit: cover;
|
|
}
|
|
.yt-video__duration {
|
|
position: absolute;
|
|
bottom: 0.5rem;
|
|
right: 0.5rem;
|
|
background: rgba(0, 0, 0, 0.8);
|
|
color: white;
|
|
padding: 0.125rem 0.375rem;
|
|
border-radius: 0.25rem;
|
|
font-size: 0.75rem;
|
|
font-weight: 500;
|
|
}
|
|
.yt-video__info {
|
|
padding: 0.75rem;
|
|
flex: 1;
|
|
display: flex;
|
|
flex-direction: column;
|
|
}
|
|
.yt-video__title {
|
|
font-weight: 500;
|
|
font-size: 0.875rem;
|
|
margin: 0 0 0.5rem 0;
|
|
display: -webkit-box;
|
|
-webkit-line-clamp: 2;
|
|
-webkit-box-orient: vertical;
|
|
overflow: hidden;
|
|
}
|
|
.yt-video__title a {
|
|
color: inherit;
|
|
text-decoration: none;
|
|
}
|
|
.yt-video__title a:hover { text-decoration: underline; }
|
|
.yt-video__meta {
|
|
font-size: 0.75rem;
|
|
color: var(--color-text-secondary, #666);
|
|
margin-top: auto;
|
|
}
|
|
|
|
/* Public link banner */
|
|
.yt-public-link {
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: space-between;
|
|
padding: 1rem;
|
|
background: var(--color-offset, #f5f5f5);
|
|
border-radius: 0.5rem;
|
|
margin-top: 2rem;
|
|
}
|
|
.yt-public-link p {
|
|
margin: 0;
|
|
color: var(--color-text-secondary, #666);
|
|
}
|
|
</style>
|
|
|
|
{% if error %}
|
|
{{ prose({ text: error.message }) }}
|
|
{% else %}
|
|
{# Channel Header #}
|
|
{% if channel %}
|
|
<div class="yt-channel">
|
|
{% if channel.thumbnail %}
|
|
<img src="{{ channel.thumbnail }}" alt="" class="yt-channel__avatar">
|
|
{% endif %}
|
|
<div class="yt-channel__info">
|
|
<h2 class="yt-channel__name">{{ channel.title }}</h2>
|
|
<div class="yt-channel__stats">
|
|
<span>{{ channel.subscriberCount }} {{ __("youtube.subscribers") }}</span>
|
|
<span>{{ channel.videoCount }} videos</span>
|
|
</div>
|
|
</div>
|
|
{% if isLive %}
|
|
<span class="yt-live-badge yt-live-badge--live">
|
|
<span class="yt-live-dot"></span>
|
|
{{ __("youtube.live") }}
|
|
</span>
|
|
{% elif isUpcoming %}
|
|
<span class="yt-live-badge yt-live-badge--upcoming">
|
|
{{ __("youtube.upcoming") }}
|
|
</span>
|
|
{% else %}
|
|
<span class="yt-live-badge yt-live-badge--offline">
|
|
{{ __("youtube.offline") }}
|
|
</span>
|
|
{% endif %}
|
|
</div>
|
|
{% endif %}
|
|
|
|
{# Live Stream (if live) #}
|
|
{% if liveStatus and (liveStatus.isLive or liveStatus.isUpcoming) %}
|
|
<section class="yt-section">
|
|
<h2>{% if liveStatus.isLive %}{{ __("youtube.live") }}{% else %}{{ __("youtube.upcoming") }}{% endif %}</h2>
|
|
<div class="yt-live-stream">
|
|
{% if liveStatus.thumbnail %}
|
|
<img src="{{ liveStatus.thumbnail }}" alt="" class="yt-live-stream__thumb">
|
|
{% endif %}
|
|
<div class="yt-live-stream__info">
|
|
<h3 class="yt-live-stream__title">
|
|
<a href="https://www.youtube.com/watch?v={{ liveStatus.videoId }}" target="_blank" rel="noopener">
|
|
{{ liveStatus.title }}
|
|
</a>
|
|
</h3>
|
|
{{ button({
|
|
href: "https://www.youtube.com/watch?v=" + liveStatus.videoId,
|
|
text: __("youtube.watchNow"),
|
|
target: "_blank"
|
|
}) }}
|
|
</div>
|
|
</div>
|
|
</section>
|
|
{% endif %}
|
|
|
|
{# Latest Videos #}
|
|
<section class="yt-section">
|
|
<h2>{{ __("youtube.videos") }}</h2>
|
|
{% if videos and videos.length > 0 %}
|
|
<ul class="yt-video-grid">
|
|
{% for video in videos %}
|
|
<li class="yt-video">
|
|
<div class="yt-video__thumb-wrapper">
|
|
<a href="{{ video.url }}" target="_blank" rel="noopener">
|
|
<img src="{{ video.thumbnail }}" alt="" class="yt-video__thumb" loading="lazy">
|
|
</a>
|
|
{% if video.durationFormatted and not video.isLive %}
|
|
<span class="yt-video__duration">{{ video.durationFormatted }}</span>
|
|
{% elif video.isLive %}
|
|
<span class="yt-video__duration" style="background:#ff0000">LIVE</span>
|
|
{% endif %}
|
|
</div>
|
|
<div class="yt-video__info">
|
|
<h3 class="yt-video__title">
|
|
<a href="{{ video.url }}" target="_blank" rel="noopener">{{ video.title }}</a>
|
|
</h3>
|
|
<div class="yt-video__meta">
|
|
{{ video.viewCount }} {{ __("youtube.views") }}
|
|
</div>
|
|
</div>
|
|
</li>
|
|
{% endfor %}
|
|
</ul>
|
|
{% else %}
|
|
{{ prose({ text: __("youtube.noVideos") }) }}
|
|
{% endif %}
|
|
</section>
|
|
|
|
{# Link to YouTube channel #}
|
|
{% if channel %}
|
|
<div class="yt-public-link">
|
|
<p>{{ __("youtube.widget.description") }}</p>
|
|
{{ button({
|
|
href: "https://www.youtube.com/channel/" + channel.id,
|
|
text: __("youtube.widget.view"),
|
|
target: "_blank"
|
|
}) }}
|
|
</div>
|
|
{% endif %}
|
|
{% endif %}
|
|
{% endblock %}
|