diff options
| -rw-r--r-- | _includes/header.html | 11 | ||||
| -rw-r--r-- | _layouts/default.html | 34 | ||||
| -rw-r--r-- | _plugins/twitter.rb | 52 | ||||
| -rw-r--r-- | images/default.png | bin | 0 -> 9980 bytes | |||
| -rw-r--r-- | images/empty.png | bin | 0 -> 1627 bytes | |||
| -rw-r--r-- | images/posts/la-recollida-porta-a-porta.png | bin | 0 -> 55650 bytes | |||
| -rw-r--r-- | stylesheets/partials/minima/_layout.scss | 1 |
7 files changed, 94 insertions, 4 deletions
diff --git a/_includes/header.html b/_includes/header.html index ca0eeca..3609584 100644 --- a/_includes/header.html +++ b/_includes/header.html @@ -8,6 +8,16 @@ <a title="Home" class="site-title" rel="author" href="{{ "/" | relative_url }}">{{ site.title | escape }}</a> </div> <nav class="site-nav"> + <input type="checkbox" id="nav-trigger" class="nav-trigger" /> + <label for="nav-trigger"> + <span class="menu-icon"> + <svg viewBox="0 0 18 15" width="18px" height="15px"> + <path d="M18,1.484c0,0.82-0.665,1.484-1.484,1.484H1.484C0.665,2.969,0,2.304,0,1.484l0,0C0,0.665,0.665,0,1.484,0 h15.032C17.335,0,18,0.665,18,1.484L18,1.484z M18,7.516C18,8.335,17.335,9,16.516,9H1.484C0.665,9,0,8.335,0,7.516l0,0 c0-0.82,0.665-1.484,1.484-1.484h15.032C17.335,6.031,18,6.696,18,7.516L18,7.516z M18,13.516C18,14.335,17.335,15,16.516,15H1.484 C0.665,15,0,14.335,0,13.516l0,0c0-0.82,0.665-1.483,1.484-1.483h15.032C17.335,12.031,18,12.695,18,13.516L18,13.516z"/> + </svg> + </span> + </label> + + <div class="trigger"> {% if site.lang == "ca" %} {% if page.layout == "post" and page.english_available == false %} <span class="no-lang" title="{% t blog.no_english_post %}">{% t global.english %}</span> @@ -25,6 +35,7 @@ <a title="{% t titles.writings %}" href="{% tl writings %}">{% t titles.writings %}</a> <a title="{% t titles.blog %}" href="{% tl blog %}">{% t titles.blog %}</a> <a title="{% t titles.about %}" href="{% tl about %}">{% t titles.about %}</a> + </div> </nav> </div> </header> diff --git a/_layouts/default.html b/_layouts/default.html index 0adbf0d..2b452db 100644 --- a/_layouts/default.html +++ b/_layouts/default.html @@ -14,16 +14,42 @@ {% endcomment %} {% if page.title %} {% if page.title contains "titles." %} - <title>{{ site.title }} - {% t page.title %}</title> + {% capture title %}{{ site.title }} - {% t page.title %}{% endcapture %} + {% capture raw_title %}{% t page.title %}{% endcapture %} {% else %} - <title>{{ site.title }} - {{ page.title }}</title> + {% capture title %}{{ site.title }} - {{ page.title }}{% endcapture %} + {% capture raw_title %}{{ page.title }}{% endcapture %} {% endif %} {% else %} - <title>{{ site.title }}</title> + {% capture title %}{{ site.title }}{% endcapture %} + {% capture raw_title %}{% endcapture %} {% endif %} + <title>{{ title }}</title> + <meta http-equiv="X-UA-Compatible" content="IE=edge"> - <meta name="description" content="{% if page.excerpt %}{{ page.excerpt | strip_html | strip_newlines | truncate: 160 }}{% else %}{{ site.description }}{% endif %}"> + {% capture description %}{% if page.excerpt %}{{ page.excerpt | strip_html | strip_newlines | truncate: 160 }}{% else %}{{ site.description }}{% endif %}{% endcapture %} + <meta name="description" content="{{ description }}"> + + {% comment %}<!-- Twitter stuff -->{% endcomment %} + <meta name="twitter:card" content="summary" /> + <meta name="twitter:site" content="@miquelssola" /> + <meta name="twitter:creator" content="@miquelssola" /> + + {% comment %}<!-- OpenGraph protocol -->{% endcomment %} + {% if site.lang == "ca" %} + <meta property="og:locale" content="ca_ES" /> + <meta property="og:locale:alternate" content="en_US" /> + <meta property="og:url" content="http://jo.mssola.com{{ page.url }}" /> + {% else %} + <meta property="og:locale" content="en_US" /> + <meta property="og:locale:alternate" content="ca_ES" /> + <meta property="og:url" content="http://jo.mssola.com/en{{ page.url }}" /> + {% endif %} + <meta property="og:title" content="{{ title }}" /> + <meta property="og:description" content="{{ description }}" /> + <meta property="og:type" content="website" /> + {% render_og_image %} {% comment %}<!-- We have the same CSS file for all languages -->{% endcomment %} <link href="{{ "/stylesheets/main.css" | prepend: site.baseurl_root }}" rel="stylesheet" type="text/css" /> diff --git a/_plugins/twitter.rb b/_plugins/twitter.rb new file mode 100644 index 0000000..bc4c99b --- /dev/null +++ b/_plugins/twitter.rb @@ -0,0 +1,52 @@ +# frozen_string_literal: true + +# Copyright (C) 2019 Miquel Sabaté Solà <mikisabate@gmail.com> +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see <https://www.gnu.org/licenses/>. + +module Jekyll + # Render the OG image meta HTML tag for the currently rendered page. + class RenderOGImageTag < Liquid::Tag + # The path to be used when the current page does not have a specific image. + DEFAULT_PATH = "/images/default.png" + + def render(context) + img = normalize(context["raw_title"]) + ".png" + path = image_exists?(img) ? "/images/posts/#{img}" : DEFAULT_PATH + render_meta("og:image", "http://jo.mssola.com#{path}") + end + + protected + + # Returns true if the given image exists inside of /images/posts. + def image_exists?(image) + return false if image == ".png" + + path = File.expand_path(File.join(File.dirname(__FILE__), "..", "images", "posts", image)) + File.file?(path) + end + + # Downcases the given string and replaces space characters with "-" + def normalize(str) + str.gsub(/\s/, "-").downcase + end + + # Render an HTML meta tag with the given property and content attributes. + def render_meta(property, content) + "<meta property=\"#{property}\" content=\"#{content}\" />" + end + end +end + +Liquid::Template.register_tag("render_og_image", Jekyll::RenderOGImageTag) diff --git a/images/default.png b/images/default.png Binary files differnew file mode 100644 index 0000000..8a85866 --- /dev/null +++ b/images/default.png diff --git a/images/empty.png b/images/empty.png Binary files differnew file mode 100644 index 0000000..bc21f1c --- /dev/null +++ b/images/empty.png diff --git a/images/posts/la-recollida-porta-a-porta.png b/images/posts/la-recollida-porta-a-porta.png Binary files differnew file mode 100644 index 0000000..06371da --- /dev/null +++ b/images/posts/la-recollida-porta-a-porta.png diff --git a/stylesheets/partials/minima/_layout.scss b/stylesheets/partials/minima/_layout.scss index dcfa539..654cbd9 100644 --- a/stylesheets/partials/minima/_layout.scss +++ b/stylesheets/partials/minima/_layout.scss @@ -91,6 +91,7 @@ input:checked ~ .trigger { display: block; padding-bottom: 5px; + padding-right: 10px; } .page-link { |
