From 67e82b50015d32ddf0f1351eaaf699257dc543ec Mon Sep 17 00:00:00 2001 From: Eloi Perdereau <eloi@perdereau.eu> Date: Mon, 25 Nov 2019 01:52:29 +0100 Subject: [PATCH] allow author override in front matter --- _includes/author-profile.html | 8 +++++--- _includes/seo.html | 1 + _layouts/single.html | 8 +++++--- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/_includes/author-profile.html b/_includes/author-profile.html index 12c5971..675075d 100644 --- a/_includes/author-profile.html +++ b/_includes/author-profile.html @@ -1,7 +1,9 @@ <!-- {% assign author = page.author | default: page.authors[0] | default: site.author %} --> -{% assign author = page.url | split: "/" %} -{% assign author = author[1] %} -{% assign author = site.data.authors.authors | where: "prefix", author | first %} +{% unless page.author %} + {% assign author = page.url | split: "/" %} + {% assign author = author[1] %} +{% endunless %} +{% assign author = site.data.authors.authors | where: "directory", author | first %} <div itemscope itemtype="https://schema.org/Person"> diff --git a/_includes/seo.html b/_includes/seo.html index be95b29..f4415d3 100644 --- a/_includes/seo.html +++ b/_includes/seo.html @@ -25,6 +25,7 @@ {%- assign seo_description = seo_description | markdownify | strip_html | strip_newlines | escape_once -%} {%- endif -%} +<!-- don't use page.author even if it is set, find author based on url --> {% assign author = page.url | split: "/" %} {% assign author = author[1] %} {% assign author = site.data.authors.authors | where: "prefix", author | first %} diff --git a/_layouts/single.html b/_layouts/single.html index 87f3448..908ece7 100644 --- a/_layouts/single.html +++ b/_layouts/single.html @@ -2,9 +2,11 @@ layout: default --- -{% assign author = page.url | split: "/" %} -{% assign author = author[1] %} -{% assign author = site.data.authors.authors | where: "prefix", author | first %} +{% unless page.author %} + {% assign author = page.url | split: "/" %} + {% assign author = author[1] %} +{% endunless %} +{% assign author = site.data.authors.authors | where: "directory", author | first %} {% if page.has_header %} {% include page__hero.html %} -- GitLab