feat(open_graph): replace keywords with article:tag

- https://yoast.com/meta-keywords/
- add date-related tags to all pages
This commit is contained in:
curben 2019-10-18 01:53:01 +01:00
parent 774346e67d
commit 07b342bb27
No known key found for this signature in database
GPG Key ID: 5D9DB57A25D34EE3
1 changed files with 6 additions and 15 deletions

View File

@ -33,7 +33,7 @@ function openGraphHelper (options = {}) {
const { content } = page const { content } = page
let images = page.photos || [] let images = page.photos || []
let description = page.excerpt || theme.description 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 title = page.title || theme.nickname
const type = (this.is_post() ? 'article' : 'website') const type = (this.is_post() ? 'article' : 'website')
const url = encodeURL(this.url) const url = encodeURL(this.url)
@ -72,13 +72,9 @@ function openGraphHelper (options = {}) {
} }
if (keywords) { if (keywords) {
if (typeof keywords === 'string') { keywords.forEach(tag => {
result += meta('keywords', keywords) result += og('article:tag', tag.name)
} else if (keywords.length) { })
result += meta('keywords', keywords.map(tag => {
return tag.name ? tag.name : tag
}).filter(keyword => !!keyword).join())
}
} }
result += og('og:type', type) result += og('og:type', type)
@ -112,8 +108,7 @@ function openGraphHelper (options = {}) {
}) })
if (published) { if (published) {
if ((moment.isMoment(published) || moment.isDate(published)) && !isNaN(published.valueOf()) && if ((moment.isMoment(published) || moment.isDate(published)) && !isNaN(published.valueOf())) {
this.is_post()) {
// Skip timezone conversion // Skip timezone conversion
result += og('article:published_time', moment(published).format('YYYY-MM-DD[T00:00:00.000Z]')) 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 (updated) {
if ((moment.isMoment(updated) || moment.isDate(updated)) && !isNaN(updated.valueOf())) { 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]')) result += og('article:modified_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]'))
}
} }
} }