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