Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: path ogImage if is url #121

Merged
merged 1 commit into from
Jan 14, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions packages/meta/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const debug = require('debug')('nuxt:pwa')

const find = (arr, key, val) => arr.find(obj => val ? obj[key] === val : obj[key])
const isUrl = url => url.indexOf('http') === 0 || url.indexOf('//') === 0

module.exports = function nuxtMeta (_options) {
const hook = () => {
Expand Down Expand Up @@ -182,12 +183,12 @@ function generateMeta (_options) {
options.ogImage = { path: options.ogImage }
}
if (options.ogImage && !find(this.options.head.meta, 'property', 'og:image') && !find(this.options.head.meta, 'name', 'og:image')) {
if (options.ogHost) {
if (options.ogHost || isUrl(options.ogImage.path)) {
this.options.head.meta.push({
hid: 'og:image',
name: 'og:image',
property: 'og:image',
content: options.ogHost + options.ogImage.path
content: isUrl(options.ogImage.path) ? options.ogImage.path : options.ogHost + options.ogImage.path
})
if (options.ogImage.width && options.ogImage.height) {
this.options.head.meta.push({
Expand Down