Skip to content

Commit 173b31d

Browse files
committed
feat: export hasMetaInfo helper function
1 parent f597f61 commit 173b31d

File tree

5 files changed

+19
-16
lines changed

5 files changed

+19
-16
lines changed

examples/basic/app.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import Vue from 'vue'
2-
import VueMeta from 'vue-meta'
2+
import * as VueMeta from 'vue-meta'
33

44
Vue.use(VueMeta)
55

src/browser.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,26 +3,28 @@ import createMixin from './shared/mixin'
33
import setOptions from './shared/options'
44
import { isUndefined } from './shared/typeof'
55
import $meta from './client/$meta'
6-
export { hasMetaInfo } from './shared/hasMetaInfo'
6+
import { hasMetaInfo } from './shared/hasMetaInfo'
77

88
/**
99
* Plugin install function.
1010
* @param {Function} Vue - the Vue constructor.
1111
*/
12-
function VueMeta(Vue, options = {}) {
12+
function install(Vue, options = {}) {
1313
options = setOptions(options)
1414

1515
Vue.prototype.$meta = $meta(options)
1616

1717
Vue.mixin(createMixin(Vue, options))
1818
}
1919

20-
VueMeta.version = version
21-
2220
// automatic install
2321
if (!isUndefined(window) && !isUndefined(window.Vue)) {
2422
/* istanbul ignore next */
25-
Vue.use(VueMeta)
23+
install(window.Vue)
2624
}
2725

28-
export default VueMeta
26+
export default {
27+
version,
28+
install,
29+
hasMetaInfo
30+
}

src/index.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,22 @@ import { version } from '../package.json'
22
import createMixin from './shared/mixin'
33
import setOptions from './shared/options'
44
import $meta from './server/$meta'
5-
export { hasMetaInfo } from './shared/hasMetaInfo'
5+
import { hasMetaInfo } from './shared/hasMetaInfo'
66

77
/**
88
* Plugin install function.
99
* @param {Function} Vue - the Vue constructor.
1010
*/
11-
function VueMeta(Vue, options = {}) {
11+
function install(Vue, options = {}) {
1212
options = setOptions(options)
1313

1414
Vue.prototype.$meta = $meta(options)
1515

1616
Vue.mixin(createMixin(Vue, options))
1717
}
1818

19-
VueMeta.version = version
20-
21-
export default VueMeta
19+
export default {
20+
version,
21+
install,
22+
hasMetaInfo
23+
}

test/plugin-server.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { mount, defaultOptions, hasMetaInfo, VueMetaServerPlugin, loadVueMetaPlugin } from './utils'
1+
import { mount, defaultOptions, VueMetaServerPlugin, loadVueMetaPlugin } from './utils'
22

33
jest.mock('../package.json', () => ({
44
version: 'test-version'
@@ -64,7 +64,7 @@ describe('plugin', () => {
6464

6565
const { vm } = mount(Component, { localVue: Vue })
6666

67-
expect(hasMetaInfo(vm)).toBe(true)
67+
expect(VueMetaServerPlugin.hasMetaInfo(vm)).toBe(true)
6868
expect(warn).not.toHaveBeenCalled()
6969

7070
warn.mockRestore()

test/utils/index.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { mount, createLocalVue } from '@vue/test-utils'
22
import { renderToString } from '@vue/server-test-utils'
33
import VueMetaBrowserPlugin from '../../src/browser'
4-
import VueMetaServerPlugin, { hasMetaInfo } from '../../src'
4+
import VueMetaServerPlugin from '../../src'
55

66
import {
77
keyName,
@@ -15,7 +15,6 @@ import {
1515
export {
1616
mount,
1717
renderToString,
18-
hasMetaInfo,
1918
VueMetaBrowserPlugin,
2019
VueMetaServerPlugin
2120
}

0 commit comments

Comments
 (0)