<meta charset="<%= @options.charset %>">
<meta name="viewport" content="width=device-width, initial-scale=1">

<title><%= h @title %></title>

<%- if defined?(klass) %>
  <meta
    name="keywords"
    content="ruby,<%= h "#{klass.type},#{klass.full_name}" %>"
  >
  <%- if klass.comment.empty? %>
    <meta
      name="description"
      content="Documentation for the <%= h "#{klass.full_name} #{klass.type}" %>"
    >
  <%- else %>
    <meta
      name="description"
      content="<%= h "#{klass.type} #{klass.full_name}: #{excerpt(klass.comment)}" %>"
    >
  <%- end %>
<%- elsif defined?(file) %>
  <meta name="keywords" content="ruby,documentation,<%= h file.page_name %>">
  <meta
    name="description"
    content="<%= h "#{file.page_name}: #{excerpt(file.comment)}" %>"
  >
<%- elsif @title %>
  <meta name="keywords" content="ruby,documentation,<%= h @title %>">
  <%- if @options.main_page and
      main_page = @files.find { |f| f.full_name == @options.main_page } %>
    <meta
      name="description"
      content="<%= h "#{@title}: #{excerpt(main_page.comment)}" %>"
    >
  <%- else %>
    <meta name="description" content="Documentation for <%= h @title %>">
  <%- end %>
<%- end %>

<%- if canonical_url = @options.canonical_root %>
  <% canonical_url = current.canonical_url if defined?(current) %>
  <link rel="canonical" href="<%= canonical_url %>">
<%- end %>

<!-- Open Graph / Facebook -->
<meta property="og:type" content="website">
<meta property="og:title" content="<%= h @title %>">

<%- if defined?(klass) %>
  <%- if klass.comment.empty? %>
    <meta
      property="og:description"
      content="Documentation for <%= h klass.full_name %> <%= h klass.type %> - API reference and code examples"
    >
  <%- else %>
    <meta property="og:description" content="<%= h excerpt(klass.comment) %>">
  <%- end %>
<%- elsif defined?(file) %>
  <%- if file.comment.empty? %>
    <meta
      property="og:description"
      content="<%= h file.page_name %> - <%= h @title %> documentation"
    >
  <%- else %>
    <meta property="og:description" content="<%= h excerpt(file.comment) %>">
  <%- end %>
<%- else %>
  <meta
    property="og:description"
    content="API documentation for <%= h @title %> - Browse classes, modules, and methods"
  >
<%- end %>

<%- if canonical_url = @options.canonical_root %>
  <% canonical_url = current.canonical_url if defined?(current) %>
  <meta property="og:url" content="<%= canonical_url %>">
<%- end %>

<!-- Twitter -->
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="<%= h @title %>">

<%- if defined?(klass) %>
  <%- if klass.comment.empty? %>
    <meta
      name="twitter:description"
      content="Documentation for <%= h klass.full_name %> <%= h klass.type %> - API reference and code examples"
    >
  <%- else %>
    <meta name="twitter:description" content="<%= h excerpt(klass.comment) %>">
  <%- end %>
<%- elsif defined?(file) %>
  <%- if file.comment.empty? %>
    <meta
      name="twitter:description"
      content="<%= h file.page_name %> - <%= h @title %> documentation"
    >
  <%- else %>
    <meta name="twitter:description" content="<%= h excerpt(file.comment) %>">
  <%- end %>
<%- else %>
  <meta
    name="twitter:description"
    content="API documentation for <%= h @title %> - Browse classes, modules, and methods"
  >
<%- end %>

<script type="text/javascript">
  var rdoc_rel_prefix = "<%= h asset_rel_prefix %>/";
  var index_rel_prefix = "<%= h rel_prefix %>/";
</script>

<script
  src="<%= h asset_rel_prefix %>/js/theme-toggle.js?v=<%= h RDoc::VERSION %>"
></script>

<script
  src="<%= h asset_rel_prefix %>/js/search_navigation.js?v=<%= h RDoc::VERSION %>"
  defer
></script>

<script
  src="<%= h asset_rel_prefix %>/js/search_data.js?v=<%= h RDoc::VERSION %>"
  defer
></script>

<script
  src="<%= h asset_rel_prefix %>/js/search_ranker.js?v=<%= h RDoc::VERSION %>"
  defer
></script>

<script
  src="<%= h asset_rel_prefix %>/js/search_controller.js?v=<%= h RDoc::VERSION %>"
  defer
></script>

<script
  src="<%= h asset_rel_prefix %>/js/c_highlighter.js?v=<%= h RDoc::VERSION %>"
  defer
></script>

<script
  src="<%= h asset_rel_prefix %>/js/aliki.js?v=<%= h RDoc::VERSION %>"
  defer
></script>

<link
  href="<%= h asset_rel_prefix %>/css/rdoc.css?v=<%= h RDoc::VERSION %>"
  rel="stylesheet"
>

<%- @options.template_stylesheets.each do |stylesheet| %>
  <link
    href="<%= h asset_rel_prefix %>/<%= h File.basename stylesheet %>?v=<%= h RDoc::VERSION %>"
    rel="stylesheet"
  >
<%- end %>
