Permalink
Browse files

feat(meta): add twitter card, site and creator properties (#43)

  • Loading branch information...
manniL authored and pi0 committed Mar 8, 2018
1 parent 3990ddf commit fe11c76941ba53eb85659c3cd9a970924f51abf3
Showing with 32 additions and 1 deletion.
  1. +13 −0 docs/modules/meta.md
  2. +19 −1 packages/meta/index.js
@@ -97,6 +97,19 @@ These types are accepted:
- Default: ogHost (if defined)
- Meta: `og:url`
**twitterCard**
- Default: `undefined`
- Meta: `twitter:card
**twitterSite**
- Default: `undefined`
- Meta: `twitter:site
**twitterCreator**
- Default: `undefined`
- Meta: `twitter:creator`
**nativeUI**
- Default: `false`
@@ -35,7 +35,10 @@ function generateMeta (_options) {
ogDescription: true,
ogImage: true,
ogHost: undefined,
ogUrl: true
ogUrl: true,
twitterCard: undefined,
twitterSite: undefined,
twitterCreator: undefined
}
// Combine sources
@@ -204,6 +207,21 @@ function generateMeta (_options) {
debug('No host specified, skipping og:image')
}
}
// twitter:card
if (options.twitterCard && !find(this.options.head.meta, 'property', 'twitter:card') && !find(this.options.head.meta, 'name', 'twitter:card')) {
this.options.head.meta.push({ hid: 'twitter:card', name: 'twitter:card', property: 'twitter:card', content: options.twitterCard })
}
// twitter:site
if (options.twitterSite && !find(this.options.head.meta, 'property', 'twitter:site') && !find(this.options.head.meta, 'name', 'twitter:site')) {
this.options.head.meta.push({ hid: 'twitter:site', name: 'twitter:site', property: 'twitter:site', content: options.twitterSite })
}
// twitter:creator
if (options.twitterCreator && !find(this.options.head.meta, 'property', 'twitter:creator') && !find(this.options.head.meta, 'name', 'twitter:creator')) {
this.options.head.meta.push({ hid: 'twitter:creator', name: 'twitter:creator', property: 'twitter:creator', content: options.twitterCreator })
}
}
module.exports.meta = require('./package.json')

0 comments on commit fe11c76

Please sign in to comment.