diff --git a/themes/typing/layout/_partial/head.ejs b/themes/typing/layout/_partial/head.ejs index 137904e..2a8b2e9 100644 --- a/themes/typing/layout/_partial/head.ejs +++ b/themes/typing/layout/_partial/head.ejs @@ -22,8 +22,8 @@ <% if (title) { %><%= title %> | <% } %><%= config.title %> <%/* Add Open Graph meta tags for easier sharing on social networking sites */%> - <%/* Modified for cloudinary compatibility */%> - <%- open_graph_cloudinary() %> + <%/* Modified from original source for compatibility with my blog */%> + <%- openGraph() %> <% if (theme.rss) { %> <% } %> diff --git a/themes/typing/layout/_partial/post/date.ejs b/themes/typing/layout/_partial/post/date.ejs index 890747b..9e0a38e 100644 --- a/themes/typing/layout/_partial/post/date.ejs +++ b/themes/typing/layout/_partial/post/date.ejs @@ -1,3 +1,4 @@ - + <%/* Date format is specified to skip timezone conversion */%> + diff --git a/themes/typing/layout/_partial/post/updated-date.ejs b/themes/typing/layout/_partial/post/updated-date.ejs index 9548579..20a1f4f 100644 --- a/themes/typing/layout/_partial/post/updated-date.ejs +++ b/themes/typing/layout/_partial/post/updated-date.ejs @@ -1,5 +1,5 @@ <%/* User-specified updated date */%> <%/* default post.updated is (almost) always is the time 'hexo generate' is executed */%> - + diff --git a/themes/typing/scripts/open_graph_cloudinary.js b/themes/typing/scripts/openGraph.js similarity index 87% rename from themes/typing/scripts/open_graph_cloudinary.js rename to themes/typing/scripts/openGraph.js index 310c4b4..30b789a 100644 --- a/themes/typing/scripts/open_graph_cloudinary.js +++ b/themes/typing/scripts/openGraph.js @@ -48,7 +48,8 @@ function openGraphHelper (options = {}) { const url = options.url || this.url const siteName = options.site_name || config.title const twitterCard = options.twitter_card || 'summary' - const updated = options.updated !== false ? options.updated || page.updated : false + const published = page.date || false + const updated = page.lastUpdated || false const language = options.language || page.lang || page.language || config.language let result = '' @@ -116,9 +117,18 @@ function openGraphHelper (options = {}) { result += og('og:image', path, false) }) + + if (published) { + if ((moment.isMoment(published) || moment.isDate(published)) && !isNaN(published.valueOf())) { + // Skip timezone conversion + result += og('article:published_time', moment(published).format('YYYY-MM-DD[T]HH:mm:ss.SSS[Z]')) + } + } + if (updated) { if ((moment.isMoment(updated) || moment.isDate(updated)) && !isNaN(updated.valueOf())) { - result += og('og:updated_time', updated.toISOString()) + result += og('article:modified_time', moment(updated).format('YYYY-MM-DD[T]HH:mm:ss.SSS[Z]')) + result += og('og:updated_time', moment(updated).format('YYYY-MM-DD[T]HH:mm:ss.SSS[Z]')) } } @@ -158,4 +168,4 @@ function openGraphHelper (options = {}) { return result.trim() } -hexo.extend.helper.register('open_graph_cloudinary', openGraphHelper) +hexo.extend.helper.register('openGraph', openGraphHelper)