From c7913511fc0b2680effb7077e642812d7857b7fe Mon Sep 17 00:00:00 2001 From: pimlie Date: Sat, 20 Apr 2019 12:53:48 +0200 Subject: [PATCH] chore: remove old files after merge --- src/server/generators/tagGenerator.js | 59 ------------------------- src/server/generators/titleGenerator.js | 18 -------- 2 files changed, 77 deletions(-) delete mode 100644 src/server/generators/tagGenerator.js delete mode 100644 src/server/generators/titleGenerator.js diff --git a/src/server/generators/tagGenerator.js b/src/server/generators/tagGenerator.js deleted file mode 100644 index 811cc3b..0000000 --- a/src/server/generators/tagGenerator.js +++ /dev/null @@ -1,59 +0,0 @@ -export default function _tagGenerator (options = {}) { - const { attribute } = options - - /** - * Generates meta, base, link, style, script, noscript tags for use on the server - * - * @param {('meta'|'base'|'link'|'style'|'script'|'noscript')} the name of the tag - * @param {(Array|Object)} tags - an array of tag objects or a single object in case of base - * @return {Object} - the tag generator - */ - return function tagGenerator (type, tags) { - return { - text ({ body = false } = {}) { - // build a string containing all tags of this type - return tags.reduce((tagsStr, tag) => { - if (Object.keys(tag).length === 0) return tagsStr // Bail on empty tag object - if (!!tag.body !== body) return tagsStr - // build a string containing all attributes of this tag - const attrs = Object.keys(tag).reduce((attrsStr, attr) => { - switch (attr) { - // these attributes are treated as children on the tag - case 'innerHTML': - case 'cssText': - case 'once': - return attrsStr - // these form the attribute list for this tag - default: - if ([options.tagIDKeyName, 'body'].indexOf(attr) !== -1) { - return `${attrsStr} data-${attr}="${tag[attr]}"` - } - return typeof tag[attr] === 'undefined' - ? `${attrsStr} ${attr}` - : `${attrsStr} ${attr}="${tag[attr]}"` - } - }, '').trim() - - // grab child content from one of these attributes, if possible - const content = tag.innerHTML || tag.cssText || '' - - // generate tag exactly without any other redundant attribute - const observeTag = tag.once - ? '' - : `${attribute}="true" ` - - // these tags have no end tag - const hasEndTag = ['base', 'meta', 'link'].indexOf(type) === -1 - - // these tag types will have content inserted - const hasContent = hasEndTag && ['noscript', 'script', 'style'].indexOf(type) > -1 - - // the final string for this specific tag - return !hasContent - ? `${tagsStr}<${type} ${observeTag}${attrs}${hasEndTag ? '/' : ''}>` - : `${tagsStr}<${type} ${observeTag}${attrs}>${content}` - }, '') - } - } - } -} diff --git a/src/server/generators/titleGenerator.js b/src/server/generators/titleGenerator.js deleted file mode 100644 index 3cecb02..0000000 --- a/src/server/generators/titleGenerator.js +++ /dev/null @@ -1,18 +0,0 @@ -export default function _titleGenerator (options = {}) { - const { attribute } = options - - /** - * Generates title output for the server - * - * @param {'title'} type - the string "title" - * @param {String} data - the title text - * @return {Object} - the title generator - */ - return function titleGenerator (type, data) { - return { - text () { - return String(data).trim() ? `<${type} ${attribute}="true">${data}` : '' - } - } - } -}