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

Add unique identifiers to meta fields #23

Merged
merged 1 commit into from
Dec 19, 2017
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
20 changes: 10 additions & 10 deletions packages/meta/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,27 +49,27 @@ function generateMeta (_options) {

// Charset
if (options.charset && !find(this.options.head.meta, 'charset')) {
this.options.head.meta.push({ charset: options.charset })
this.options.head.meta.push({ hid: 'charset', charset: options.charset })
}

// Viewport
if (options.viewport && !find(this.options.head.meta, 'name', 'viewport')) {
this.options.head.meta.push({ name: 'viewport', content: options.viewport })
this.options.head.meta.push({ hid: 'viewport', name: 'viewport', content: options.viewport })
}

// mobileApp
if (options.mobileApp && !find(this.options.head.meta, 'name', 'mobile-web-app-capable')) {
this.options.head.meta.push({ name: 'mobile-web-app-capable', content: 'yes' })
this.options.head.meta.push({ hid: 'mobile-web-app-capable', name: 'mobile-web-app-capable', content: 'yes' })
}

// mobileApp (IOS)
if (options.mobileAppIOS && !find(this.options.head.meta, 'name', 'apple-mobile-web-app-capable')) {
this.options.head.meta.push({ name: 'apple-mobile-web-app-capable', content: 'yes' })
this.options.head.meta.push({ hid: 'apple-mobile-web-app-capable', name: 'apple-mobile-web-app-capable', content: 'yes' })
}

// statusBarStyle (IOS)
if (options.mobileAppIOS && options.appleStatusBarStyle && !find(this.options.head.meta, 'name', 'apple-mobile-web-app-status-bar-style')) {
this.options.head.meta.push({ name: 'apple-mobile-web-app-status-bar-style', content: options.appleStatusBarStyle })
this.options.head.meta.push({ hid: 'apple-mobile-web-app-status-bar-style', name: 'apple-mobile-web-app-status-bar-style', content: options.appleStatusBarStyle })
}

// Icons
Expand Down Expand Up @@ -99,7 +99,7 @@ function generateMeta (_options) {
// IOS launch icon title
const title = options.name || this.options.head.title || false
if (title && !find(this.options.head.meta, 'name', 'apple-mobile-web-app-title')) {
this.options.head.meta.push({ name: 'apple-mobile-web-app-title', content: title })
this.options.head.meta.push({ hid: 'apple-mobile-web-app-title', name: 'apple-mobile-web-app-title', content: title })
}

// description meta
Expand All @@ -109,7 +109,7 @@ function generateMeta (_options) {

// theme-color meta
if (options.theme_color && !find(this.options.head.meta, 'name', 'theme-color')) {
this.options.head.meta.push({ name: 'theme-color', content: options.theme_color })
this.options.head.meta.push({ hid: 'theme-color', name: 'theme-color', content: options.theme_color })
}

// Add lang to html tag
Expand All @@ -122,23 +122,23 @@ function generateMeta (_options) {

// og:type
if (options.ogType && !find(this.options.head.meta, 'property', 'og:type') && !find(this.options.head.meta, 'name', 'og:type')) {
this.options.head.meta.push({ name: 'og:type', property: 'og:type', content: options.ogType })
this.options.head.meta.push({ hid: 'og:type', name: 'og:type', property: 'og:type', content: options.ogType })
}

// og:title
if (options.ogTitle === true) {
options.ogTitle = options.name
}
if (options.ogTitle && !find(this.options.head.meta, 'property', 'og:title') && !find(this.options.head.meta, 'name', 'og:title')) {
this.options.head.meta.push({ name: 'og:title', property: 'og:title', content: options.ogTitle })
this.options.head.meta.push({ hid: 'og:title', name: 'og:title', property: 'og:title', content: options.ogTitle })
}

// og:description
if (options.ogDescription === true) {
options.ogDescription = options.description
}
if (options.ogDescription && !find(this.options.head.meta, 'property', 'og:description') && !find(this.options.head.meta, 'name', 'og:description')) {
this.options.head.meta.push({ name: 'og:description', property: 'og:description', content: options.ogDescription })
this.options.head.meta.push({ hid: 'og:description', name: 'og:description', property: 'og:description', content: options.ogDescription })
}
}

Expand Down