From 1013b0a381f71defb7abdb484321a8c51e7cd257 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Sko=C5=99epa?= <jakub@skorepa.info> Date: Wed, 15 Mar 2017 10:49:08 +0100 Subject: [PATCH] Opengraph --- sitegin/tags.js | 3 ++- sitegin/urls.js | 3 ++- theme/templates/article.html.nunj | 6 ++++++ theme/templates/partials/base.html.nunj | 7 +++++++ theme/templates/tag.html.nunj | 7 +++++++ 5 files changed, 24 insertions(+), 2 deletions(-) diff --git a/sitegin/tags.js b/sitegin/tags.js index b81d174e..db4ac0c8 100644 --- a/sitegin/tags.js +++ b/sitegin/tags.js @@ -83,7 +83,7 @@ module.exports = function(obj) { if(firstpage === undefined) firstpage = tagPage; lastpage = tagPage; - tagPage.file = file+'/'+p; + tagPage.file = file+'/'+p+'/'; tagPage.type = 'tag'; tagPage.tag = tag; tagPage.subtags = subtags; @@ -92,6 +92,7 @@ module.exports = function(obj) { tagPage.metadata.prevurl = prevurl; tagPage.metadata.thispage = tagPage; tagPage.metadata.pagenumber = p; + tagPage.canonicalURL = 'https://ok1kvk.cz/'+tagPage.file tagPage.content = []; if(prevpage !== undefined) diff --git a/sitegin/urls.js b/sitegin/urls.js index 57045398..bd667a92 100644 --- a/sitegin/urls.js +++ b/sitegin/urls.js @@ -3,7 +3,7 @@ */ var rewriteURL = function(file) { - file = file.replace(/\.md$/,''); + file = file.replace(/\.md$/,'/'); file = file.replace(/^articles/,'clanek'); return file; } @@ -13,6 +13,7 @@ module.exports = function(obj) { return new Promise(function(resolve, reject) { obj.pages.forEach(function(page) { page.file = rewriteURL(page.file); + page.canonicalURL = 'https://ok1kvk.cz/'+page.file }) resolve(obj) }); diff --git a/theme/templates/article.html.nunj b/theme/templates/article.html.nunj index 4a80f391..6e23a9a1 100644 --- a/theme/templates/article.html.nunj +++ b/theme/templates/article.html.nunj @@ -1,6 +1,12 @@ {% extends "partials/base.html.nunj" %} {% block head %} + + <meta property="og:type" content="article" /> + <meta property="article:published_time" content="{{ metadata.date.creation }}" /> + <meta property="og:image" content="{{ metadata.image }}" /> + <meta property="og:description" content="{% if metadata.perex %}{{metadata.perex}}{% else %}{% if metadata.perex_e %}{{metadata.perex_e | truncate}}{% else %}{% if content %}{{ content | striptags | truncate }}{% endif %}{% endif %}{% endif %}" /> + {{ super() }} {{ metadata.headerextra | safe }} <script type="text/x-mathjax-config"> diff --git a/theme/templates/partials/base.html.nunj b/theme/templates/partials/base.html.nunj index 795c0e7b..14183767 100644 --- a/theme/templates/partials/base.html.nunj +++ b/theme/templates/partials/base.html.nunj @@ -6,6 +6,13 @@ <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1.0"/> <title>{% if metadata.title %}{{ metadata.title }}{%else%}Radioklub OK1KVK{%endif%}</title> + <link rel="canonical" href="{{ canonicalURL }}" /> + <link rel="publisher" href="https://plus.google.com/+ok1kvk/"/> + <meta property="og:title" content="{% if metadata.title %}{{ metadata.title }}{%else%}Radioklub OK1KVK{%endif%}" /> + <meta property="og:locale" content="cs_CZ" /> + <meta property="og:url" content="{{ canonicalURL }}" /> + <meta property="og:site_name" content="ok1kvk.cz" /> + <link href='https://fonts.googleapis.com/css?family=Roboto&subset=latin,latin-ext' rel='stylesheet' type='text/css'> <link href="{{ config.baseurl }}/theme/style.css?v=2" type="text/css" rel="stylesheet" media="screen,projection"/> <link href="{{ config.baseurl }}/theme/highlight.css" type="text/css" rel="stylesheet" media="screen,projection"/> diff --git a/theme/templates/tag.html.nunj b/theme/templates/tag.html.nunj index b086b5c7..f598d441 100644 --- a/theme/templates/tag.html.nunj +++ b/theme/templates/tag.html.nunj @@ -1,5 +1,12 @@ {% extends "partials/base.html.nunj" %} +{% block head %} + {{ super() }} + + <meta property="og:type" content="website" /> + +{% endblock %} + {% block content %} {% include "partials/list.html.nunj" %} {% endblock %} -- GitLab