yufan.me/themes/spectre/layout/_partial/head/open-graph.ejs

37 lines
1.7 KiB
Plaintext
Raw Normal View History

2024-06-14 02:15:18 +08:00
<%
var title = page.title;
if (is_archive()) {
title = __('sidebar.archive');
if (is_month()) {
title += ': ' + page.year + '/' + page.month;
}
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;
}
%>
<meta property="og:title" content="<% if (title) { %><%= title %> | <% } %><%= config.title %>">
<meta property="og:type" content="blog">
<meta property="og:url" content="<%= config.url + url_for(page.path).replace('index.html', '') %>">
<meta property="og:image" content="<% if (page.thumbnail) { %><%= page.thumbnail %><% } else { %><%= url_for(theme.head.high_res_favicon) %><% } %>">
<meta property="og:description" content="<% if(page.description) { %><%= page.description %><% } else if(page.excerpt){ %><%= strip_html(page.excerpt).replace(/^s*/, '').replace(/s*$/, '') %><% } else if (config.description){ %><%= config.description %><% } %>">
<% if(page.tags && page.tags.each) { page.tags.each(function(tag){ %><meta property="og:article:tag" content="<%= tag.name %>"> <% })} %>
<% if( (is_post()) ) { %>
<meta property="article:published_time" content="<%= page.date %>">
<meta property="article:modified_time" content="<%= page.updated %>">
<% } %>
<meta name="twitter:card" content="<% if (page.thumbnail) { %>summary_large_image<% } else { %>summary<% } %>">
<% if(theme.footer.sns.twitter) { %>
<meta property="twitter:site" content="<%= theme.footer.sns.twitter %>">
<meta property="twitter:creator" content="<%= theme.footer.sns.twitter.replace('https://twitter.com/','') %>">
<% } %>