From 07b342bb277ae2375c63b59064aae0bcd275a93c Mon Sep 17 00:00:00 2001 From: curben <2809763-curben@users.noreply.gitlab.com> Date: Fri, 18 Oct 2019 01:53:01 +0100 Subject: [PATCH] feat(open_graph): replace keywords with article:tag - https://yoast.com/meta-keywords/ - add date-related tags to all pages --- themes/chameleon/scripts/openGraph.js | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-) diff --git a/themes/chameleon/scripts/openGraph.js b/themes/chameleon/scripts/openGraph.js index d4b2721..da6b3a2 100644 --- a/themes/chameleon/scripts/openGraph.js +++ b/themes/chameleon/scripts/openGraph.js @@ -33,7 +33,7 @@ function openGraphHelper (options = {}) { const { content } = page let images = page.photos || [] let description = page.excerpt || theme.description - const keywords = page.keywords || (page.tags && page.tags.length ? page.tags : undefined) || config.keywords + const keywords = page.tags || false const title = page.title || theme.nickname const type = (this.is_post() ? 'article' : 'website') const url = encodeURL(this.url) @@ -72,13 +72,9 @@ function openGraphHelper (options = {}) { } if (keywords) { - if (typeof keywords === 'string') { - result += meta('keywords', keywords) - } else if (keywords.length) { - result += meta('keywords', keywords.map(tag => { - return tag.name ? tag.name : tag - }).filter(keyword => !!keyword).join()) - } + keywords.forEach(tag => { + result += og('article:tag', tag.name) + }) } result += og('og:type', type) @@ -112,8 +108,7 @@ function openGraphHelper (options = {}) { }) if (published) { - if ((moment.isMoment(published) || moment.isDate(published)) && !isNaN(published.valueOf()) && - this.is_post()) { + if ((moment.isMoment(published) || moment.isDate(published)) && !isNaN(published.valueOf())) { // Skip timezone conversion result += og('article:published_time', moment(published).format('YYYY-MM-DD[T00:00:00.000Z]')) } @@ -121,11 +116,7 @@ function openGraphHelper (options = {}) { if (updated) { if ((moment.isMoment(updated) || moment.isDate(updated)) && !isNaN(updated.valueOf())) { - result += og('og:updated_time', moment(updated).format('YYYY-MM-DD[T00:00:00.000Z]')) - - if (this.is_post()) { - result += og('article:modified_time', moment(updated).format('YYYY-MM-DD[T00:00:00.000Z]')) - } + result += og('article:modified_time', moment(updated).format('YYYY-MM-DD[T00:00:00.000Z]')) } }