mirror of
https://github.com/tenrok/vue-meta.git
synced 2026-06-25 10:40:33 +03:00
refactor: move utils to utils folder
This commit is contained in:
committed by
Alexander Lichter
parent
4c967b0b4b
commit
6405724881
+1
-1
@@ -1,7 +1,7 @@
|
|||||||
import { version } from '../package.json'
|
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 { isUndefined } from './shared/is-type'
|
import { isUndefined } from './utils/is-type'
|
||||||
import $meta from './client/$meta'
|
import $meta from './client/$meta'
|
||||||
import { hasMetaInfo } from './shared/meta-helpers'
|
import { hasMetaInfo } from './shared/meta-helpers'
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { hasGlobalWindow } from '../shared/window'
|
import { hasGlobalWindow } from '../utils/window'
|
||||||
|
|
||||||
// fallback to timers if rAF not present
|
// fallback to timers if rAF not present
|
||||||
const stopUpdate = (hasGlobalWindow ? window.cancelAnimationFrame : null) || clearTimeout
|
const stopUpdate = (hasGlobalWindow ? window.cancelAnimationFrame : null) || clearTimeout
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import getMetaInfo from '../shared/getMetaInfo'
|
import getMetaInfo from '../shared/getMetaInfo'
|
||||||
import { isFunction } from '../shared/is-type'
|
import { isFunction } from '../utils/is-type'
|
||||||
import { clientSequences } from '../shared/escaping'
|
import { clientSequences } from '../shared/escaping'
|
||||||
import updateClientMetaInfo from './updateClientMetaInfo'
|
import updateClientMetaInfo from './updateClientMetaInfo'
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { metaInfoOptionKeys, metaInfoAttributeKeys } from '../shared/constants'
|
import { metaInfoOptionKeys, metaInfoAttributeKeys } from '../shared/constants'
|
||||||
import { isArray } from '../shared/is-type'
|
import { isArray } from '../utils/is-type'
|
||||||
import { updateAttribute, updateTag, updateTitle } from './updaters'
|
import { updateAttribute, updateTag, updateTitle } from './updaters'
|
||||||
|
|
||||||
function getTag(tags, tag) {
|
function getTag(tags, tag) {
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { booleanHtmlAttributes } from '../../shared/constants'
|
import { booleanHtmlAttributes } from '../../shared/constants'
|
||||||
import { isArray } from '../../shared/is-type'
|
import { isArray } from '../../utils/is-type'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Updates the document's html tag attributes
|
* Updates the document's html tag attributes
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { isUndefined } from '../../shared/is-type'
|
import { isUndefined } from '../../utils/is-type'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Updates meta tags inside <head> and <body> on the client. Borrowed from `react-helmet`:
|
* Updates meta tags inside <head> and <body> on the client. Borrowed from `react-helmet`:
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { booleanHtmlAttributes } from '../../shared/constants'
|
import { booleanHtmlAttributes } from '../../shared/constants'
|
||||||
import { isUndefined, isArray } from '../../shared/is-type'
|
import { isUndefined, isArray } from '../../utils/is-type'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generates tag attributes for use on the server.
|
* Generates tag attributes for use on the server.
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { booleanHtmlAttributes, tagsWithoutEndTag, tagsWithInnerContent, tagAttributeAsInnerContent } from '../../shared/constants'
|
import { booleanHtmlAttributes, tagsWithoutEndTag, tagsWithInnerContent, tagAttributeAsInnerContent } from '../../shared/constants'
|
||||||
import { isUndefined } from '../../shared/is-type'
|
import { isUndefined } from '../../utils/is-type'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generates meta, base, link, style, script, noscript tags for use on the server
|
* Generates meta, base, link, style, script, noscript tags for use on the server
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
|
import { isString, isArray, isObject } from '../utils/is-type'
|
||||||
import { metaInfoOptionKeys, disableOptionKeys } from './constants'
|
import { metaInfoOptionKeys, disableOptionKeys } from './constants'
|
||||||
import { isString, isArray, isObject } from './is-type'
|
|
||||||
|
|
||||||
export const serverSequences = [
|
export const serverSequences = [
|
||||||
[/&/g, '&'],
|
[/&/g, '&'],
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
|
import { isFunction, isObject } from '../utils/is-type'
|
||||||
import { merge } from './merge'
|
import { merge } from './merge'
|
||||||
import { applyTemplate } from './template'
|
import { applyTemplate } from './template'
|
||||||
import { inMetaInfoBranch } from './meta-helpers'
|
import { inMetaInfoBranch } from './meta-helpers'
|
||||||
import { isFunction, isObject } from './is-type'
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the `opts.option` $option value of the given `opts.component`.
|
* Returns the `opts.option` $option value of the given `opts.component`.
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
|
import { ensureIsArray } from '../utils/ensure'
|
||||||
import { applyTemplate } from './template'
|
import { applyTemplate } from './template'
|
||||||
import { defaultInfo, disableOptionKeys } from './constants'
|
import { defaultInfo, disableOptionKeys } from './constants'
|
||||||
import { ensureIsArray } from './ensure'
|
|
||||||
import { escape } from './escaping'
|
import { escape } from './escaping'
|
||||||
import getComponentOption from './getComponentOption'
|
import getComponentOption from './getComponentOption'
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { isUndefined, isObject } from './is-type'
|
import { isUndefined, isObject } from '../utils/is-type'
|
||||||
|
|
||||||
// Vue $root instance has a _vueMeta object property, otherwise its a boolean true
|
// Vue $root instance has a _vueMeta object property, otherwise its a boolean true
|
||||||
export function hasMetaInfo(vm = this) {
|
export function hasMetaInfo(vm = this) {
|
||||||
|
|||||||
+2
-2
@@ -1,7 +1,7 @@
|
|||||||
import triggerUpdate from '../client/triggerUpdate'
|
import triggerUpdate from '../client/triggerUpdate'
|
||||||
|
import { isUndefined, isFunction } from '../utils/is-type'
|
||||||
|
import { ensuredPush } from '../utils/ensure'
|
||||||
import { hasMetaInfo } from './meta-helpers'
|
import { hasMetaInfo } from './meta-helpers'
|
||||||
import { isUndefined, isFunction } from './is-type'
|
|
||||||
import { ensuredPush } from './ensure'
|
|
||||||
import { addNavGuards } from './nav-guards'
|
import { addNavGuards } from './nav-guards'
|
||||||
|
|
||||||
export default function createMixin(Vue, options) {
|
export default function createMixin(Vue, options) {
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { isFunction } from './is-type'
|
import { isFunction } from '../utils/is-type'
|
||||||
|
|
||||||
export function addNavGuards(vm) {
|
export function addNavGuards(vm) {
|
||||||
// return when nav guards already added or no router exists
|
// return when nav guards already added or no router exists
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { isObject } from './is-type'
|
import { isObject } from '../utils/is-type'
|
||||||
import { defaultOptions } from './constants'
|
import { defaultOptions } from './constants'
|
||||||
|
|
||||||
export default function setOptions(options) {
|
export default function setOptions(options) {
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { isUndefined, isFunction } from './is-type'
|
import { isUndefined, isFunction } from '../utils/is-type'
|
||||||
|
|
||||||
export function applyTemplate({ component, metaTemplateKeyName, contentKeyName }, headObject, template, chunk) {
|
export function applyTemplate({ component, metaTemplateKeyName, contentKeyName }, headObject, template, chunk) {
|
||||||
if (isUndefined(template)) {
|
if (isUndefined(template)) {
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ import Changed from '../components/changed.vue'
|
|||||||
|
|
||||||
const getMetaInfo = component => _getMetaInfo(defaultOptions, component)
|
const getMetaInfo = component => _getMetaInfo(defaultOptions, component)
|
||||||
|
|
||||||
jest.mock('../../src/shared/window', () => ({
|
jest.mock('../../src/utils/window', () => ({
|
||||||
hasGlobalWindow: false
|
hasGlobalWindow: false
|
||||||
}))
|
}))
|
||||||
|
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
/**
|
/**
|
||||||
* @jest-environment node
|
* @jest-environment node
|
||||||
*/
|
*/
|
||||||
import { ensureIsArray } from '../../src/shared/ensure'
|
|
||||||
import setOptions from '../../src/shared/options'
|
import setOptions from '../../src/shared/options'
|
||||||
import { hasGlobalWindowFn } from '../../src/shared/window'
|
|
||||||
import { defaultOptions } from '../../src/shared/constants'
|
import { defaultOptions } from '../../src/shared/constants'
|
||||||
|
import { ensureIsArray } from '../../src/utils/ensure'
|
||||||
|
import { hasGlobalWindowFn } from '../../src/utils/window'
|
||||||
|
|
||||||
describe('shared', () => {
|
describe('shared', () => {
|
||||||
test('ensureIsArray ensures var is array', () => {
|
test('ensureIsArray ensures var is array', () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user