<%-
  ucid = channel.ucid
  author = HTML.escape(channel.author)
  channel_profile_pic = URI.parse(channel.author_thumbnail).request_target

  relative_url =
    case selected_tab
    when .shorts?    then "/channel/#{ucid}/shorts"
    when .streams?   then "/channel/#{ucid}/streams"
    when .playlists? then "/channel/#{ucid}/playlists"
    when .channels?  then "/channel/#{ucid}/channels"
    else
      "/channel/#{ucid}"
    end

  youtube_url = "https://www.youtube.com#{relative_url}"
  redirect_url = Invidious::Frontend::Misc.redirect_url(env)
-%>

<% content_for "header" do %>
<%- if selected_tab.videos? -%>
<meta name="description" content="<%= channel.description %>">
<meta property="og:site_name" content="Invidious">
<meta property="og:url" content="<%= HOST_URL %>/channel/<%= ucid %>">
<meta property="og:title" content="<%= author %>">
<meta property="og:image" content="/ggpht<%= channel_profile_pic %>">
<meta property="og:description" content="<%= channel.description %>">
<meta name="twitter:card" content="summary">
<meta name="twitter:url" content="<%= HOST_URL %>/channel/<%= ucid %>">
<meta name="twitter:title" content="<%= author %>">
<meta name="twitter:description" content="<%= channel.description %>">
<meta name="twitter:image" content="/ggpht<%= channel_profile_pic %>">
<link rel="alternate" type="application/rss+xml" title="RSS" href="/feed/channel/<%= ucid %>" />
<%- end -%>

<link rel="alternate" href="<%= youtube_url %>">
<title><%= author %> - Invidious</title>
<% end %>

<%= rendered "components/channel_info" %>

<div class="h-box">
    <hr>
</div>

<div class="pure-g">
<% items.each do |item| %>
    <%= rendered "components/item" %>
<% end %>
</div>

<script src="/js/watched_indicator.js"></script>

<div class="pure-g h-box">
    <div class="pure-u-1 pure-u-md-4-5"></div>
    <div class="pure-u-1 pure-u-lg-1-5" style="text-align:right">
        <% if next_continuation %>
            <a href="<%= relative_url %>?continuation=<%= next_continuation %><% if sort_options.any? sort_by %>&sort_by=<%= sort_by %><% end %>">
                <%= translate(locale, "Next page") %>
            </a>
        <% end %>
    </div>
</div>
