From 8b02ea04285fa32d477a94abf0807ac62e2c4d1b Mon Sep 17 00:00:00 2001 From: Daniel Barber Date: Sat, 13 Jul 2019 16:36:39 -0400 Subject: [PATCH] Fix up feeds and OG data --- _config.yml | 3 ++- _includes/head.html | 5 ++++- _plugins/minimagick.rb | 39 +++++++++++++++++++++++++++++++++++++++ feed.json | 2 +- feed.photos.json | 4 ++-- feed.photos.xml | 2 +- 6 files changed, 49 insertions(+), 6 deletions(-) create mode 100644 _plugins/minimagick.rb diff --git a/_config.yml b/_config.yml index 2de04c5..1b2900d 100644 --- a/_config.yml +++ b/_config.yml @@ -10,6 +10,8 @@ collections: title: Uploads output: true +title_photos: Dan Barber – Photos + author: Dan Barber markdown: Kramdown description: Web designer and developer for thoughtbot in London. Drummer and all @@ -92,7 +94,6 @@ picture: width: 300 height: 300 - full-width: ppi: [1, 2] attr: diff --git a/_includes/head.html b/_includes/head.html index d0eada2..632809c 100644 --- a/_includes/head.html +++ b/_includes/head.html @@ -54,7 +54,10 @@ - + +{%- if page.image != nil %} + +{%- endif %} diff --git a/_plugins/minimagick.rb b/_plugins/minimagick.rb new file mode 100644 index 0000000..402d41c --- /dev/null +++ b/_plugins/minimagick.rb @@ -0,0 +1,39 @@ +module Jekyll + module MiniMagick + def magick(image_path, options) + filename, ext = image_path.split("/").last.split(".") + + dest_path = image_path. + split("/")[0..-2]. + prepend("assets"). + join("/") + + options.each do |command, arg| + filename += "_#{command}#{arg}" + end + + write_path = "#{dest_path}/#{filename}.#{ext}" + + if File.exists?("_site/#{write_path}") + return write_path + end + + image = ::MiniMagick::Image.open("_pictures/#{image_path}") + + image.combine_options do |i| + options.each do |command, arg| + i.send command, arg + end + i.strip + end + + puts write_path + + image.write "_site/#{write_path}" + + write_path + end + end +end + +Liquid::Template.register_filter(Jekyll::MiniMagick) diff --git a/feed.json b/feed.json index 0080807..1116e09 100644 --- a/feed.json +++ b/feed.json @@ -59,7 +59,7 @@ layout: , "url": {{ post_author_uri | jsonify }} {% endif %} }, - "tags": {{ post.tags | jsonify }} + "tags": {{ post.tags | uniq | jsonify }} }{% unless forloop.last == true %},{% endunless %} {% endfor %} ] diff --git a/feed.photos.json b/feed.photos.json index ab0dda1..b5801a9 100644 --- a/feed.photos.json +++ b/feed.photos.json @@ -5,7 +5,7 @@ layout: { "version": "https://jsonfeed.org/version/1", {% if site.title %} - "title": {{ site.title | smartify | jsonify }}, + "title": {{ site.title_photos | smartify | jsonify }}, {% elsif site.name %} "title": {{ site.name | smartify | jsonify }}, {% endif %} @@ -41,7 +41,7 @@ layout: {% unless post_image contains "://" %} {% assign post_image = post_image | absolute_url | xml_escape %} {% endunless %} - "image": {{ post_image | jsonify }}, + "image": {{ post.image | magick: resize: "2097152@" | absolute_url | jsonify }}, {% endif %} {% assign post_banner_image = post.banner_image.path | default: post.banner_image %} {% if post_banner_image %} diff --git a/feed.photos.xml b/feed.photos.xml index cb78b00..b1e2379 100644 --- a/feed.photos.xml +++ b/feed.photos.xml @@ -4,7 +4,7 @@ layout: - <![CDATA[{{ site.title }}]]> + <![CDATA[{{ site.title_photos }}]]> {{ site.time | date_to_xmlschema }}