-
Notifications
You must be signed in to change notification settings - Fork 247
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add browser build without ssr code
- Loading branch information
Showing
7 changed files
with
90 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { version } from '../package.json' | ||
import createMixin from './shared/mixin' | ||
import setOptions from './shared/options' | ||
import $meta from './client/$meta' | ||
|
||
/** | ||
* Plugin install function. | ||
* @param {Function} Vue - the Vue constructor. | ||
*/ | ||
function VueMeta(Vue, options = {}) { | ||
options = setOptions(options) | ||
|
||
Vue.prototype.$meta = $meta(options) | ||
|
||
Vue.mixin(createMixin(options)) | ||
} | ||
|
||
VueMeta.version = version | ||
|
||
export default VueMeta |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import refresh from './refresh' | ||
|
||
export default function _$meta(options = {}) { | ||
/** | ||
* Returns an injector for server-side rendering. | ||
* @this {Object} - the Vue instance (a root component) | ||
* @return {Object} - injector | ||
*/ | ||
return function $meta() { | ||
return { | ||
refresh: refresh(options).bind(this) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,20 @@ | ||
import { version } from '../package.json' | ||
import install from './shared/plugin' | ||
import createMixin from './shared/mixin' | ||
import setOptions from './shared/options' | ||
import $meta from './server/$meta' | ||
|
||
install.version = version | ||
/** | ||
* Plugin install function. | ||
* @param {Function} Vue - the Vue constructor. | ||
*/ | ||
function VueMeta(Vue, options = {}) { | ||
options = setOptions(options) | ||
|
||
export default install | ||
Vue.prototype.$meta = $meta(options) | ||
|
||
Vue.mixin(createMixin(options)) | ||
} | ||
|
||
VueMeta.version = version | ||
|
||
export default VueMeta |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { isObject } from '../shared/typeof' | ||
import { | ||
keyName, | ||
attribute, | ||
ssrAttribute, | ||
tagIDKeyName, | ||
metaTemplateKeyName, | ||
contentKeyName | ||
} from './constants' | ||
|
||
// set some default options | ||
const defaultOptions = { | ||
keyName, | ||
contentKeyName, | ||
metaTemplateKeyName, | ||
attribute, | ||
ssrAttribute, | ||
tagIDKeyName | ||
} | ||
|
||
export default function setOptions(options) { | ||
// combine options | ||
options = isObject('object') ? options : {} | ||
|
||
for (const key in defaultOptions) { | ||
if (!options[key]) { | ||
options[key] = defaultOptions[key] | ||
} | ||
} | ||
|
||
return options | ||
} |