From b4feec023222f55e866cea68516687ffbee3d524 Mon Sep 17 00:00:00 2001 From: pimlie Date: Mon, 11 Feb 2019 09:16:51 +0100 Subject: [PATCH] chore: rename constants to use camelCase for better readability --- src/shared/constants.js | 20 +++++++++++++------- src/shared/plugin.js | 23 ++++++++++++----------- test/utils/index.js | 24 ++++++++++++------------ 3 files changed, 37 insertions(+), 30 deletions(-) diff --git a/src/shared/constants.js b/src/shared/constants.js index 90bab14..190e9fd 100644 --- a/src/shared/constants.js +++ b/src/shared/constants.js @@ -4,28 +4,29 @@ // This is the name of the component option that contains all the information that // gets converted to the various meta tags & attributes for the page. -export const VUE_META_KEY_NAME = 'metaInfo' +export const keyName = 'metaInfo' -// This is the attribute vue-meta augments on elements to know which it should +// This is the attribute vue-meta arguments on elements to know which it should // manage and which it should ignore. -export const VUE_META_ATTRIBUTE = 'data-vue-meta' +export const attribute = 'data-vue-meta' // This is the attribute that goes on the `html` tag to inform `vue-meta` // that the server has already generated the meta tags for the initial render. -export const VUE_META_SERVER_RENDERED_ATTRIBUTE = 'data-vue-meta-server-rendered' +export const ssrAttribute = 'data-vue-meta-server-rendered' // This is the property that tells vue-meta to overwrite (instead of append) // an item in a tag list. For example, if you have two `meta` tag list items // that both have `vmid` of "description", then vue-meta will overwrite the // shallowest one with the deepest one. -export const VUE_META_TAG_LIST_ID_KEY_NAME = 'vmid' +export const tagIDKeyName = 'vmid' // This is the key name for possible meta templates -export const VUE_META_TEMPLATE_KEY_NAME = 'template' +export const metaTemplateKeyName = 'template' // This is the key name for the content-holding property -export const VUE_META_CONTENT_KEY = 'content' +export const contentKeyName = 'content' +// List of metaInfo property keys which are configuration options (and dont generate html) export const metaInfoOptionKeys = [ 'titleChunk', 'titleTemplate', @@ -34,14 +35,19 @@ export const metaInfoOptionKeys = [ '__dangerouslyDisableSanitizersByTagID' ] +// List of metaInfo property keys which only generates attributes and no tags export const metaInfoAttributeKeys = [ 'htmlAttrs', 'headAttrs', 'bodyAttrs' ] +// HTML elements which dont have a head tag (shortened to our needs) +// see: https://www.w3.org/TR/html52/document-metadata.html export const tagsWithoutEndTag = ['base', 'meta', 'link'] +// HTML elements which can have inner content (shortened to our needs) export const tagsWithInnerContent = ['noscript', 'script', 'style'] +// Attributes which are inserted as childNodes instead of HTMLAttribute export const tagAttributeAsInnerContent = ['innerHTML', 'cssText'] diff --git a/src/shared/plugin.js b/src/shared/plugin.js index 16a059a..01c128a 100644 --- a/src/shared/plugin.js +++ b/src/shared/plugin.js @@ -2,11 +2,12 @@ import batchUpdate from '../client/batchUpdate' import $meta from './$meta' import { - VUE_META_KEY_NAME, - VUE_META_ATTRIBUTE, - VUE_META_SERVER_RENDERED_ATTRIBUTE, - VUE_META_TAG_LIST_ID_KEY_NAME, - VUE_META_TEMPLATE_KEY_NAME, VUE_META_CONTENT_KEY + keyName, + attribute, + ssrAttribute, + tagIDKeyName, + metaTemplateKeyName, + contentKeyName } from './constants' // automatic install @@ -21,12 +22,12 @@ if (typeof window !== 'undefined' && typeof window.Vue !== 'undefined') { export default function VueMeta(Vue, options = {}) { // set some default options const defaultOptions = { - keyName: VUE_META_KEY_NAME, - contentKeyName: VUE_META_CONTENT_KEY, - metaTemplateKeyName: VUE_META_TEMPLATE_KEY_NAME, - attribute: VUE_META_ATTRIBUTE, - ssrAttribute: VUE_META_SERVER_RENDERED_ATTRIBUTE, - tagIDKeyName: VUE_META_TAG_LIST_ID_KEY_NAME + keyName, + contentKeyName, + metaTemplateKeyName, + attribute, + ssrAttribute, + tagIDKeyName } // combine options diff --git a/test/utils/index.js b/test/utils/index.js index d8abb51..7c84943 100644 --- a/test/utils/index.js +++ b/test/utils/index.js @@ -3,12 +3,12 @@ import { renderToString } from '@vue/server-test-utils' import VueMetaPlugin from '../../src' import { - VUE_META_ATTRIBUTE, - VUE_META_CONTENT_KEY, - VUE_META_KEY_NAME, - VUE_META_SERVER_RENDERED_ATTRIBUTE, - VUE_META_TAG_LIST_ID_KEY_NAME, - VUE_META_TEMPLATE_KEY_NAME + keyName, + attribute, + ssrAttribute, + tagIDKeyName, + metaTemplateKeyName, + contentKeyName } from '../../src/shared/constants' export { @@ -18,12 +18,12 @@ export { } export const defaultOptions = { - keyName: VUE_META_KEY_NAME, - attribute: VUE_META_ATTRIBUTE, - ssrAttribute: VUE_META_SERVER_RENDERED_ATTRIBUTE, - metaTemplateKeyName: VUE_META_TEMPLATE_KEY_NAME, - contentKeyName: VUE_META_CONTENT_KEY, - tagIDKeyName: VUE_META_TAG_LIST_ID_KEY_NAME + keyName, + attribute, + ssrAttribute, + tagIDKeyName, + metaTemplateKeyName, + contentKeyName } export function getVue() {