<meta charset="utf-8" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<% desc = "#{SiteSetting['SiteName']} on Codidact - open, community-run Q&A knowledge sharing" %>
<meta name="description" content="<%= content_for?(:description) ? content_for(:description) : desc %>" />

<% page_title = (Rails.env.development? ? '[DEV] ' : '') +
                SiteSetting['SiteName'].to_s +
                (content_for?(:title) ? ' - ' + CGI.unescapeHTML(content_for(:title)) : '') %>
<title>
  <%= page_title %>
</title>

<% icon_path = SiteSetting['IconPath'] %>
<link rel="icon" href="<%= icon_path.present? ? icon_path : '/assets/favicon.ico' %>" />

<%= stylesheet_link_tag "https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.11.2/css/all.min.css" %>
<%= stylesheet_link_tag "https://unpkg.com/@codidact/co-design@0.12.0/dist/codidact.css" %>
<%= stylesheet_link_tag "https://cdn.jsdelivr.net/npm/select2@4.0.12/dist/css/select2.min.css" %>
<%= stylesheet_link_tag "/assets/community/#{@community.host.split('.')[0]}.css" %>
<%= stylesheet_link_tag 'application', media: 'all' %>

<%= javascript_include_tag "https://code.jquery.com/jquery-2.2.2.min.js" %>
<%= javascript_include_tag "https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.13.0/moment.min.js" %>
<%= javascript_include_tag "https://cdn.jsdelivr.net/npm/select2@4.0.12/dist/js/select2.min.js" %>
<%= javascript_include_tag "/assets/community/#{@community.host.split('.')[0]}.js" %>
<%= javascript_include_tag 'application' %>
<script src="https://unpkg.com/@codidact/co-design@0.12.0/js/co-design.js" defer></script>

<% if SiteSetting['SyntaxHighlightingEnabled'] %>
  <link rel="stylesheet"
        href="//cdnjs.cloudflare.com/ajax/libs/highlight.js/10.1.2/styles/default.min.css">
  <script src="//cdnjs.cloudflare.com/ajax/libs/highlight.js/10.1.2/highlight.min.js"></script>
  <script defer>hljs.initHighlightingOnLoad();</script>
<% end %>

<% if SiteSetting['MathJaxEnabled'] %>
  <script>
    MathJax = {
      tex: {
        inlineMath: [['$', '$'], ['\\(', '\\)']]
      }
    };
  </script>
  <script src="https://polyfill.io/v3/polyfill.min.js?features=es6"></script>
  <script id="MathJax-script" async src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js"></script>
<% end %>

<%= csrf_meta_tags %>

<%= yield(:head) %>

<% if content_for? :twitter_card_meta %>
  <%= yield :twitter_card_meta %>
<% else %>
  <meta name="twitter:card" content="summary" />
  <meta name="twitter:creator" content="@CodidactQA" />
  <meta property="og:url" content="<%= request.original_url %>" />
  <meta property="og:title" content="<%= page_title %>" />
  <meta property="og:description" content="<%= content_for?(:description) ? content_for(:description) : desc %>" />
  <meta property="og:image" content="<%= "https://#{RequestContext.community.host}#{SiteSetting['SiteLogoPath']}" %>" />
<% end %>
