<% var _externalUrl = (lecture.type === "link" || lecture.type === "news") && (lecture.newsUrl || "").trim(); %>
<article class="lecture-card">
  <% if (_externalUrl) { %>
  <a class="lecture-link lecture-link-external" href="<%= _externalUrl %>" target="_blank" rel="noopener noreferrer">
  <% } else { %>
  <a class="lecture-link" href="/lectures/<%= lecture.id %>">
  <% } %>
    <div class="thumb <%= lecture.type %>">
      <% if (lecture.type === "ppt") { %>
      <% if (lecture.thumbnailUrl) { %>
      <img src="<%= lecture.thumbnailUrl %>" alt="<%= lecture.title %> 썸네일" class="thumb-image" />
      <% } else { %>
      <span class="thumb-fallback">썸네일 <%= lecture.thumbnailStatus || "pending" %></span>
      <% } %>
      <span class="thumb-kicker">PPT 프리뷰</span>
      <% if (lecture.previewTitle && lecture.previewTitle !== "제목 없음") { %><strong><%= lecture.previewTitle %></strong><% } %>
      <% } else if (lecture.type === "news") { %>
      <% if (lecture.thumbnailUrl) { %>
      <img src="<%= lecture.thumbnailUrl %>" alt="" class="thumb-image thumb-image-og" loading="lazy" referrerpolicy="no-referrer" />
      <% } %>
      <span class="thumb-kicker">뉴스</span>
      <% if (!lecture.thumbnailUrl) { %><strong>외부 링크</strong><% } %>
      <% } else if (lecture.type === "link") { %>
      <% if (lecture.thumbnailUrl) { %>
      <img src="<%= lecture.thumbnailUrl %>" alt="" class="thumb-image thumb-image-og" loading="lazy" referrerpolicy="no-referrer" />
      <% } %>
      <span class="thumb-kicker">웹 링크</span>
      <% if (!lecture.thumbnailUrl) { %><strong>외부 페이지</strong><% } %>
      <% } else if (lecture.type === "video") { %>
      <% if (lecture.thumbnailUrl) { %>
      <img src="<%= lecture.thumbnailUrl %>" alt="<%= lecture.title %> 썸네일" class="thumb-image" />
      <% } else { %>
      <span class="thumb-fallback">썸네일 <%= lecture.thumbnailStatus || "pending" %></span>
      <% } %>
      <span class="thumb-kicker">동영상 파일</span>
      <% if (!lecture.thumbnailUrl) { %><strong>업로드 영상</strong><% } %>
      <% } else { %>
      <% const ytThumb = typeof getYoutubeThumbnailUrl === 'function' ? getYoutubeThumbnailUrl(lecture.youtubeUrl) : null; %>
      <% if (ytThumb) { %>
      <img src="<%= ytThumb %>" alt="<%= lecture.title %> 썸네일" class="thumb-image thumb-image-youtube" />
      <% } %>
      <span class="thumb-kicker">YouTube</span>
      <strong>영상 강의</strong>
      <% } %>
    </div>
    <div class="badge <%= lecture.type %>">
      <% if (lecture.type === "youtube") { %>YouTube<% } else if (lecture.type === "news") { %>뉴스<% } else if (lecture.type === "link") { %>링크<% } else if (lecture.type === "video") { %>동영상<% } else { %>PPT<% } %>
    </div>
    <h3><%= lecture.title %></h3>
    <p><%= lecture.description || "설명이 없습니다." %></p>
    <div class="tag-row">
      <% (lecture.tags || []).forEach((oneTag) => { %>
      <span class="tag-chip">#<%= oneTag %></span>
      <% }) %>
    </div>
    <small><%= new Date(lecture.createdAt).toLocaleString("ko-KR") %></small>
  </a>
</article>
