hexo-theme-stellar/layout/_partial/head.ejs

90 lines
2.7 KiB
Plaintext
Raw Normal View History

2021-02-19 23:33:19 +08:00
<%
2021-02-21 04:01:17 +08:00
function generate_title() {
2021-02-22 13:19:21 +08:00
if (page.layout == 'wiki' && page.wiki && (page.title || page.seo_title)) {
return page.wiki + __('symbol.colon') + (page.seo_title || page.title) + ' - ' + config.title;
2021-07-26 22:26:46 +08:00
} else if (page.seo_title || page.title || page.wiki) {
return (page.seo_title || page.title || page.wiki) + ' - ' + config.title;
2021-02-19 23:33:19 +08:00
} else if (page.category) {
return __('btn.category') + __('symbol.colon') + page.category + ' - ' + config.title;
} else if (page.tag) {
return __('btn.tag') + __('symbol.colon') + page.tag + ' - ' + config.title;
} else {
return config.title;
}
return '';
}
2021-02-26 20:02:32 +08:00
function generate_description() {
// 索引页
if (theme.open_graph && theme.open_graph.enable) {
return '';
}
if (page.description || page.excerpt || page.content) {
return '<meta name="description" content="' + truncate(strip_html(page.description || page.excerpt || page.content), {length: 150}) + '">';
}
return '<meta name="description" content="' + config.description + '">';
}
2021-02-21 04:01:17 +08:00
function generate_robots() {
if (is_home() == true) {
return '';
}
if (page.robots) {
return '<meta name="robots" content="' + page.robots + '">';
}
2021-02-19 23:33:19 +08:00
}
2021-02-21 03:13:21 +08:00
function og_args() {
var args = {};
if (theme.open_graph.twitter_id) {
args.twitter_id = theme.open_graph.twitter_id;
2021-02-19 23:33:19 +08:00
}
2021-02-21 03:13:21 +08:00
if (page.layout == 'post' && page.cover) {
args.twitter_card = 'summary_large_image';
2021-02-19 23:33:19 +08:00
}
2021-02-21 03:13:21 +08:00
return args;
2021-02-19 23:33:19 +08:00
}
%>
2021-03-06 00:01:41 +08:00
<head>
2021-02-21 03:13:21 +08:00
<%- meta_generator() %>
2021-02-19 23:33:19 +08:00
<meta charset="utf-8">
2021-02-21 04:01:17 +08:00
<%- generate_robots() %>
2021-02-21 03:13:21 +08:00
2021-02-19 23:33:19 +08:00
<meta http-equiv='x-dns-prefetch-control' content='on' />
<link rel='dns-prefetch' href='https://cdn.jsdelivr.net'>
<link rel="preconnect" href="https://cdn.jsdelivr.net" crossorigin>
<meta name="renderer" content="webkit">
<meta name="force-rendering" content="webkit">
<meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1">
<meta name="HandheldFriendly" content="True" >
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
2021-06-23 13:41:05 +08:00
<meta name="theme-color" content="#f8f8f8">
2021-02-21 04:01:17 +08:00
<title><%- generate_title() %></title>
2021-02-19 23:33:19 +08:00
2021-02-21 03:13:21 +08:00
<% if (theme.open_graph && theme.open_graph.enable) { %>
<%- open_graph(og_args()) %>
<% } %>
2021-02-26 20:02:32 +08:00
<%- generate_description() %>
2021-02-19 23:33:19 +08:00
<!-- feed -->
<% if (config.feed && config.feed.path) { %>
<%- feed_tag(config.feed.path, {title: config.title}) %>
<% } %>
<% if (theme.stellar.cdn_css) { %>
<%- css(theme.stellar.cdn_css) %>
<% } else { %>
<%- css('/css/main.css') %>
<% } %>
2021-06-23 16:39:27 +08:00
<% if (config.favicon) { %>
<%- favicon_tag(config.favicon) %>
<% } %>
2021-07-26 22:26:46 +08:00
2021-02-19 23:33:19 +08:00
<% if (config.inject && config.inject.head){ %>
<% (config.inject.head||[]).forEach(function(item){ %>
<%- item %>
<% }) %>
<% } %>
</head>