<head>
  <!-- 元数据 -->
  <meta charset="utf-8">
  <% if (theme.site_logo) { %><link rel="icon" href="<%- theme.site_logo %>"><% } %>
  <%
  var title = page.title || __(page.title_i18n);
  if (is_archive()){
    title = __('title.archive');
    if (is_month()){
      title += ': ' + page.year + '-' + String(page.month).padStart(2, '0');
    } else if (is_year()){
      title += ': ' + page.year;
    }
  } else if (is_category()){
    title = __('title.category') + ': ' + page.category;
  } else if (is_tag()){
    title = __('title.tag') + ': ' + page.tag;
  } else if (is_post() && !title){
    title = __('title.status');
  }
  %>
  <title><% if (title) { %><%= title %> | <% } %><%= config.title %></title>
  <%- kratos_canonical() %>
  <meta name="author" content="<%- config.author  %>" />
  <meta http-equiv="Cache-Control" content="no-transform" />
  <meta http-equiv="Cache-Control" content="no-siteapp" />
  <meta http-equiv="X-UA-Compatible" content="IE=edge" />
  <meta name="robots" content="index,follow" />
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1" />
  <meta name="format-detection" content="telphone=no, email=no" />
  <% if (is_post()) { %>
    <meta name="keywords" content="<%- strip_html(list_tags(page.tags, { show_count: false, style: 'none' })) %>" />
  <% } else { %>
    <meta name="keywords" content="<%- config.keywords %>" />
  <% } %>
  <%- open_graph({
    image: (function(){
      const image_path = page.pic ? page.path + page.pic : theme.site_logo;
      return image_path ? full_url_for(image_path) : null;
    })(),
    // twitter_site: theme.contact.twitter ? "@" + theme.contact.twitter : null,
    title
  }) %>
  <% if (config.feed?.path) {%><link rel="alternate" href="<%- config.feed.path %>" type="application/atom+xml"><% } %>
  <!-- 站点验证相关 -->
  <% if (theme.site_verify) { %>
    <% if (theme.site_verify.google) { %>
      <meta name="google-site-verification" content="<%- theme.site_verify.google %>" />
    <% } %>
    <% if (theme.site_verify.baidu) { %>
      <meta name="baidu-site-verification" content="<%- theme.site_verify.baidu %>" />
    <% } %>
    <% if (theme.site_verify.bing) { %>
      <meta name="msvalidate.01" content="<%- theme.site_verify.bing %>" />
    <% } %>
  <% } %>
  <!-- 样式表文件 -->
  <%- css_theme_cdn('css/kratosr.min.css', {id: "kratos-css", media:"all"}) %>
  <% if (theme.enable_dark) { %>
    <%- css_theme_cdn('css/kr-color-dark.min.css', {id: "darkmode-css", media:"(prefers-color-scheme: dark)"}) %>
    <%- js_theme_cdn('js/kr-dark.min.js') %>
  <% } %>
  <% if (((config.highlight && config.highlight.enable) || config.syntax_highlighter === "highlight.js") && theme.highlight_theme) { %>
    <%- css_theme_cdn(`css/highlight/${theme.highlight_theme || 'night-eighties'}.min.css`, {id: "highlight-css", media:"all"}) %>
  <% } %>
  <%- css_npm_cdn('font-awesome', 'css/font-awesome.min.css', {id:"fontawe-css", media:"all"}) %>
  <%- css_npm_cdn('nprogress', 'nprogress.css', {id:"nprogress-css", media:"all"}) %>
  <% const commentProvider = theme.posts?.comments?.provider ?? theme.posts?.comments; %>
  <% if (theme.aplayer?.enabled) { %>
    <%- css_npm_cdn('aplayer', 'dist/APlayer.min.css') %>
  <% }%>
  <% if (theme.fancybox){ %>
    <%- css_npm_cdn('@fancyapps/fancybox', 'dist/jquery.fancybox.min.css') %>
  <% } %>
  <!-- 不得不预先加载的一些JS文件 -->
  <%- js_npm_cdn('jquery', 'dist/jquery.min.js') %>
  <% if (theme.posts?.share) { %>
    <%- js_npm_cdn('qrcode_js', 'qrcode.min.js') %>
  <% } %>
  <% if (theme.customStyles) { %>
  <style>
    <% if (theme.customStyles.images?.banner) { %>
      .kratos-cover.kratos-cover-2 {
        background-image: url('<%- theme.customStyles.images?.banner %>');
      }
    <% } %>
    <% if (theme.customStyles.images?.background) { %>
      @media(min-width:768px) {
        body.custom-background {
          background-image: url('<%- theme.customStyles.images?.background %>');
        }
      }
    <% } %>
  </style>
  <% } %>
</head>

