mirror of
https://github.com/tenrok/vue-meta.git
synced 2026-06-23 13:20:34 +03:00
feat: export hasMetaInfo helper function
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
import Vue from 'vue'
|
import Vue from 'vue'
|
||||||
import VueMeta from 'vue-meta'
|
import * as VueMeta from 'vue-meta'
|
||||||
|
|
||||||
Vue.use(VueMeta)
|
Vue.use(VueMeta)
|
||||||
|
|
||||||
|
|||||||
+8
-6
@@ -3,13 +3,13 @@ import createMixin from './shared/mixin'
|
|||||||
import setOptions from './shared/options'
|
import setOptions from './shared/options'
|
||||||
import { isUndefined } from './shared/typeof'
|
import { isUndefined } from './shared/typeof'
|
||||||
import $meta from './client/$meta'
|
import $meta from './client/$meta'
|
||||||
export { hasMetaInfo } from './shared/hasMetaInfo'
|
import { hasMetaInfo } from './shared/hasMetaInfo'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Plugin install function.
|
* Plugin install function.
|
||||||
* @param {Function} Vue - the Vue constructor.
|
* @param {Function} Vue - the Vue constructor.
|
||||||
*/
|
*/
|
||||||
function VueMeta(Vue, options = {}) {
|
function install(Vue, options = {}) {
|
||||||
options = setOptions(options)
|
options = setOptions(options)
|
||||||
|
|
||||||
Vue.prototype.$meta = $meta(options)
|
Vue.prototype.$meta = $meta(options)
|
||||||
@@ -17,12 +17,14 @@ function VueMeta(Vue, options = {}) {
|
|||||||
Vue.mixin(createMixin(Vue, options))
|
Vue.mixin(createMixin(Vue, options))
|
||||||
}
|
}
|
||||||
|
|
||||||
VueMeta.version = version
|
|
||||||
|
|
||||||
// automatic install
|
// automatic install
|
||||||
if (!isUndefined(window) && !isUndefined(window.Vue)) {
|
if (!isUndefined(window) && !isUndefined(window.Vue)) {
|
||||||
/* istanbul ignore next */
|
/* istanbul ignore next */
|
||||||
Vue.use(VueMeta)
|
install(window.Vue)
|
||||||
}
|
}
|
||||||
|
|
||||||
export default VueMeta
|
export default {
|
||||||
|
version,
|
||||||
|
install,
|
||||||
|
hasMetaInfo
|
||||||
|
}
|
||||||
|
|||||||
+7
-5
@@ -2,13 +2,13 @@ import { version } from '../package.json'
|
|||||||
import createMixin from './shared/mixin'
|
import createMixin from './shared/mixin'
|
||||||
import setOptions from './shared/options'
|
import setOptions from './shared/options'
|
||||||
import $meta from './server/$meta'
|
import $meta from './server/$meta'
|
||||||
export { hasMetaInfo } from './shared/hasMetaInfo'
|
import { hasMetaInfo } from './shared/hasMetaInfo'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Plugin install function.
|
* Plugin install function.
|
||||||
* @param {Function} Vue - the Vue constructor.
|
* @param {Function} Vue - the Vue constructor.
|
||||||
*/
|
*/
|
||||||
function VueMeta(Vue, options = {}) {
|
function install(Vue, options = {}) {
|
||||||
options = setOptions(options)
|
options = setOptions(options)
|
||||||
|
|
||||||
Vue.prototype.$meta = $meta(options)
|
Vue.prototype.$meta = $meta(options)
|
||||||
@@ -16,6 +16,8 @@ function VueMeta(Vue, options = {}) {
|
|||||||
Vue.mixin(createMixin(Vue, options))
|
Vue.mixin(createMixin(Vue, options))
|
||||||
}
|
}
|
||||||
|
|
||||||
VueMeta.version = version
|
export default {
|
||||||
|
version,
|
||||||
export default VueMeta
|
install,
|
||||||
|
hasMetaInfo
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { mount, defaultOptions, hasMetaInfo, VueMetaServerPlugin, loadVueMetaPlugin } from './utils'
|
import { mount, defaultOptions, VueMetaServerPlugin, loadVueMetaPlugin } from './utils'
|
||||||
|
|
||||||
jest.mock('../package.json', () => ({
|
jest.mock('../package.json', () => ({
|
||||||
version: 'test-version'
|
version: 'test-version'
|
||||||
@@ -64,7 +64,7 @@ describe('plugin', () => {
|
|||||||
|
|
||||||
const { vm } = mount(Component, { localVue: Vue })
|
const { vm } = mount(Component, { localVue: Vue })
|
||||||
|
|
||||||
expect(hasMetaInfo(vm)).toBe(true)
|
expect(VueMetaServerPlugin.hasMetaInfo(vm)).toBe(true)
|
||||||
expect(warn).not.toHaveBeenCalled()
|
expect(warn).not.toHaveBeenCalled()
|
||||||
|
|
||||||
warn.mockRestore()
|
warn.mockRestore()
|
||||||
|
|||||||
+1
-2
@@ -1,7 +1,7 @@
|
|||||||
import { mount, createLocalVue } from '@vue/test-utils'
|
import { mount, createLocalVue } from '@vue/test-utils'
|
||||||
import { renderToString } from '@vue/server-test-utils'
|
import { renderToString } from '@vue/server-test-utils'
|
||||||
import VueMetaBrowserPlugin from '../../src/browser'
|
import VueMetaBrowserPlugin from '../../src/browser'
|
||||||
import VueMetaServerPlugin, { hasMetaInfo } from '../../src'
|
import VueMetaServerPlugin from '../../src'
|
||||||
|
|
||||||
import {
|
import {
|
||||||
keyName,
|
keyName,
|
||||||
@@ -15,7 +15,6 @@ import {
|
|||||||
export {
|
export {
|
||||||
mount,
|
mount,
|
||||||
renderToString,
|
renderToString,
|
||||||
hasMetaInfo,
|
|
||||||
VueMetaBrowserPlugin,
|
VueMetaBrowserPlugin,
|
||||||
VueMetaServerPlugin
|
VueMetaServerPlugin
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user