Skip to content

Commit

Permalink
feat: meta tag recode
Browse files Browse the repository at this point in the history
  • Loading branch information
lh1me committed Mar 3, 2022
1 parent ff0f2ca commit 9d7f674
Show file tree
Hide file tree
Showing 4 changed files with 89 additions and 87 deletions.
11 changes: 11 additions & 0 deletions layout/_partial/footer.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,17 @@
<script async custom-element="amp-ad" src="https://cdn.ampproject.org/v0/amp-ad-0.1.js"></script>
<% } %>


<% if (config.aomori_googletagmanager && config.aomori_googletagmanager.enable){ %>
<!-- Google Tag Manager -->
<script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
})(window,document,'script','dataLayer','<%= config.aomori_googletagmanager.id %>');</script>
<!-- End Google Tag Manager -->
<% } %>

<% if (config.aomori_baidu_analytics) { %>
<!-- Baidu Analytics-->
<script type="text/javascript">
Expand Down
83 changes: 3 additions & 80 deletions layout/_partial/head.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -24,86 +24,9 @@

<meta name="description" content="<%= page.description || page.excerpt || config.description || config.title %>">
<meta name="keywords" content="<%= page.keywords || config.keywords %>">
<% if(is_post() && config.publisher && page.date && config.siteName && page.description && page.title && page.image && config.author){ %>
<meta property="og:locale" content="it_IT" />
<meta property="og:type" content="article" />
<meta property="og:title" content= "<%= page.title %>" />
<meta property="og:description" content= "<%= page.description %>" />
<meta property="og:url" content="<%= url %>" />
<meta property="og:site_name" content="<%= config.siteName%>" />
<meta property="article:author" content="<%= config.author%>" />
<meta property="article:publisher" content="<%= config.publisher%>" />
<meta property="article:published_time" content="<%= page.date.toISOString() %>" />
<meta property="article:modified_time" content="<%= page.updated?.toISOString() %>" />
<meta property="og:image" content="<%= page.image %>" />
<meta property="og:description" content="<%= page.description %>" />
<meta property="og:image:width" content="800" />
<meta property="og:image:height" content="350" />
<meta property="og:image:type" content="image/png" />
<meta name="twitter:card" content="summary_large_image" />
<meta name="twitter:data1" content="<%= config.author%>" />
<meta name="twitter:title" content="<%= page.title %>"/>
<meta name="twitter:description" content="<%= page.description %>"/>
<script type="application/ld+json">
{
"description": "<%= page.description %>",
"author": { "@type": "Person", "name": "<%= config.author%>" },
"@type": "BlogPosting",
"url": "<%= url %>",
"publisher": {
"@type": "Organization",
"logo": {
"@type": "ImageObject",
"url": "<%= config.url + config.aomori_logo %>"
},
"name": "<%= config.author%>"
},
"headline": "<%= page.title %>",
"datePublished": "<%= page.date.toISOString() %>",
"mainEntityOfPage": {
"@type": "WebPage",
"@id": "<%= url %>"
},
"@context": "http://schema.org"
}
</script>
<% }
else if (is_page() && config.publisher && page.description && page.date && page.title && page.image && config.author){ %>
<meta property="og:type" content="website"/>
<meta property="og:title" content="<%= page.title %>"/>
<meta property="og:description" content="<%= page.description %>"/>
<meta property="og:locale" content="it_IT" />
<meta property="og:type" content="article" />
<meta property="og:url" content="<%= url %>>" />
<meta property="og:site_name" content="<%= config.author%>" />
<meta property="article:publisher" content="<%= config.publisher%>" />
<meta property="article:published_time" content="<%= page.date.toISOString() %>" />
<meta property="article:modified_time" content="<%= page.update?.toISOString()%>" />
<meta property="og:image" content="<%= config.url + page.image%>" />
<meta name="twitter:card" content="summary_large_image" />
<script type="application/ld+json">
{
"@context": "https://schema.org",
"@type": "WebPage",
"name": "<%= page.title %>",
"description": "<%= page.description %>",
"publisher": {
"@type": "Organization",
"name": "<%= config.author%>"
},
}
</script>
<% }
else {}%>
<% if (config.googletagmanager){ %>
<!-- Google Tag Manager -->
<script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
})(window,document,'script','dataLayer','<%= config.googletagmanager %>');</script>
<!-- End Google Tag Manager -->
<% } %>

<%- partial('_partial/meta') %>

<% if (config.aomori_google_site && config.aomori_google_site.enable){ %>
<meta name="google-site-verification" content="<%= config.aomori_google_site.id %>" />
<% } %>
Expand Down
74 changes: 74 additions & 0 deletions layout/_partial/meta.ejs
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
<%
var title = page.title;
if (is_archive()){
title = __('Archive');
if (is_month()){
title += ' | ' + page.year + '/' + page.month;
} else if (is_year()){
title += ' | ' + page.year;
}
} else if (is_category()){
title = __('Category') + ' | ' + page.category;
} else if (is_tag()){
title = __('Tag') + ' | ' + page.tag;
}
%>
<% if(is_post()){ %>
<meta property="og:locale" content="<%= config.language %>" />
<meta property="og:type" content="article" />
<meta property="og:title" content= "<% if (title){ %><%= title %> | <% } %><%= config.title %>" />
<meta property="og:description" content= "<%= page.description || page.excerpt || config.description || config.title %>" />
<meta property="og:url" content="<%= url %>" />
<meta property="og:site_name" content="<%= config.siteName %>" />
<meta property="article:author" content="<%= config.author %>" />
<meta property="article:publisher" content="<%= config.publisher %>" />
<meta property="og:description" content="<%= page.description || page.excerpt || config.description || config.title %>" />
<meta name="twitter:title" content="<% if (title){ %><%= title %> | <% } %><%= config.title %>"/>
<meta name="twitter:description" content="<%= page.description || page.excerpt || config.description || config.title %>"/>
<script type="application/ld+json">
{
"description": "<%= page.description || page.excerpt || config.description || config.title %>",
"author": { "@type": "Person", "name": "<%= config.author %>" },
"@type": "BlogPosting",
"url": "<%= url %>",
"publisher": {
"@type": "Organization",
"logo": {
"@type": "ImageObject",
"url": "<%= config.url + config.aomori_logo %>"
},
"name": "<%= config.author%>"
},
"headline": "<% if (title){ %><%= title %> | <% } %><%= config.title %>",
"datePublished": "<%= page.date.toISOString() %>",
"mainEntityOfPage": {
"@type": "WebPage",
"@id": "<%= url %>"
},
"@context": "http://schema.org"
}
</script>
<% } %>

<% if(is_home() || is_page()){ %>
<meta property="og:type" content="website"/>
<meta property="og:title" content="<%= page.title %>"/>
<meta property="og:description" content="<%= page.description %>"/>
<meta property="og:locale" content="<%= config.language %>" />
<meta property="og:type" content="article" />
<meta property="og:url" content="<%= url %>" />
<meta property="og:site_name" content="<%= config.author%>" />
<meta property="article:publisher" content="<%= config.publisher%>" />
<script type="application/ld+json">
{
"@context": "https://schema.org",
"@type": "WebPage",
"name": "<%= page.title %>",
"description": "<%= page.description %>",
"publisher": {
"@type": "Organization",
"name": "<%= config.author%>"
},
}
</script>
<% } %>
8 changes: 1 addition & 7 deletions layout/layout.ejs
Original file line number Diff line number Diff line change
@@ -1,14 +1,8 @@
<%- partial('_partial/head') %>

<body>
<% if (config.googletagmanager){ %>
<!-- Google Tag Manager (noscript) -->
<noscript><iframe src="https://www.googletagmanager.com/ns.html?id=<%= config.googletagmanager %>"
height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
<!-- End Google Tag Manager (noscript) -->
<% } %>

<%- partial('_partial/header') %>


<div class="container">
<div class="main">
Expand Down

0 comments on commit 9d7f674

Please sign in to comment.