From 215022edf9fc338415ff5ac7bc374548aa2b241e Mon Sep 17 00:00:00 2001 From: PinGu Date: Mon, 17 Feb 2020 15:46:15 +0800 Subject: [PATCH 1/3] Fill author element with Twitter handle Fix jekyll/jekyll-feed#299 --- lib/jekyll-feed/feed.xml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/jekyll-feed/feed.xml b/lib/jekyll-feed/feed.xml index 4d4fd16d..cb437660 100644 --- a/lib/jekyll-feed/feed.xml +++ b/lib/jekyll-feed/feed.xml @@ -59,7 +59,11 @@ {% assign post_author = site.data.authors[post_author] | default: post_author %} {% assign post_author_email = post_author.email | default: nil %} {% assign post_author_uri = post_author.uri | default: nil %} - {% assign post_author_name = post_author.name | default: post_author %} + {% assign post_author_twitter = post_author.twitter | default: nil %} + {% if post_author_twitter %} + {% assign post_author_twitter = post_author.twitter | prepend: "@" %} + {% endif %} + {% assign post_author_name = post_author.name | default: post_author_twitter | default: post_author %} {{ post_author_name | default: "" | xml_escape }} From cc7700d01692af5fddfb39e3fef2ab51ec33caa2 Mon Sep 17 00:00:00 2001 From: PinGu Date: Mon, 17 Feb 2020 15:54:56 +0800 Subject: [PATCH 2/3] Fallback to key if name and twitter unavailable If both name and twitter in author.yml unavailable, fallback to author key --- lib/jekyll-feed/feed.xml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/jekyll-feed/feed.xml b/lib/jekyll-feed/feed.xml index cb437660..eb222314 100644 --- a/lib/jekyll-feed/feed.xml +++ b/lib/jekyll-feed/feed.xml @@ -56,6 +56,10 @@ {% endunless %} {% assign post_author = post.author | default: post.authors[0] | default: site.author %} + {% assign post_author_name = nil %} + {% unless post_author.first %} + {% assign post_author_name = post_author %} + {% endunless %} {% assign post_author = site.data.authors[post_author] | default: post_author %} {% assign post_author_email = post_author.email | default: nil %} {% assign post_author_uri = post_author.uri | default: nil %} @@ -63,7 +67,7 @@ {% if post_author_twitter %} {% assign post_author_twitter = post_author.twitter | prepend: "@" %} {% endif %} - {% assign post_author_name = post_author.name | default: post_author_twitter | default: post_author %} + {% assign post_author_name = post_author.name | default: post_author_twitter | default: post_author_name | default: post_author %} {{ post_author_name | default: "" | xml_escape }} From 0a08d7dbc6aea369d5ca91c502018e962bbc4f3e Mon Sep 17 00:00:00 2001 From: PinGu Date: Mon, 17 Feb 2020 20:33:38 +0800 Subject: [PATCH 3/3] Code refactoring --- lib/jekyll-feed/feed.xml | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/lib/jekyll-feed/feed.xml b/lib/jekyll-feed/feed.xml index eb222314..9f6de0cd 100644 --- a/lib/jekyll-feed/feed.xml +++ b/lib/jekyll-feed/feed.xml @@ -56,16 +56,18 @@ {% endunless %} {% assign post_author = post.author | default: post.authors[0] | default: site.author %} - {% assign post_author_name = nil %} - {% unless post_author.first %} + {% if post_author.first %} + {% assign post_author_name = nil %} + {% else %} {% assign post_author_name = post_author %} - {% endunless %} + {% endif %} {% assign post_author = site.data.authors[post_author] | default: post_author %} {% assign post_author_email = post_author.email | default: nil %} {% assign post_author_uri = post_author.uri | default: nil %} - {% assign post_author_twitter = post_author.twitter | default: nil %} - {% if post_author_twitter %} + {% if post_author.twitter %} {% assign post_author_twitter = post_author.twitter | prepend: "@" %} + {% else %} + {% assign post_author_twitter = nil %} {% endif %} {% assign post_author_name = post_author.name | default: post_author_twitter | default: post_author_name | default: post_author %}