<%
var separator = theme.title_join_string || theme.tab_title_separator
var title = page.title ? [page.title, config.title].join(separator) : config.title
var keywords = page.keywords || config.keywords
if (keywords instanceof Array) {
  keywords = keywords.join(',')
}
var description = page.description || page.excerpt || (is_post() && page.content) || config.description
if (description) {
  description = escape_html(strip_html(description).substring(0, 200).trim()).replace(/\n/g, ' ')
}
var ogImage = page.og_img || page.index_img
var ogConfig = Object.assign({ image: ogImage && url_for(ogImage) }, theme.open_graph)
%>

<head>
  <meta charset="UTF-8">
  <meta name="baidu-site-verification" content="code-l7Baw38I2G" />
  <link rel="apple-touch-icon" sizes="76x76" href="<%= url_for(theme.apple_touch_icon) %>">
  <link rel="icon" href="<%= url_for(theme.favicon) %>">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=5.0, shrink-to-fit=no">
  <meta http-equiv="x-ua-compatible" content="ie=edge">
  <% if (theme.force_https) { %>
    <meta http-equiv="Content-Security-Policy" content="upgrade-insecure-requests">
  <% } %>
  <meta name="theme-color" content="<%= theme.color.navbar_bg_color %>">
  <meta name="author" content="<%= page.author || config.author %>">
  <meta name="keywords" content="<%= keywords %>">
  <% if (theme.open_graph.enable) { %>
    <%- open_graph(ogConfig) %>
  <% } else { %>
    <meta name="description" content="<%= description %>">
  <% } %>
  <% if (theme.custom_head) { %>
    <%- theme.custom_head %>
  <% } %>
  <title><%= title %></title>
  <script>
    (async()=>{
    window.swinstall = window.localStorage.getItem('install') === 'true'? true : false;
    if(!window.swinstall){
      window.stop();
      document.write('Waiting ServiceWorker')
    }
      navigator.serviceWorker.register(`/sw.js?time=${new Date().getTime()}`)
        .then(async reg => {
            if (!swinstall) {
                window.localStorage.setItem('install', 'true');
                setTimeout(() => {
                    window.location.reload();
                }, 50)
            }
        }).catch(err => {
        })
  })()
  </script>
  <script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-2653896444493474" crossorigin="anonymous"></script>
  <script>
    var _hmt = _hmt || [];
    (function() {
      var hm = document.createElement("script");
      hm.src = "https://hm.baidu.com/hm.js?7295ae77cd2791fc3c1459c5a15b2124";
      var s = document.getElementsByTagName("script")[0]; 
      s.parentNode.insertBefore(hm, s);
    })();
    </script>
    

  <%- partial('_partials/css.ejs') %>
  <%- export_config() %>
  <%- js_ex(theme.static_prefix.internal_js, 'utils.js') %>
  <%- js_ex(theme.static_prefix.internal_js, 'color-schema.js') %>

  <%- inject_point('head') %>
  <!-- 注意每个站点的验证标签都不一样，请勿复制！ -->
</head>
