react-helmet-async
Advanced tools
Comparing version
154
index.d.ts
@@ -1,86 +0,70 @@ | ||
declare module 'react-helmet-async' { | ||
import * as React from 'react'; | ||
interface OtherElementAttributes { | ||
[key: string]: string | number | boolean | null | undefined; | ||
} | ||
type HtmlProps = JSX.IntrinsicElements['html'] & OtherElementAttributes; | ||
type BodyProps = JSX.IntrinsicElements['body'] & OtherElementAttributes; | ||
type LinkProps = JSX.IntrinsicElements['link']; | ||
type MetaProps = JSX.IntrinsicElements['meta']; | ||
export interface HelmetTags { | ||
baseTag: Array<any>; | ||
linkTags: Array<HTMLLinkElement>; | ||
metaTags: Array<HTMLMetaElement>; | ||
noscriptTags: Array<any>; | ||
scriptTags: Array<HTMLScriptElement>; | ||
styleTags: Array<HTMLStyleElement>; | ||
} | ||
export interface HelmetProps { | ||
async?: boolean; | ||
base?: any; | ||
bodyAttributes?: BodyProps; | ||
defaultTitle?: string; | ||
defer?: boolean; | ||
encodeSpecialCharacters?: boolean; | ||
htmlAttributes?: HtmlProps; | ||
onChangeClientState?: (newState: any, addedTags: HelmetTags, removedTags: HelmetTags) => void; | ||
link?: LinkProps[]; | ||
meta?: MetaProps[]; | ||
noscript?: Array<any>; | ||
script?: Array<any>; | ||
style?: Array<any>; | ||
title?: string; | ||
titleAttributes?: Object; | ||
titleTemplate?: string; | ||
} | ||
export class Helmet extends React.Component<HelmetProps> { | ||
} | ||
export interface HelmetData { | ||
base: HelmetDatum; | ||
bodyAttributes: HelmetHTMLBodyDatum; | ||
htmlAttributes: HelmetHTMLElementDatum; | ||
link: HelmetDatum; | ||
meta: HelmetDatum; | ||
noscript: HelmetDatum; | ||
script: HelmetDatum; | ||
style: HelmetDatum; | ||
title: HelmetDatum; | ||
titleAttributes: HelmetDatum; | ||
} | ||
export interface HelmetDatum { | ||
toString(): string; | ||
toComponent(): React.Component<any>; | ||
} | ||
export interface HelmetHTMLBodyDatum { | ||
toString(): string; | ||
toComponent(): React.HTMLAttributes<HTMLBodyElement>; | ||
} | ||
export interface HelmetHTMLElementDatum { | ||
toString(): string; | ||
toComponent(): React.HTMLAttributes<HTMLHtmlElement>; | ||
} | ||
export interface FilledContext { | ||
helmet: HelmetData; | ||
} | ||
interface ProviderProps { | ||
context?: {}; | ||
} | ||
export class HelmetProvider extends React.Component<ProviderProps> { | ||
static canUseDOM: boolean; | ||
} | ||
export { default as HelmetProvider } from "./Provider"; | ||
export class Helmet { | ||
/** | ||
* @param {Object} base: {"target": "_blank", "href": "http://mysite.com/"} | ||
* @param {Object} bodyAttributes: {"className": "root"} | ||
* @param {String} defaultTitle: "Default Title" | ||
* @param {Boolean} defer: true | ||
* @param {Boolean} encodeSpecialCharacters: true | ||
* @param {Object} htmlAttributes: {"lang": "en", "amp": undefined} | ||
* @param {Array} link: [{"rel": "canonical", "href": "http://mysite.com/example"}] | ||
* @param {Array} meta: [{"name": "description", "content": "Test description"}] | ||
* @param {Array} noscript: [{"innerHTML": "<img src='http://mysite.com/js/test.js'"}] | ||
* @param {Function} onChangeClientState: "(newState) => console.log(newState)" | ||
* @param {Array} script: [{"type": "text/javascript", "src": "http://mysite.com/js/test.js"}] | ||
* @param {Array} style: [{"type": "text/css", "cssText": "div { display: block; color: blue; }"}] | ||
* @param {String} title: "Title" | ||
* @param {Object} titleAttributes: {"itemprop": "name"} | ||
* @param {String} titleTemplate: "MySite.com - %s" | ||
* @param {Boolean} prioritizeSeoTags: false | ||
*/ | ||
static propTypes: { | ||
base: any; | ||
bodyAttributes: any; | ||
children: any; | ||
defaultTitle: any; | ||
defer: any; | ||
encodeSpecialCharacters: any; | ||
htmlAttributes: any; | ||
link: any; | ||
meta: any; | ||
noscript: any; | ||
onChangeClientState: any; | ||
script: any; | ||
style: any; | ||
title: any; | ||
titleAttributes: any; | ||
titleTemplate: any; | ||
prioritizeSeoTags: any; | ||
}; | ||
static defaultProps: { | ||
defer: boolean; | ||
encodeSpecialCharacters: boolean; | ||
prioritizeSeoTags: boolean; | ||
}; | ||
static displayName: string; | ||
shouldComponentUpdate(nextProps: any): boolean; | ||
mapNestedChildrenToProps(child: any, nestedChildren: any): { | ||
innerHTML: any; | ||
cssText?: undefined; | ||
} | { | ||
cssText: any; | ||
innerHTML?: undefined; | ||
}; | ||
flattenArrayTypeChildren({ child, arrayTypeChildren, newChildProps, nestedChildren }: { | ||
child: any; | ||
arrayTypeChildren: any; | ||
newChildProps: any; | ||
nestedChildren: any; | ||
}): any; | ||
mapObjectTypeChildren({ child, newProps, newChildProps, nestedChildren }: { | ||
child: any; | ||
newProps: any; | ||
newChildProps: any; | ||
nestedChildren: any; | ||
}): any; | ||
mapArrayTypeChildrenToProps(arrayTypeChildren: any, newProps: any): any; | ||
warnOnInvalidChildren(child: any, nestedChildren: any): boolean; | ||
mapChildrenToProps(children: any, newProps: any): any; | ||
render(): any; | ||
} |
@@ -1,2 +0,2 @@ | ||
function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}var t=require("react"),r=e(t),n=e(require("prop-types")),i=e(require("react-fast-compare")),o=e(require("invariant")),a=e(require("shallowequal"));function s(){return(s=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e}).apply(this,arguments)}function c(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,e.__proto__=t}function u(e,t){if(null==e)return{};var r,n,i={},o=Object.keys(e);for(n=0;n<o.length;n++)t.indexOf(r=o[n])>=0||(i[r]=e[r]);return i}var l={BASE:"base",BODY:"body",HEAD:"head",HTML:"html",LINK:"link",META:"meta",NOSCRIPT:"noscript",SCRIPT:"script",STYLE:"style",TITLE:"title",FRAGMENT:"Symbol(react.fragment)"},p=Object.keys(l).map(function(e){return l[e]}),f={accesskey:"accessKey",charset:"charSet",class:"className",contenteditable:"contentEditable",contextmenu:"contextMenu","http-equiv":"httpEquiv",itemprop:"itemProp",tabindex:"tabIndex"},d=Object.keys(f).reduce(function(e,t){return e[f[t]]=t,e},{}),h=function(e,t){for(var r=e.length-1;r>=0;r-=1){var n=e[r];if(Object.prototype.hasOwnProperty.call(n,t))return n[t]}return null},m=function(e){var t=h(e,l.TITLE),r=h(e,"titleTemplate");if(Array.isArray(t)&&(t=t.join("")),r&&t)return r.replace(/%s/g,function(){return t});var n=h(e,"defaultTitle");return t||n||void 0},y=function(e){return h(e,"onChangeClientState")||function(){}},T=function(e,t){return t.filter(function(t){return void 0!==t[e]}).map(function(t){return t[e]}).reduce(function(e,t){return s({},e,t)},{})},b=function(e,t){return t.filter(function(e){return void 0!==e[l.BASE]}).map(function(e){return e[l.BASE]}).reverse().reduce(function(t,r){if(!t.length)for(var n=Object.keys(r),i=0;i<n.length;i+=1){var o=n[i].toLowerCase();if(-1!==e.indexOf(o)&&r[o])return t.concat(r)}return t},[])},g=function(e,t,r){var n={};return r.filter(function(t){return!!Array.isArray(t[e])||(void 0!==t[e]&&console&&"function"==typeof console.warn&&console.warn("Helmet: "+e+' should be of type "Array". Instead found type "'+typeof t[e]+'"'),!1)}).map(function(t){return t[e]}).reverse().reduce(function(e,r){var i={};r.filter(function(e){for(var r,o=Object.keys(e),a=0;a<o.length;a+=1){var s=o[a],c=s.toLowerCase();-1===t.indexOf(c)||"rel"===r&&"canonical"===e[r].toLowerCase()||"rel"===c&&"stylesheet"===e[c].toLowerCase()||(r=c),-1===t.indexOf(s)||"innerHTML"!==s&&"cssText"!==s&&"itemprop"!==s||(r=s)}if(!r||!e[r])return!1;var u=e[r].toLowerCase();return n[r]||(n[r]={}),i[r]||(i[r]={}),!n[r][u]&&(i[r][u]=!0,!0)}).reverse().forEach(function(t){return e.push(t)});for(var o=Object.keys(i),a=0;a<o.length;a+=1){var c=o[a],u=s({},n[c],i[c]);n[c]=u}return e},[]).reverse()},v=function(e){return Array.isArray(e)?e.join(""):e},A=[l.NOSCRIPT,l.SCRIPT,l.STYLE],C=function(e,t){return void 0===t&&(t=!0),!1===t?String(e):String(e).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")},O=function(e){return Object.keys(e).reduce(function(t,r){var n=void 0!==e[r]?r+'="'+e[r]+'"':""+r;return t?t+" "+n:n},"")},E=function(e,t){return void 0===t&&(t={}),Object.keys(e).reduce(function(t,r){return t[f[r]||r]=e[r],t},t)},S=function(e,t,n){switch(e){case l.TITLE:return{toComponent:function(){return n=t.titleAttributes,(i={key:e=t.title})["data-rh"]=!0,o=E(n,i),[r.createElement(l.TITLE,o,e)];var e,n,i,o},toString:function(){return function(e,t,r,n){var i=O(r),o=v(t);return i?"<"+e+' data-rh="true" '+i+">"+C(o,n)+"</"+e+">":"<"+e+' data-rh="true">'+C(o,n)+"</"+e+">"}(e,t.title,t.titleAttributes,n)}};case"bodyAttributes":case"htmlAttributes":return{toComponent:function(){return E(t)},toString:function(){return O(t)}};default:return{toComponent:function(){return function(e,t){return t.map(function(t,n){var i,o=((i={key:n})["data-rh"]=!0,i);return Object.keys(t).forEach(function(e){var r=f[e]||e;"innerHTML"===r||"cssText"===r?o.dangerouslySetInnerHTML={__html:t.innerHTML||t.cssText}:o[r]=t[e]}),r.createElement(e,o)})}(e,t)},toString:function(){return function(e,t,r){return t.reduce(function(t,n){var i=Object.keys(n).filter(function(e){return!("innerHTML"===e||"cssText"===e)}).reduce(function(e,t){var i=void 0===n[t]?t:t+'="'+C(n[t],r)+'"';return e?e+" "+i:i},""),o=n.innerHTML||n.cssText||"",a=-1===A.indexOf(e);return t+"<"+e+' data-rh="true" '+i+(a?"/>":">"+o+"</"+e+">")},"")}(e,t,n)}}}},I=function(e){var t=e.bodyAttributes,r=e.encode,n=e.htmlAttributes,i=e.linkTags,o=e.metaTags,a=e.noscriptTags,s=e.scriptTags,c=e.styleTags,u=e.title,p=void 0===u?"":u,f=e.titleAttributes;return{base:S(l.BASE,e.baseTag,r),bodyAttributes:S("bodyAttributes",t,r),htmlAttributes:S("htmlAttributes",n,r),link:S(l.LINK,i,r),meta:S(l.META,o,r),noscript:S(l.NOSCRIPT,a,r),script:S(l.SCRIPT,s,r),style:S(l.STYLE,c,r),title:S(l.TITLE,{title:p,titleAttributes:f},r)}},P=r.createContext({}),x=n.shape({setHelmet:n.func,helmetInstances:n.shape({get:n.func,add:n.func,remove:n.func})}),L="undefined"!=typeof document,j=function(e){function t(r){var n;return(n=e.call(this,r)||this).instances=[],n.value={setHelmet:function(e){n.props.context.helmet=e},helmetInstances:{get:function(){return n.instances},add:function(e){n.instances.push(e)},remove:function(e){var t=n.instances.indexOf(e);n.instances.splice(t,1)}}},t.canUseDOM||(r.context.helmet=I({baseTag:[],bodyAttributes:{},encodeSpecialCharacters:!0,htmlAttributes:{},linkTags:[],metaTags:[],noscriptTags:[],scriptTags:[],styleTags:[],title:"",titleAttributes:{}})),n}return c(t,e),t.prototype.render=function(){return r.createElement(P.Provider,{value:this.value},this.props.children)},t}(t.Component);j.canUseDOM=L,j.propTypes={context:n.shape({helmet:n.shape()}),children:n.node.isRequired},j.defaultProps={context:{}},j.displayName="HelmetProvider";var w=function(e,t){var r,n=document.head||document.querySelector(l.HEAD),i=n.querySelectorAll(e+"[data-rh]"),o=[].slice.call(i),a=[];return t&&t.length&&t.forEach(function(t){var n=document.createElement(e);for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&("innerHTML"===i?n.innerHTML=t.innerHTML:"cssText"===i?n.styleSheet?n.styleSheet.cssText=t.cssText:n.appendChild(document.createTextNode(t.cssText)):n.setAttribute(i,void 0===t[i]?"":t[i]));n.setAttribute("data-rh","true"),o.some(function(e,t){return r=t,n.isEqualNode(e)})?o.splice(r,1):a.push(n)}),o.forEach(function(e){return e.parentNode.removeChild(e)}),a.forEach(function(e){return n.appendChild(e)}),{oldTags:o,newTags:a}},H=function(e,t){var r=document.getElementsByTagName(e)[0];if(r){for(var n=r.getAttribute("data-rh"),i=n?n.split(","):[],o=[].concat(i),a=Object.keys(t),s=0;s<a.length;s+=1){var c=a[s],u=t[c]||"";r.getAttribute(c)!==u&&r.setAttribute(c,u),-1===i.indexOf(c)&&i.push(c);var l=o.indexOf(c);-1!==l&&o.splice(l,1)}for(var p=o.length-1;p>=0;p-=1)r.removeAttribute(o[p]);i.length===o.length?r.removeAttribute("data-rh"):r.getAttribute("data-rh")!==a.join(",")&&r.setAttribute("data-rh",a.join(","))}},k=function(e,t){var r=e.baseTag,n=e.htmlAttributes,i=e.linkTags,o=e.metaTags,a=e.noscriptTags,s=e.onChangeClientState,c=e.scriptTags,u=e.styleTags,p=e.title,f=e.titleAttributes;H(l.BODY,e.bodyAttributes),H(l.HTML,n),function(e,t){void 0!==e&&document.title!==e&&(document.title=v(e)),H(l.TITLE,t)}(p,f);var d={baseTag:w(l.BASE,r),linkTags:w(l.LINK,i),metaTags:w(l.META,o),noscriptTags:w(l.NOSCRIPT,a),scriptTags:w(l.SCRIPT,c),styleTags:w(l.STYLE,u)},h={},m={};Object.keys(d).forEach(function(e){var t=d[e],r=t.newTags,n=t.oldTags;r.length&&(h[e]=r),n.length&&(m[e]=d[e].oldTags)}),t&&t(),s(e,h,m)},M=null,N=function(e){function t(){for(var t,r=arguments.length,n=new Array(r),i=0;i<r;i++)n[i]=arguments[i];return(t=e.call.apply(e,[this].concat(n))||this).rendered=!1,t}c(t,e);var r=t.prototype;return r.shouldComponentUpdate=function(e){return!a(e,this.props)},r.componentDidUpdate=function(){this.emitChange()},r.componentWillUnmount=function(){this.props.context.helmetInstances.remove(this),this.emitChange()},r.emitChange=function(){var e,t,r=this.props.context,n=r.setHelmet,i=null,o=(e=r.helmetInstances.get().map(function(e){var t=s({},e.props);return delete t.context,t}),{baseTag:b(["href"],e),bodyAttributes:T("bodyAttributes",e),defer:h(e,"defer"),encode:h(e,"encodeSpecialCharacters"),htmlAttributes:T("htmlAttributes",e),linkTags:g(l.LINK,["rel","href"],e),metaTags:g(l.META,["name","charset","http-equiv","property","itemprop"],e),noscriptTags:g(l.NOSCRIPT,["innerHTML"],e),onChangeClientState:y(e),scriptTags:g(l.SCRIPT,["src","innerHTML"],e),styleTags:g(l.STYLE,["cssText"],e),title:m(e),titleAttributes:T("titleAttributes",e)});j.canUseDOM?(t=o,M&&cancelAnimationFrame(M),t.defer?M=requestAnimationFrame(function(){k(t,function(){M=null})}):(k(t),M=null)):I&&(i=I(o)),n(i)},r.init=function(){this.rendered||(this.rendered=!0,this.props.context.helmetInstances.add(this),this.emitChange())},r.render=function(){return this.init(),null},t}(t.Component);N.propTypes={context:x.isRequired},N.displayName="HelmetDispatcher";var R=function(e){function t(){return e.apply(this,arguments)||this}c(t,e);var n=t.prototype;return n.shouldComponentUpdate=function(e){return!i(this.props,e)},n.mapNestedChildrenToProps=function(e,t){if(!t)return null;switch(e.type){case l.SCRIPT:case l.NOSCRIPT:return{innerHTML:t};case l.STYLE:return{cssText:t};default:throw new Error("<"+e.type+" /> elements are self-closing and can not contain children. Refer to our API for more information.")}},n.flattenArrayTypeChildren=function(e){var t,r=e.child,n=e.arrayTypeChildren;return s({},n,((t={})[r.type]=[].concat(n[r.type]||[],[s({},e.newChildProps,this.mapNestedChildrenToProps(r,e.nestedChildren))]),t))},n.mapObjectTypeChildren=function(e){var t,r,n=e.child,i=e.newProps,o=e.newChildProps,a=e.nestedChildren;switch(n.type){case l.TITLE:return s({},i,((t={})[n.type]=a,t.titleAttributes=s({},o),t));case l.BODY:return s({},i,{bodyAttributes:s({},o)});case l.HTML:return s({},i,{htmlAttributes:s({},o)});default:return s({},i,((r={})[n.type]=s({},o),r))}},n.mapArrayTypeChildrenToProps=function(e,t){var r=s({},t);return Object.keys(e).forEach(function(t){var n;r=s({},r,((n={})[t]=e[t],n))}),r},n.warnOnInvalidChildren=function(e,t){return o(p.some(function(t){return e.type===t}),"function"==typeof e.type?"You may be attempting to nest <Helmet> components within each other, which is not allowed. Refer to our API for more information.":"Only elements types "+p.join(", ")+" are allowed. Helmet does not support rendering <"+e.type+"> elements. Refer to our API for more information."),o(!t||"string"==typeof t||Array.isArray(t)&&!t.some(function(e){return"string"!=typeof e}),"Helmet expects a string as a child of <"+e.type+">. Did you forget to wrap your children in braces? ( <"+e.type+">{``}</"+e.type+"> ) Refer to our API for more information."),!0},n.mapChildrenToProps=function(e,t){var n=this,i={};return r.Children.forEach(e,function(e){if(e&&e.props){var r=e.props,o=r.children,a=u(r,["children"]),s=Object.keys(a).reduce(function(e,t){return e[d[t]||t]=a[t],e},{}),c=e.type;switch("symbol"==typeof c?c=c.toString():n.warnOnInvalidChildren(e,o),c){case l.FRAGMENT:t=n.mapChildrenToProps(o,t);break;case l.LINK:case l.META:case l.NOSCRIPT:case l.SCRIPT:case l.STYLE:i=n.flattenArrayTypeChildren({child:e,arrayTypeChildren:i,newChildProps:s,nestedChildren:o});break;default:t=n.mapObjectTypeChildren({child:e,newProps:t,newChildProps:s,nestedChildren:o})}}}),this.mapArrayTypeChildrenToProps(i,t)},n.render=function(){var e=this.props,t=e.children,n=s({},u(e,["children"]));return t&&(n=this.mapChildrenToProps(t,n)),r.createElement(P.Consumer,null,function(e){return r.createElement(N,s({},n,{context:e}))})},t}(t.Component);R.propTypes={base:n.object,bodyAttributes:n.object,children:n.oneOfType([n.arrayOf(n.node),n.node]),defaultTitle:n.string,defer:n.bool,encodeSpecialCharacters:n.bool,htmlAttributes:n.object,link:n.arrayOf(n.object),meta:n.arrayOf(n.object),noscript:n.arrayOf(n.object),onChangeClientState:n.func,script:n.arrayOf(n.object),style:n.arrayOf(n.object),title:n.string,titleAttributes:n.object,titleTemplate:n.string},R.defaultProps={defer:!0,encodeSpecialCharacters:!0},R.displayName="Helmet",exports.Helmet=R,exports.HelmetProvider=j; | ||
var t=require("react"),e=require("prop-types"),r=require("react-fast-compare"),n=require("invariant"),i=require("shallowequal");function o(t){return t&&"object"==typeof t&&"default"in t?t:{default:t}}var a=o(t),u=o(e),s=o(r),c=o(n),l=o(i);function f(){return(f=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])}return t}).apply(this,arguments)}function d(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,p(t,e)}function p(t,e){return(p=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function h(t,e){if(null==t)return{};var r,n,i={},o=Object.keys(t);for(n=0;n<o.length;n++)e.indexOf(r=o[n])>=0||(i[r]=t[r]);return i}var y={BASE:"base",BODY:"body",HEAD:"head",HTML:"html",LINK:"link",META:"meta",NOSCRIPT:"noscript",SCRIPT:"script",STYLE:"style",TITLE:"title",FRAGMENT:"Symbol(react.fragment)"},T={rel:["amphtml","canonical","alternate"]},m={type:["application/ld+json"]},g={charset:"",name:["robots","description"],property:["og:type","og:title","og:url","og:image","og:image:alt","og:description","twitter:url","twitter:title","twitter:description","twitter:image","twitter:image:alt","twitter:card","twitter:site"]},b=Object.keys(y).map(function(t){return y[t]}),v={accesskey:"accessKey",charset:"charSet",class:"className",contenteditable:"contentEditable",contextmenu:"contextMenu","http-equiv":"httpEquiv",itemprop:"itemProp",tabindex:"tabIndex"},A=Object.keys(v).reduce(function(t,e){return t[v[e]]=e,t},{}),C=function(t,e){for(var r=t.length-1;r>=0;r-=1){var n=t[r];if(Object.prototype.hasOwnProperty.call(n,e))return n[e]}return null},O=function(t){var e=C(t,y.TITLE),r=C(t,"titleTemplate");if(Array.isArray(e)&&(e=e.join("")),r&&e)return r.replace(/%s/g,function(){return e});var n=C(t,"defaultTitle");return e||n||void 0},S=function(t){return C(t,"onChangeClientState")||function(){}},E=function(t,e){return e.filter(function(e){return void 0!==e[t]}).map(function(e){return e[t]}).reduce(function(t,e){return f({},t,e)},{})},I=function(t,e){return e.filter(function(t){return void 0!==t[y.BASE]}).map(function(t){return t[y.BASE]}).reverse().reduce(function(e,r){if(!e.length)for(var n=Object.keys(r),i=0;i<n.length;i+=1){var o=n[i].toLowerCase();if(-1!==t.indexOf(o)&&r[o])return e.concat(r)}return e},[])},P=function(t,e,r){var n={};return r.filter(function(e){return!!Array.isArray(e[t])||(void 0!==e[t]&&console&&"function"==typeof console.warn&&console.warn("Helmet: "+t+' should be of type "Array". Instead found type "'+typeof e[t]+'"'),!1)}).map(function(e){return e[t]}).reverse().reduce(function(t,r){var i={};r.filter(function(t){for(var r,o=Object.keys(t),a=0;a<o.length;a+=1){var u=o[a],s=u.toLowerCase();-1===e.indexOf(s)||"rel"===r&&"canonical"===t[r].toLowerCase()||"rel"===s&&"stylesheet"===t[s].toLowerCase()||(r=s),-1===e.indexOf(u)||"innerHTML"!==u&&"cssText"!==u&&"itemprop"!==u||(r=u)}if(!r||!t[r])return!1;var c=t[r].toLowerCase();return n[r]||(n[r]={}),i[r]||(i[r]={}),!n[r][c]&&(i[r][c]=!0,!0)}).reverse().forEach(function(e){return t.push(e)});for(var o=Object.keys(i),a=0;a<o.length;a+=1){var u=o[a],s=f({},n[u],i[u]);n[u]=s}return t},[]).reverse()},L=function(t,e){if(Array.isArray(t)&&t.length)for(var r=0;r<t.length;r+=1)if(t[r][e])return!0;return!1},w=function(t){return Array.isArray(t)?t.join(""):t},j=function(t,e){return Array.isArray(t)?t.reduce(function(t,r){return function(t,e){for(var r=Object.keys(t),n=0;n<r.length;n+=1)if(e[r[n]]&&e[r[n]].includes(t[r[n]]))return!0;return!1}(r,e)?t.priority.push(r):t.default.push(r),t},{priority:[],default:[]}):{default:t}},x=[y.NOSCRIPT,y.SCRIPT,y.STYLE],k=function(t,e){return void 0===e&&(e=!0),!1===e?String(t):String(t).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")},M=function(t){return Object.keys(t).reduce(function(e,r){var n=void 0!==t[r]?r+'="'+t[r]+'"':""+r;return e?e+" "+n:n},"")},H=function(t,e){return void 0===e&&(e={}),Object.keys(t).reduce(function(e,r){return e[v[r]||r]=t[r],e},e)},N=function(t,e){return e.map(function(e,r){var n,i=((n={key:r})["data-rh"]=!0,n);return Object.keys(e).forEach(function(t){var r=v[t]||t;"innerHTML"===r||"cssText"===r?i.dangerouslySetInnerHTML={__html:e.innerHTML||e.cssText}:i[r]=e[t]}),a.default.createElement(t,i)})},R=function(t,e,r){switch(t){case y.TITLE:return{toComponent:function(){return r=e.titleAttributes,(n={key:t=e.title})["data-rh"]=!0,i=H(r,n),[a.default.createElement(y.TITLE,i,t)];var t,r,n,i},toString:function(){return function(t,e,r,n){var i=M(r),o=w(e);return i?"<"+t+' data-rh="true" '+i+">"+k(o,n)+"</"+t+">":"<"+t+' data-rh="true">'+k(o,n)+"</"+t+">"}(t,e.title,e.titleAttributes,r)}};case"bodyAttributes":case"htmlAttributes":return{toComponent:function(){return H(e)},toString:function(){return M(e)}};default:return{toComponent:function(){return N(t,e)},toString:function(){return function(t,e,r){return e.reduce(function(e,n){var i=Object.keys(n).filter(function(t){return!("innerHTML"===t||"cssText"===t)}).reduce(function(t,e){var i=void 0===n[e]?e:e+'="'+k(n[e],r)+'"';return t?t+" "+i:i},""),o=n.innerHTML||n.cssText||"",a=-1===x.indexOf(t);return e+"<"+t+' data-rh="true" '+i+(a?"/>":">"+o+"</"+t+">")},"")}(t,e,r)}}}},q=function(t){var e=t.baseTag,r=t.bodyAttributes,n=t.encode,i=t.htmlAttributes,o=t.noscriptTags,a=t.styleTags,u=t.title,s=void 0===u?"":u,c=t.titleAttributes,l=t.linkTags,f=t.metaTags,d=t.scriptTags,p={toComponent:function(){},toString:function(){return""}};if(t.prioritizeSeoTags){var h=function(t){var e=t.linkTags,r=t.scriptTags,n=t.encode,i=j(t.metaTags,g),o=j(e,T),a=j(r,m);return{priorityMethods:{toComponent:function(){return[].concat(N(y.META,i.priority),N(y.LINK,o.priority),N(y.SCRIPT,a.priority))},toString:function(){return R(y.META,i.priority,n)+" "+R(y.LINK,o.priority,n)+" "+R(y.SCRIPT,a.priority,n)}},metaTags:i.default,linkTags:o.default,scriptTags:a.default}}(t);p=h.priorityMethods,l=h.linkTags,f=h.metaTags,d=h.scriptTags}return{priority:p,base:R(y.BASE,e,n),bodyAttributes:R("bodyAttributes",r,n),htmlAttributes:R("htmlAttributes",i,n),link:R(y.LINK,l,n),meta:R(y.META,f,n),noscript:R(y.NOSCRIPT,o,n),script:R(y.SCRIPT,d,n),style:R(y.STYLE,a,n),title:R(y.TITLE,{title:s,titleAttributes:c},n)}},D=a.default.createContext({}),Y=u.default.shape({setHelmet:u.default.func,helmetInstances:u.default.shape({get:u.default.func,add:u.default.func,remove:u.default.func})}),B="undefined"!=typeof document,K=function(t){function e(r){var n;return(n=t.call(this,r)||this).instances=[],n.value={setHelmet:function(t){n.props.context.helmet=t},helmetInstances:{get:function(){return n.instances},add:function(t){n.instances.push(t)},remove:function(t){var e=n.instances.indexOf(t);n.instances.splice(e,1)}}},e.canUseDOM||(r.context.helmet=q({baseTag:[],bodyAttributes:{},encodeSpecialCharacters:!0,htmlAttributes:{},linkTags:[],metaTags:[],noscriptTags:[],scriptTags:[],styleTags:[],title:"",titleAttributes:{}})),n}return d(e,t),e.prototype.render=function(){return a.default.createElement(D.Provider,{value:this.value},this.props.children)},e}(t.Component);K.canUseDOM=B,K.propTypes={context:u.default.shape({helmet:u.default.shape()}),children:u.default.node.isRequired},K.defaultProps={context:{}},K.displayName="HelmetProvider";var U=function(t,e){var r,n=document.head||document.querySelector(y.HEAD),i=n.querySelectorAll(t+"[data-rh]"),o=[].slice.call(i),a=[];return e&&e.length&&e.forEach(function(e){var n=document.createElement(t);for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&("innerHTML"===i?n.innerHTML=e.innerHTML:"cssText"===i?n.styleSheet?n.styleSheet.cssText=e.cssText:n.appendChild(document.createTextNode(e.cssText)):n.setAttribute(i,void 0===e[i]?"":e[i]));n.setAttribute("data-rh","true"),o.some(function(t,e){return r=e,n.isEqualNode(t)})?o.splice(r,1):a.push(n)}),o.forEach(function(t){return t.parentNode.removeChild(t)}),a.forEach(function(t){return n.appendChild(t)}),{oldTags:o,newTags:a}},_=function(t,e){var r=document.getElementsByTagName(t)[0];if(r){for(var n=r.getAttribute("data-rh"),i=n?n.split(","):[],o=[].concat(i),a=Object.keys(e),u=0;u<a.length;u+=1){var s=a[u],c=e[s]||"";r.getAttribute(s)!==c&&r.setAttribute(s,c),-1===i.indexOf(s)&&i.push(s);var l=o.indexOf(s);-1!==l&&o.splice(l,1)}for(var f=o.length-1;f>=0;f-=1)r.removeAttribute(o[f]);i.length===o.length?r.removeAttribute("data-rh"):r.getAttribute("data-rh")!==a.join(",")&&r.setAttribute("data-rh",a.join(","))}},z=function(t,e){var r=t.baseTag,n=t.htmlAttributes,i=t.linkTags,o=t.metaTags,a=t.noscriptTags,u=t.onChangeClientState,s=t.scriptTags,c=t.styleTags,l=t.title,f=t.titleAttributes;_(y.BODY,t.bodyAttributes),_(y.HTML,n),function(t,e){void 0!==t&&document.title!==t&&(document.title=w(t)),_(y.TITLE,e)}(l,f);var d={baseTag:U(y.BASE,r),linkTags:U(y.LINK,i),metaTags:U(y.META,o),noscriptTags:U(y.NOSCRIPT,a),scriptTags:U(y.SCRIPT,s),styleTags:U(y.STYLE,c)},p={},h={};Object.keys(d).forEach(function(t){var e=d[t],r=e.newTags,n=e.oldTags;r.length&&(p[t]=r),n.length&&(h[t]=d[t].oldTags)}),e&&e(),u(t,p,h)},F=null,G=function(t){function e(){for(var e,r=arguments.length,n=new Array(r),i=0;i<r;i++)n[i]=arguments[i];return(e=t.call.apply(t,[this].concat(n))||this).rendered=!1,e}d(e,t);var r=e.prototype;return r.shouldComponentUpdate=function(t){return!l.default(t,this.props)},r.componentDidUpdate=function(){this.emitChange()},r.componentWillUnmount=function(){this.props.context.helmetInstances.remove(this),this.emitChange()},r.emitChange=function(){var t,e,r=this.props.context,n=r.setHelmet,i=null,o=(t=r.helmetInstances.get().map(function(t){var e=f({},t.props);return delete e.context,e}),{baseTag:I(["href"],t),bodyAttributes:E("bodyAttributes",t),defer:C(t,"defer"),encode:C(t,"encodeSpecialCharacters"),htmlAttributes:E("htmlAttributes",t),linkTags:P(y.LINK,["rel","href"],t),metaTags:P(y.META,["name","charset","http-equiv","property","itemprop"],t),noscriptTags:P(y.NOSCRIPT,["innerHTML"],t),onChangeClientState:S(t),scriptTags:P(y.SCRIPT,["src","innerHTML"],t),styleTags:P(y.STYLE,["cssText"],t),title:O(t),titleAttributes:E("titleAttributes",t),prioritizeSeoTags:L(t,"prioritizeSeoTags")});K.canUseDOM?(e=o,F&&cancelAnimationFrame(F),e.defer?F=requestAnimationFrame(function(){z(e,function(){F=null})}):(z(e),F=null)):q&&(i=q(o)),n(i)},r.init=function(){this.rendered||(this.rendered=!0,this.props.context.helmetInstances.add(this),this.emitChange())},r.render=function(){return this.init(),null},e}(t.Component);G.propTypes={context:Y.isRequired},G.displayName="HelmetDispatcher";var W=["children"],J=["children"],Q=function(t){function e(){return t.apply(this,arguments)||this}d(e,t);var r=e.prototype;return r.shouldComponentUpdate=function(t){return!s.default(this.props,t)},r.mapNestedChildrenToProps=function(t,e){if(!e)return null;switch(t.type){case y.SCRIPT:case y.NOSCRIPT:return{innerHTML:e};case y.STYLE:return{cssText:e};default:throw new Error("<"+t.type+" /> elements are self-closing and can not contain children. Refer to our API for more information.")}},r.flattenArrayTypeChildren=function(t){var e,r=t.child,n=t.arrayTypeChildren;return f({},n,((e={})[r.type]=[].concat(n[r.type]||[],[f({},t.newChildProps,this.mapNestedChildrenToProps(r,t.nestedChildren))]),e))},r.mapObjectTypeChildren=function(t){var e,r,n=t.child,i=t.newProps,o=t.newChildProps,a=t.nestedChildren;switch(n.type){case y.TITLE:return f({},i,((e={})[n.type]=a,e.titleAttributes=f({},o),e));case y.BODY:return f({},i,{bodyAttributes:f({},o)});case y.HTML:return f({},i,{htmlAttributes:f({},o)});default:return f({},i,((r={})[n.type]=f({},o),r))}},r.mapArrayTypeChildrenToProps=function(t,e){var r=f({},e);return Object.keys(t).forEach(function(e){var n;r=f({},r,((n={})[e]=t[e],n))}),r},r.warnOnInvalidChildren=function(t,e){return c.default(b.some(function(e){return t.type===e}),"function"==typeof t.type?"You may be attempting to nest <Helmet> components within each other, which is not allowed. Refer to our API for more information.":"Only elements types "+b.join(", ")+" are allowed. Helmet does not support rendering <"+t.type+"> elements. Refer to our API for more information."),c.default(!e||"string"==typeof e||Array.isArray(e)&&!e.some(function(t){return"string"!=typeof t}),"Helmet expects a string as a child of <"+t.type+">. Did you forget to wrap your children in braces? ( <"+t.type+">{``}</"+t.type+"> ) Refer to our API for more information."),!0},r.mapChildrenToProps=function(t,e){var r=this,n={};return a.default.Children.forEach(t,function(t){if(t&&t.props){var i=t.props,o=i.children,a=h(i,W),u=Object.keys(a).reduce(function(t,e){return t[A[e]||e]=a[e],t},{}),s=t.type;switch("symbol"==typeof s?s=s.toString():r.warnOnInvalidChildren(t,o),s){case y.FRAGMENT:e=r.mapChildrenToProps(o,e);break;case y.LINK:case y.META:case y.NOSCRIPT:case y.SCRIPT:case y.STYLE:n=r.flattenArrayTypeChildren({child:t,arrayTypeChildren:n,newChildProps:u,nestedChildren:o});break;default:e=r.mapObjectTypeChildren({child:t,newProps:e,newChildProps:u,nestedChildren:o})}}}),this.mapArrayTypeChildrenToProps(n,e)},r.render=function(){var t=this.props,e=t.children,r=f({},h(t,J));return e&&(r=this.mapChildrenToProps(e,r)),a.default.createElement(D.Consumer,null,function(t){return a.default.createElement(G,f({},r,{context:t}))})},e}(t.Component);Q.propTypes={base:u.default.object,bodyAttributes:u.default.object,children:u.default.oneOfType([u.default.arrayOf(u.default.node),u.default.node]),defaultTitle:u.default.string,defer:u.default.bool,encodeSpecialCharacters:u.default.bool,htmlAttributes:u.default.object,link:u.default.arrayOf(u.default.object),meta:u.default.arrayOf(u.default.object),noscript:u.default.arrayOf(u.default.object),onChangeClientState:u.default.func,script:u.default.arrayOf(u.default.object),style:u.default.arrayOf(u.default.object),title:u.default.string,titleAttributes:u.default.object,titleTemplate:u.default.string,prioritizeSeoTags:u.default.bool},Q.defaultProps={defer:!0,encodeSpecialCharacters:!0,prioritizeSeoTags:!1},Q.displayName="Helmet",exports.Helmet=Q,exports.HelmetProvider=K; | ||
//# sourceMappingURL=index.js.map |
@@ -1,2 +0,2 @@ | ||
import e,{Component as t}from"react";import r from"prop-types";import n from"react-fast-compare";import s from"invariant";import o from"shallowequal";function i(){return(i=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e}).apply(this,arguments)}function a(e,t){if(null==e)return{};var r,n,s={},o=Object.keys(e);for(n=0;n<o.length;n++)t.indexOf(r=o[n])>=0||(s[r]=e[r]);return s}const l={BASE:"base",BODY:"body",HEAD:"head",HTML:"html",LINK:"link",META:"meta",NOSCRIPT:"noscript",SCRIPT:"script",STYLE:"style",TITLE:"title",FRAGMENT:"Symbol(react.fragment)"},c=Object.keys(l).map(e=>l[e]),p={accesskey:"accessKey",charset:"charSet",class:"className",contenteditable:"contentEditable",contextmenu:"contextMenu","http-equiv":"httpEquiv",itemprop:"itemProp",tabindex:"tabIndex"},d=Object.keys(p).reduce((e,t)=>(e[p[t]]=t,e),{}),h=(e,t)=>{for(let r=e.length-1;r>=0;r-=1){const n=e[r];if(Object.prototype.hasOwnProperty.call(n,t))return n[t]}return null},u=e=>{let t=h(e,l.TITLE);const r=h(e,"titleTemplate");if(Array.isArray(t)&&(t=t.join("")),r&&t)return r.replace(/%s/g,()=>t);const n=h(e,"defaultTitle");return t||n||void 0},m=e=>h(e,"onChangeClientState")||(()=>{}),T=(e,t)=>t.filter(t=>void 0!==t[e]).map(t=>t[e]).reduce((e,t)=>i({},e,t),{}),y=(e,t)=>t.filter(e=>void 0!==e[l.BASE]).map(e=>e[l.BASE]).reverse().reduce((t,r)=>{if(!t.length){const n=Object.keys(r);for(let s=0;s<n.length;s+=1){const o=n[s].toLowerCase();if(-1!==e.indexOf(o)&&r[o])return t.concat(r)}}return t},[]),f=(e,t,r)=>{const n={};return r.filter(t=>{return!!Array.isArray(t[e])||(void 0!==t[e]&&(r=`Helmet: ${e} should be of type "Array". Instead found type "${typeof t[e]}"`,console&&"function"==typeof console.warn&&console.warn(r)),!1);var r}).map(t=>t[e]).reverse().reduce((e,r)=>{const s={};r.filter(e=>{let r;const o=Object.keys(e);for(let n=0;n<o.length;n+=1){const s=o[n],i=s.toLowerCase();-1===t.indexOf(i)||"rel"===r&&"canonical"===e[r].toLowerCase()||"rel"===i&&"stylesheet"===e[i].toLowerCase()||(r=i),-1===t.indexOf(s)||"innerHTML"!==s&&"cssText"!==s&&"itemprop"!==s||(r=s)}if(!r||!e[r])return!1;const i=e[r].toLowerCase();return n[r]||(n[r]={}),s[r]||(s[r]={}),!n[r][i]&&(s[r][i]=!0,!0)}).reverse().forEach(t=>e.push(t));const o=Object.keys(s);for(let e=0;e<o.length;e+=1){const t=o[e],r=i({},n[t],s[t]);n[t]=r}return e},[]).reverse()},b=e=>Array.isArray(e)?e.join(""):e,g=[l.NOSCRIPT,l.SCRIPT,l.STYLE],A=(e,t=!0)=>!1===t?String(e):String(e).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'"),C=e=>Object.keys(e).reduce((t,r)=>{const n=void 0!==e[r]?`${r}="${e[r]}"`:""+r;return t?`${t} ${n}`:n},""),O=(e,t={})=>Object.keys(e).reduce((t,r)=>(t[p[r]||r]=e[r],t),t),E=(t,r,n)=>{switch(t){case l.TITLE:return{toComponent:()=>((t,r,n)=>{const s=O(n,{key:r,"data-rh":!0});return[e.createElement(l.TITLE,s,r)]})(0,r.title,r.titleAttributes),toString:()=>((e,t,r,n)=>{const s=C(r),o=b(t);return s?`<${e} data-rh="true" ${s}>${A(o,n)}</${e}>`:`<${e} data-rh="true">${A(o,n)}</${e}>`})(t,r.title,r.titleAttributes,n)};case"bodyAttributes":case"htmlAttributes":return{toComponent:()=>O(r),toString:()=>C(r)};default:return{toComponent:()=>((t,r)=>r.map((r,n)=>{const s={key:n,"data-rh":!0};return Object.keys(r).forEach(e=>{const t=p[e]||e;"innerHTML"===t||"cssText"===t?s.dangerouslySetInnerHTML={__html:r.innerHTML||r.cssText}:s[t]=r[e]}),e.createElement(t,s)}))(t,r),toString:()=>((e,t,r)=>t.reduce((t,n)=>{const s=Object.keys(n).filter(e=>!("innerHTML"===e||"cssText"===e)).reduce((e,t)=>{const s=void 0===n[t]?t:`${t}="${A(n[t],r)}"`;return e?`${e} ${s}`:s},""),o=n.innerHTML||n.cssText||"",i=-1===g.indexOf(e);return`${t}<${e} data-rh="true" ${s}${i?"/>":`>${o}</${e}>`}`},""))(t,r,n)}}},S=({baseTag:e,bodyAttributes:t,encode:r,htmlAttributes:n,linkTags:s,metaTags:o,noscriptTags:i,scriptTags:a,styleTags:c,title:p="",titleAttributes:d})=>({base:E(l.BASE,e,r),bodyAttributes:E("bodyAttributes",t,r),htmlAttributes:E("htmlAttributes",n,r),link:E(l.LINK,s,r),meta:E(l.META,o,r),noscript:E(l.NOSCRIPT,i,r),script:E(l.SCRIPT,a,r),style:E(l.STYLE,c,r),title:E(l.TITLE,{title:p,titleAttributes:d},r)}),x=e.createContext({}),I=r.shape({setHelmet:r.func,helmetInstances:r.shape({get:r.func,add:r.func,remove:r.func})}),P="undefined"!=typeof document;class L extends t{constructor(e){super(e),this.instances=[],this.value={setHelmet:e=>{this.props.context.helmet=e},helmetInstances:{get:()=>this.instances,add:e=>{this.instances.push(e)},remove:e=>{const t=this.instances.indexOf(e);this.instances.splice(t,1)}}},L.canUseDOM||(e.context.helmet=S({baseTag:[],bodyAttributes:{},encodeSpecialCharacters:!0,htmlAttributes:{},linkTags:[],metaTags:[],noscriptTags:[],scriptTags:[],styleTags:[],title:"",titleAttributes:{}}))}render(){return e.createElement(x.Provider,{value:this.value},this.props.children)}}L.canUseDOM=P,L.propTypes={context:r.shape({helmet:r.shape()}),children:r.node.isRequired},L.defaultProps={context:{}},L.displayName="HelmetProvider";const v=(e,t)=>{const r=document.head||document.querySelector(l.HEAD),n=r.querySelectorAll(e+"[data-rh]"),s=[].slice.call(n),o=[];let i;return t&&t.length&&t.forEach(t=>{const r=document.createElement(e);for(const e in t)Object.prototype.hasOwnProperty.call(t,e)&&("innerHTML"===e?r.innerHTML=t.innerHTML:"cssText"===e?r.styleSheet?r.styleSheet.cssText=t.cssText:r.appendChild(document.createTextNode(t.cssText)):r.setAttribute(e,void 0===t[e]?"":t[e]));r.setAttribute("data-rh","true"),s.some((e,t)=>(i=t,r.isEqualNode(e)))?s.splice(i,1):o.push(r)}),s.forEach(e=>e.parentNode.removeChild(e)),o.forEach(e=>r.appendChild(e)),{oldTags:s,newTags:o}},j=(e,t)=>{const r=document.getElementsByTagName(e)[0];if(!r)return;const n=r.getAttribute("data-rh"),s=n?n.split(","):[],o=[].concat(s),i=Object.keys(t);for(let e=0;e<i.length;e+=1){const n=i[e],a=t[n]||"";r.getAttribute(n)!==a&&r.setAttribute(n,a),-1===s.indexOf(n)&&s.push(n);const l=o.indexOf(n);-1!==l&&o.splice(l,1)}for(let e=o.length-1;e>=0;e-=1)r.removeAttribute(o[e]);s.length===o.length?r.removeAttribute("data-rh"):r.getAttribute("data-rh")!==i.join(",")&&r.setAttribute("data-rh",i.join(","))},w=(e,t)=>{const{baseTag:r,bodyAttributes:n,htmlAttributes:s,linkTags:o,metaTags:i,noscriptTags:a,onChangeClientState:c,scriptTags:p,styleTags:d,title:h,titleAttributes:u}=e;j(l.BODY,n),j(l.HTML,s),((e,t)=>{void 0!==e&&document.title!==e&&(document.title=b(e)),j(l.TITLE,t)})(h,u);const m={baseTag:v(l.BASE,r),linkTags:v(l.LINK,o),metaTags:v(l.META,i),noscriptTags:v(l.NOSCRIPT,a),scriptTags:v(l.SCRIPT,p),styleTags:v(l.STYLE,d)},T={},y={};Object.keys(m).forEach(e=>{const{newTags:t,oldTags:r}=m[e];t.length&&(T[e]=t),r.length&&(y[e]=m[e].oldTags)}),t&&t(),c(e,T,y)};let $=null;class H extends t{constructor(...e){super(...e),this.rendered=!1}shouldComponentUpdate(e){return!o(e,this.props)}componentDidUpdate(){this.emitChange()}componentWillUnmount(){const{helmetInstances:e}=this.props.context;e.remove(this),this.emitChange()}emitChange(){const{helmetInstances:e,setHelmet:t}=this.props.context;let r=null;const n=(s=e.get().map(e=>{const t=i({},e.props);return delete t.context,t}),{baseTag:y(["href"],s),bodyAttributes:T("bodyAttributes",s),defer:h(s,"defer"),encode:h(s,"encodeSpecialCharacters"),htmlAttributes:T("htmlAttributes",s),linkTags:f(l.LINK,["rel","href"],s),metaTags:f(l.META,["name","charset","http-equiv","property","itemprop"],s),noscriptTags:f(l.NOSCRIPT,["innerHTML"],s),onChangeClientState:m(s),scriptTags:f(l.SCRIPT,["src","innerHTML"],s),styleTags:f(l.STYLE,["cssText"],s),title:u(s),titleAttributes:T("titleAttributes",s)});var s,o;L.canUseDOM?(o=n,$&&cancelAnimationFrame($),o.defer?$=requestAnimationFrame(()=>{w(o,()=>{$=null})}):(w(o),$=null)):S&&(r=S(n)),t(r)}init(){if(this.rendered)return;this.rendered=!0;const{helmetInstances:e}=this.props.context;e.add(this),this.emitChange()}render(){return this.init(),null}}H.propTypes={context:I.isRequired},H.displayName="HelmetDispatcher";class k extends t{shouldComponentUpdate(e){return!n(this.props,e)}mapNestedChildrenToProps(e,t){if(!t)return null;switch(e.type){case l.SCRIPT:case l.NOSCRIPT:return{innerHTML:t};case l.STYLE:return{cssText:t};default:throw new Error(`<${e.type} /> elements are self-closing and can not contain children. Refer to our API for more information.`)}}flattenArrayTypeChildren({child:e,arrayTypeChildren:t,newChildProps:r,nestedChildren:n}){return i({},t,{[e.type]:[...t[e.type]||[],i({},r,this.mapNestedChildrenToProps(e,n))]})}mapObjectTypeChildren({child:e,newProps:t,newChildProps:r,nestedChildren:n}){switch(e.type){case l.TITLE:return i({},t,{[e.type]:n,titleAttributes:i({},r)});case l.BODY:return i({},t,{bodyAttributes:i({},r)});case l.HTML:return i({},t,{htmlAttributes:i({},r)});default:return i({},t,{[e.type]:i({},r)})}}mapArrayTypeChildrenToProps(e,t){let r=i({},t);return Object.keys(e).forEach(t=>{r=i({},r,{[t]:e[t]})}),r}warnOnInvalidChildren(e,t){return s(c.some(t=>e.type===t),"function"==typeof e.type?"You may be attempting to nest <Helmet> components within each other, which is not allowed. Refer to our API for more information.":`Only elements types ${c.join(", ")} are allowed. Helmet does not support rendering <${e.type}> elements. Refer to our API for more information.`),s(!t||"string"==typeof t||Array.isArray(t)&&!t.some(e=>"string"!=typeof e),`Helmet expects a string as a child of <${e.type}>. Did you forget to wrap your children in braces? ( <${e.type}>{\`\`}</${e.type}> ) Refer to our API for more information.`),!0}mapChildrenToProps(t,r){let n={};return e.Children.forEach(t,e=>{if(!e||!e.props)return;const t=e.props,{children:s}=t,o=a(t,["children"]),i=Object.keys(o).reduce((e,t)=>(e[d[t]||t]=o[t],e),{});let{type:c}=e;switch("symbol"==typeof c?c=c.toString():this.warnOnInvalidChildren(e,s),c){case l.FRAGMENT:r=this.mapChildrenToProps(s,r);break;case l.LINK:case l.META:case l.NOSCRIPT:case l.SCRIPT:case l.STYLE:n=this.flattenArrayTypeChildren({child:e,arrayTypeChildren:n,newChildProps:i,nestedChildren:s});break;default:r=this.mapObjectTypeChildren({child:e,newProps:r,newChildProps:i,nestedChildren:s})}}),this.mapArrayTypeChildrenToProps(n,r)}render(){const t=this.props,{children:r}=t;let n=i({},a(t,["children"]));return r&&(n=this.mapChildrenToProps(r,n)),e.createElement(x.Consumer,null,t=>e.createElement(H,i({},n,{context:t})))}}k.propTypes={base:r.object,bodyAttributes:r.object,children:r.oneOfType([r.arrayOf(r.node),r.node]),defaultTitle:r.string,defer:r.bool,encodeSpecialCharacters:r.bool,htmlAttributes:r.object,link:r.arrayOf(r.object),meta:r.arrayOf(r.object),noscript:r.arrayOf(r.object),onChangeClientState:r.func,script:r.arrayOf(r.object),style:r.arrayOf(r.object),title:r.string,titleAttributes:r.object,titleTemplate:r.string},k.defaultProps={defer:!0,encodeSpecialCharacters:!0},k.displayName="Helmet";export{k as Helmet,L as HelmetProvider}; | ||
import e,{Component as t}from"react";import r from"prop-types";import n from"react-fast-compare";import s from"invariant";import i from"shallowequal";function o(){return(o=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e}).apply(this,arguments)}function a(e,t){if(null==e)return{};var r,n,s={},i=Object.keys(e);for(n=0;n<i.length;n++)t.indexOf(r=i[n])>=0||(s[r]=e[r]);return s}const l={BASE:"base",BODY:"body",HEAD:"head",HTML:"html",LINK:"link",META:"meta",NOSCRIPT:"noscript",SCRIPT:"script",STYLE:"style",TITLE:"title",FRAGMENT:"Symbol(react.fragment)"},c={rel:["amphtml","canonical","alternate"]},p={type:["application/ld+json"]},d={charset:"",name:["robots","description"],property:["og:type","og:title","og:url","og:image","og:image:alt","og:description","twitter:url","twitter:title","twitter:description","twitter:image","twitter:image:alt","twitter:card","twitter:site"]},u=Object.keys(l).map(e=>l[e]),h={accesskey:"accessKey",charset:"charSet",class:"className",contenteditable:"contentEditable",contextmenu:"contextMenu","http-equiv":"httpEquiv",itemprop:"itemProp",tabindex:"tabIndex"},m=Object.keys(h).reduce((e,t)=>(e[h[t]]=t,e),{}),T=(e,t)=>{for(let r=e.length-1;r>=0;r-=1){const n=e[r];if(Object.prototype.hasOwnProperty.call(n,t))return n[t]}return null},y=e=>{let t=T(e,l.TITLE);const r=T(e,"titleTemplate");if(Array.isArray(t)&&(t=t.join("")),r&&t)return r.replace(/%s/g,()=>t);const n=T(e,"defaultTitle");return t||n||void 0},g=e=>T(e,"onChangeClientState")||(()=>{}),f=(e,t)=>t.filter(t=>void 0!==t[e]).map(t=>t[e]).reduce((e,t)=>o({},e,t),{}),b=(e,t)=>t.filter(e=>void 0!==e[l.BASE]).map(e=>e[l.BASE]).reverse().reduce((t,r)=>{if(!t.length){const n=Object.keys(r);for(let s=0;s<n.length;s+=1){const i=n[s].toLowerCase();if(-1!==e.indexOf(i)&&r[i])return t.concat(r)}}return t},[]),A=(e,t,r)=>{const n={};return r.filter(t=>{return!!Array.isArray(t[e])||(void 0!==t[e]&&(r=`Helmet: ${e} should be of type "Array". Instead found type "${typeof t[e]}"`,console&&"function"==typeof console.warn&&console.warn(r)),!1);var r}).map(t=>t[e]).reverse().reduce((e,r)=>{const s={};r.filter(e=>{let r;const i=Object.keys(e);for(let n=0;n<i.length;n+=1){const s=i[n],o=s.toLowerCase();-1===t.indexOf(o)||"rel"===r&&"canonical"===e[r].toLowerCase()||"rel"===o&&"stylesheet"===e[o].toLowerCase()||(r=o),-1===t.indexOf(s)||"innerHTML"!==s&&"cssText"!==s&&"itemprop"!==s||(r=s)}if(!r||!e[r])return!1;const o=e[r].toLowerCase();return n[r]||(n[r]={}),s[r]||(s[r]={}),!n[r][o]&&(s[r][o]=!0,!0)}).reverse().forEach(t=>e.push(t));const i=Object.keys(s);for(let e=0;e<i.length;e+=1){const t=i[e],r=o({},n[t],s[t]);n[t]=r}return e},[]).reverse()},C=(e,t)=>{if(Array.isArray(e)&&e.length)for(let r=0;r<e.length;r+=1)if(e[r][t])return!0;return!1},S=e=>Array.isArray(e)?e.join(""):e,O=(e,t)=>Array.isArray(e)?e.reduce((e,r)=>(((e,t)=>{const r=Object.keys(e);for(let n=0;n<r.length;n+=1)if(t[r[n]]&&t[r[n]].includes(e[r[n]]))return!0;return!1})(r,t)?e.priority.push(r):e.default.push(r),e),{priority:[],default:[]}):{default:e},E=[l.NOSCRIPT,l.SCRIPT,l.STYLE],I=(e,t=!0)=>!1===t?String(e):String(e).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'"),P=e=>Object.keys(e).reduce((t,r)=>{const n=void 0!==e[r]?`${r}="${e[r]}"`:`${r}`;return t?`${t} ${n}`:n},""),x=(e,t={})=>Object.keys(e).reduce((t,r)=>(t[h[r]||r]=e[r],t),t),L=(t,r)=>r.map((r,n)=>{const s={key:n,"data-rh":!0};return Object.keys(r).forEach(e=>{const t=h[e]||e;"innerHTML"===t||"cssText"===t?s.dangerouslySetInnerHTML={__html:r.innerHTML||r.cssText}:s[t]=r[e]}),e.createElement(t,s)}),w=(t,r,n)=>{switch(t){case l.TITLE:return{toComponent:()=>((t,r,n)=>{const s=x(n,{key:r,"data-rh":!0});return[e.createElement(l.TITLE,s,r)]})(0,r.title,r.titleAttributes),toString:()=>((e,t,r,n)=>{const s=P(r),i=S(t);return s?`<${e} data-rh="true" ${s}>${I(i,n)}</${e}>`:`<${e} data-rh="true">${I(i,n)}</${e}>`})(t,r.title,r.titleAttributes,n)};case"bodyAttributes":case"htmlAttributes":return{toComponent:()=>x(r),toString:()=>P(r)};default:return{toComponent:()=>L(t,r),toString:()=>((e,t,r)=>t.reduce((t,n)=>{const s=Object.keys(n).filter(e=>!("innerHTML"===e||"cssText"===e)).reduce((e,t)=>{const s=void 0===n[t]?t:`${t}="${I(n[t],r)}"`;return e?`${e} ${s}`:s},""),i=n.innerHTML||n.cssText||"",o=-1===E.indexOf(e);return`${t}<${e} data-rh="true" ${s}${o?"/>":`>${i}</${e}>`}`},""))(t,r,n)}}},j=e=>{const{baseTag:t,bodyAttributes:r,encode:n,htmlAttributes:s,noscriptTags:i,styleTags:o,title:a="",titleAttributes:u,prioritizeSeoTags:h}=e;let{linkTags:m,metaTags:T,scriptTags:y}=e,g={toComponent:()=>{},toString:()=>""};return h&&({priorityMethods:g,linkTags:m,metaTags:T,scriptTags:y}=(({metaTags:e,linkTags:t,scriptTags:r,encode:n})=>{const s=O(e,d),i=O(t,c),o=O(r,p);return{priorityMethods:{toComponent:()=>[...L(l.META,s.priority),...L(l.LINK,i.priority),...L(l.SCRIPT,o.priority)],toString:()=>`${w(l.META,s.priority,n)} ${w(l.LINK,i.priority,n)} ${w(l.SCRIPT,o.priority,n)}`},metaTags:s.default,linkTags:i.default,scriptTags:o.default}})(e)),{priority:g,base:w(l.BASE,t,n),bodyAttributes:w("bodyAttributes",r,n),htmlAttributes:w("htmlAttributes",s,n),link:w(l.LINK,m,n),meta:w(l.META,T,n),noscript:w(l.NOSCRIPT,i,n),script:w(l.SCRIPT,y,n),style:w(l.STYLE,o,n),title:w(l.TITLE,{title:a,titleAttributes:u},n)}},v=e.createContext({}),$=r.shape({setHelmet:r.func,helmetInstances:r.shape({get:r.func,add:r.func,remove:r.func})}),k="undefined"!=typeof document;class M extends t{constructor(e){super(e),this.instances=[],this.value={setHelmet:e=>{this.props.context.helmet=e},helmetInstances:{get:()=>this.instances,add:e=>{this.instances.push(e)},remove:e=>{const t=this.instances.indexOf(e);this.instances.splice(t,1)}}},M.canUseDOM||(e.context.helmet=j({baseTag:[],bodyAttributes:{},encodeSpecialCharacters:!0,htmlAttributes:{},linkTags:[],metaTags:[],noscriptTags:[],scriptTags:[],styleTags:[],title:"",titleAttributes:{}}))}render(){return e.createElement(v.Provider,{value:this.value},this.props.children)}}M.canUseDOM=k,M.propTypes={context:r.shape({helmet:r.shape()}),children:r.node.isRequired},M.defaultProps={context:{}},M.displayName="HelmetProvider";const H=(e,t)=>{const r=document.head||document.querySelector(l.HEAD),n=r.querySelectorAll(`${e}[data-rh]`),s=[].slice.call(n),i=[];let o;return t&&t.length&&t.forEach(t=>{const r=document.createElement(e);for(const e in t)Object.prototype.hasOwnProperty.call(t,e)&&("innerHTML"===e?r.innerHTML=t.innerHTML:"cssText"===e?r.styleSheet?r.styleSheet.cssText=t.cssText:r.appendChild(document.createTextNode(t.cssText)):r.setAttribute(e,void 0===t[e]?"":t[e]));r.setAttribute("data-rh","true"),s.some((e,t)=>(o=t,r.isEqualNode(e)))?s.splice(o,1):i.push(r)}),s.forEach(e=>e.parentNode.removeChild(e)),i.forEach(e=>r.appendChild(e)),{oldTags:s,newTags:i}},N=(e,t)=>{const r=document.getElementsByTagName(e)[0];if(!r)return;const n=r.getAttribute("data-rh"),s=n?n.split(","):[],i=[].concat(s),o=Object.keys(t);for(let e=0;e<o.length;e+=1){const n=o[e],a=t[n]||"";r.getAttribute(n)!==a&&r.setAttribute(n,a),-1===s.indexOf(n)&&s.push(n);const l=i.indexOf(n);-1!==l&&i.splice(l,1)}for(let e=i.length-1;e>=0;e-=1)r.removeAttribute(i[e]);s.length===i.length?r.removeAttribute("data-rh"):r.getAttribute("data-rh")!==o.join(",")&&r.setAttribute("data-rh",o.join(","))},R=(e,t)=>{const{baseTag:r,bodyAttributes:n,htmlAttributes:s,linkTags:i,metaTags:o,noscriptTags:a,onChangeClientState:c,scriptTags:p,styleTags:d,title:u,titleAttributes:h}=e;N(l.BODY,n),N(l.HTML,s),((e,t)=>{void 0!==e&&document.title!==e&&(document.title=S(e)),N(l.TITLE,t)})(u,h);const m={baseTag:H(l.BASE,r),linkTags:H(l.LINK,i),metaTags:H(l.META,o),noscriptTags:H(l.NOSCRIPT,a),scriptTags:H(l.SCRIPT,p),styleTags:H(l.STYLE,d)},T={},y={};Object.keys(m).forEach(e=>{const{newTags:t,oldTags:r}=m[e];t.length&&(T[e]=t),r.length&&(y[e]=m[e].oldTags)}),t&&t(),c(e,T,y)};let q=null;class D extends t{constructor(...e){super(...e),this.rendered=!1}shouldComponentUpdate(e){return!i(e,this.props)}componentDidUpdate(){this.emitChange()}componentWillUnmount(){const{helmetInstances:e}=this.props.context;e.remove(this),this.emitChange()}emitChange(){const{helmetInstances:e,setHelmet:t}=this.props.context;let r=null;const n=(s=e.get().map(e=>{const t=o({},e.props);return delete t.context,t}),{baseTag:b(["href"],s),bodyAttributes:f("bodyAttributes",s),defer:T(s,"defer"),encode:T(s,"encodeSpecialCharacters"),htmlAttributes:f("htmlAttributes",s),linkTags:A(l.LINK,["rel","href"],s),metaTags:A(l.META,["name","charset","http-equiv","property","itemprop"],s),noscriptTags:A(l.NOSCRIPT,["innerHTML"],s),onChangeClientState:g(s),scriptTags:A(l.SCRIPT,["src","innerHTML"],s),styleTags:A(l.STYLE,["cssText"],s),title:y(s),titleAttributes:f("titleAttributes",s),prioritizeSeoTags:C(s,"prioritizeSeoTags")});var s,i;M.canUseDOM?(i=n,q&&cancelAnimationFrame(q),i.defer?q=requestAnimationFrame(()=>{R(i,()=>{q=null})}):(R(i),q=null)):j&&(r=j(n)),t(r)}init(){if(this.rendered)return;this.rendered=!0;const{helmetInstances:e}=this.props.context;e.add(this),this.emitChange()}render(){return this.init(),null}}D.propTypes={context:$.isRequired},D.displayName="HelmetDispatcher";const Y=["children"],B=["children"];class K extends t{shouldComponentUpdate(e){return!n(this.props,e)}mapNestedChildrenToProps(e,t){if(!t)return null;switch(e.type){case l.SCRIPT:case l.NOSCRIPT:return{innerHTML:t};case l.STYLE:return{cssText:t};default:throw new Error(`<${e.type} /> elements are self-closing and can not contain children. Refer to our API for more information.`)}}flattenArrayTypeChildren({child:e,arrayTypeChildren:t,newChildProps:r,nestedChildren:n}){return o({},t,{[e.type]:[...t[e.type]||[],o({},r,this.mapNestedChildrenToProps(e,n))]})}mapObjectTypeChildren({child:e,newProps:t,newChildProps:r,nestedChildren:n}){switch(e.type){case l.TITLE:return o({},t,{[e.type]:n,titleAttributes:o({},r)});case l.BODY:return o({},t,{bodyAttributes:o({},r)});case l.HTML:return o({},t,{htmlAttributes:o({},r)});default:return o({},t,{[e.type]:o({},r)})}}mapArrayTypeChildrenToProps(e,t){let r=o({},t);return Object.keys(e).forEach(t=>{r=o({},r,{[t]:e[t]})}),r}warnOnInvalidChildren(e,t){return s(u.some(t=>e.type===t),"function"==typeof e.type?"You may be attempting to nest <Helmet> components within each other, which is not allowed. Refer to our API for more information.":`Only elements types ${u.join(", ")} are allowed. Helmet does not support rendering <${e.type}> elements. Refer to our API for more information.`),s(!t||"string"==typeof t||Array.isArray(t)&&!t.some(e=>"string"!=typeof e),`Helmet expects a string as a child of <${e.type}>. Did you forget to wrap your children in braces? ( <${e.type}>{\`\`}</${e.type}> ) Refer to our API for more information.`),!0}mapChildrenToProps(t,r){let n={};return e.Children.forEach(t,e=>{if(!e||!e.props)return;const t=e.props,{children:s}=t,i=a(t,Y),o=Object.keys(i).reduce((e,t)=>(e[m[t]||t]=i[t],e),{});let{type:c}=e;switch("symbol"==typeof c?c=c.toString():this.warnOnInvalidChildren(e,s),c){case l.FRAGMENT:r=this.mapChildrenToProps(s,r);break;case l.LINK:case l.META:case l.NOSCRIPT:case l.SCRIPT:case l.STYLE:n=this.flattenArrayTypeChildren({child:e,arrayTypeChildren:n,newChildProps:o,nestedChildren:s});break;default:r=this.mapObjectTypeChildren({child:e,newProps:r,newChildProps:o,nestedChildren:s})}}),this.mapArrayTypeChildrenToProps(n,r)}render(){const t=this.props,{children:r}=t;let n=o({},a(t,B));return r&&(n=this.mapChildrenToProps(r,n)),e.createElement(v.Consumer,null,t=>e.createElement(D,o({},n,{context:t})))}}K.propTypes={base:r.object,bodyAttributes:r.object,children:r.oneOfType([r.arrayOf(r.node),r.node]),defaultTitle:r.string,defer:r.bool,encodeSpecialCharacters:r.bool,htmlAttributes:r.object,link:r.arrayOf(r.object),meta:r.arrayOf(r.object),noscript:r.arrayOf(r.object),onChangeClientState:r.func,script:r.arrayOf(r.object),style:r.arrayOf(r.object),title:r.string,titleAttributes:r.object,titleTemplate:r.string,prioritizeSeoTags:r.bool},K.defaultProps={defer:!0,encodeSpecialCharacters:!0,prioritizeSeoTags:!1},K.displayName="Helmet";export{K as Helmet,M as HelmetProvider}; | ||
//# sourceMappingURL=index.modern.js.map |
@@ -1,2 +0,2 @@ | ||
import e,{Component as t}from"react";import r from"prop-types";import n from"react-fast-compare";import i from"invariant";import o from"shallowequal";function a(){return(a=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e}).apply(this,arguments)}function s(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,e.__proto__=t}function c(e,t){if(null==e)return{};var r,n,i={},o=Object.keys(e);for(n=0;n<o.length;n++)t.indexOf(r=o[n])>=0||(i[r]=e[r]);return i}var u={BASE:"base",BODY:"body",HEAD:"head",HTML:"html",LINK:"link",META:"meta",NOSCRIPT:"noscript",SCRIPT:"script",STYLE:"style",TITLE:"title",FRAGMENT:"Symbol(react.fragment)"},l=Object.keys(u).map(function(e){return u[e]}),p={accesskey:"accessKey",charset:"charSet",class:"className",contenteditable:"contentEditable",contextmenu:"contextMenu","http-equiv":"httpEquiv",itemprop:"itemProp",tabindex:"tabIndex"},f=Object.keys(p).reduce(function(e,t){return e[p[t]]=t,e},{}),d=function(e,t){for(var r=e.length-1;r>=0;r-=1){var n=e[r];if(Object.prototype.hasOwnProperty.call(n,t))return n[t]}return null},h=function(e){var t=d(e,u.TITLE),r=d(e,"titleTemplate");if(Array.isArray(t)&&(t=t.join("")),r&&t)return r.replace(/%s/g,function(){return t});var n=d(e,"defaultTitle");return t||n||void 0},m=function(e){return d(e,"onChangeClientState")||function(){}},y=function(e,t){return t.filter(function(t){return void 0!==t[e]}).map(function(t){return t[e]}).reduce(function(e,t){return a({},e,t)},{})},T=function(e,t){return t.filter(function(e){return void 0!==e[u.BASE]}).map(function(e){return e[u.BASE]}).reverse().reduce(function(t,r){if(!t.length)for(var n=Object.keys(r),i=0;i<n.length;i+=1){var o=n[i].toLowerCase();if(-1!==e.indexOf(o)&&r[o])return t.concat(r)}return t},[])},b=function(e,t,r){var n={};return r.filter(function(t){return!!Array.isArray(t[e])||(void 0!==t[e]&&console&&"function"==typeof console.warn&&console.warn("Helmet: "+e+' should be of type "Array". Instead found type "'+typeof t[e]+'"'),!1)}).map(function(t){return t[e]}).reverse().reduce(function(e,r){var i={};r.filter(function(e){for(var r,o=Object.keys(e),a=0;a<o.length;a+=1){var s=o[a],c=s.toLowerCase();-1===t.indexOf(c)||"rel"===r&&"canonical"===e[r].toLowerCase()||"rel"===c&&"stylesheet"===e[c].toLowerCase()||(r=c),-1===t.indexOf(s)||"innerHTML"!==s&&"cssText"!==s&&"itemprop"!==s||(r=s)}if(!r||!e[r])return!1;var u=e[r].toLowerCase();return n[r]||(n[r]={}),i[r]||(i[r]={}),!n[r][u]&&(i[r][u]=!0,!0)}).reverse().forEach(function(t){return e.push(t)});for(var o=Object.keys(i),s=0;s<o.length;s+=1){var c=o[s],u=a({},n[c],i[c]);n[c]=u}return e},[]).reverse()},g=function(e){return Array.isArray(e)?e.join(""):e},v=[u.NOSCRIPT,u.SCRIPT,u.STYLE],A=function(e,t){return void 0===t&&(t=!0),!1===t?String(e):String(e).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")},C=function(e){return Object.keys(e).reduce(function(t,r){var n=void 0!==e[r]?r+'="'+e[r]+'"':""+r;return t?t+" "+n:n},"")},O=function(e,t){return void 0===t&&(t={}),Object.keys(e).reduce(function(t,r){return t[p[r]||r]=e[r],t},t)},E=function(t,r,n){switch(t){case u.TITLE:return{toComponent:function(){return n=r.titleAttributes,(i={key:t=r.title})["data-rh"]=!0,o=O(n,i),[e.createElement(u.TITLE,o,t)];var t,n,i,o},toString:function(){return function(e,t,r,n){var i=C(r),o=g(t);return i?"<"+e+' data-rh="true" '+i+">"+A(o,n)+"</"+e+">":"<"+e+' data-rh="true">'+A(o,n)+"</"+e+">"}(t,r.title,r.titleAttributes,n)}};case"bodyAttributes":case"htmlAttributes":return{toComponent:function(){return O(r)},toString:function(){return C(r)}};default:return{toComponent:function(){return function(t,r){return r.map(function(r,n){var i,o=((i={key:n})["data-rh"]=!0,i);return Object.keys(r).forEach(function(e){var t=p[e]||e;"innerHTML"===t||"cssText"===t?o.dangerouslySetInnerHTML={__html:r.innerHTML||r.cssText}:o[t]=r[e]}),e.createElement(t,o)})}(t,r)},toString:function(){return function(e,t,r){return t.reduce(function(t,n){var i=Object.keys(n).filter(function(e){return!("innerHTML"===e||"cssText"===e)}).reduce(function(e,t){var i=void 0===n[t]?t:t+'="'+A(n[t],r)+'"';return e?e+" "+i:i},""),o=n.innerHTML||n.cssText||"",a=-1===v.indexOf(e);return t+"<"+e+' data-rh="true" '+i+(a?"/>":">"+o+"</"+e+">")},"")}(t,r,n)}}}},S=function(e){var t=e.bodyAttributes,r=e.encode,n=e.htmlAttributes,i=e.linkTags,o=e.metaTags,a=e.noscriptTags,s=e.scriptTags,c=e.styleTags,l=e.title,p=void 0===l?"":l,f=e.titleAttributes;return{base:E(u.BASE,e.baseTag,r),bodyAttributes:E("bodyAttributes",t,r),htmlAttributes:E("htmlAttributes",n,r),link:E(u.LINK,i,r),meta:E(u.META,o,r),noscript:E(u.NOSCRIPT,a,r),script:E(u.SCRIPT,s,r),style:E(u.STYLE,c,r),title:E(u.TITLE,{title:p,titleAttributes:f},r)}},I=e.createContext({}),P=r.shape({setHelmet:r.func,helmetInstances:r.shape({get:r.func,add:r.func,remove:r.func})}),L="undefined"!=typeof document,x=function(t){function r(e){var n;return(n=t.call(this,e)||this).instances=[],n.value={setHelmet:function(e){n.props.context.helmet=e},helmetInstances:{get:function(){return n.instances},add:function(e){n.instances.push(e)},remove:function(e){var t=n.instances.indexOf(e);n.instances.splice(t,1)}}},r.canUseDOM||(e.context.helmet=S({baseTag:[],bodyAttributes:{},encodeSpecialCharacters:!0,htmlAttributes:{},linkTags:[],metaTags:[],noscriptTags:[],scriptTags:[],styleTags:[],title:"",titleAttributes:{}})),n}return s(r,t),r.prototype.render=function(){return e.createElement(I.Provider,{value:this.value},this.props.children)},r}(t);x.canUseDOM=L,x.propTypes={context:r.shape({helmet:r.shape()}),children:r.node.isRequired},x.defaultProps={context:{}},x.displayName="HelmetProvider";var j=function(e,t){var r,n=document.head||document.querySelector(u.HEAD),i=n.querySelectorAll(e+"[data-rh]"),o=[].slice.call(i),a=[];return t&&t.length&&t.forEach(function(t){var n=document.createElement(e);for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&("innerHTML"===i?n.innerHTML=t.innerHTML:"cssText"===i?n.styleSheet?n.styleSheet.cssText=t.cssText:n.appendChild(document.createTextNode(t.cssText)):n.setAttribute(i,void 0===t[i]?"":t[i]));n.setAttribute("data-rh","true"),o.some(function(e,t){return r=t,n.isEqualNode(e)})?o.splice(r,1):a.push(n)}),o.forEach(function(e){return e.parentNode.removeChild(e)}),a.forEach(function(e){return n.appendChild(e)}),{oldTags:o,newTags:a}},w=function(e,t){var r=document.getElementsByTagName(e)[0];if(r){for(var n=r.getAttribute("data-rh"),i=n?n.split(","):[],o=[].concat(i),a=Object.keys(t),s=0;s<a.length;s+=1){var c=a[s],u=t[c]||"";r.getAttribute(c)!==u&&r.setAttribute(c,u),-1===i.indexOf(c)&&i.push(c);var l=o.indexOf(c);-1!==l&&o.splice(l,1)}for(var p=o.length-1;p>=0;p-=1)r.removeAttribute(o[p]);i.length===o.length?r.removeAttribute("data-rh"):r.getAttribute("data-rh")!==a.join(",")&&r.setAttribute("data-rh",a.join(","))}},H=function(e,t){var r=e.baseTag,n=e.htmlAttributes,i=e.linkTags,o=e.metaTags,a=e.noscriptTags,s=e.onChangeClientState,c=e.scriptTags,l=e.styleTags,p=e.title,f=e.titleAttributes;w(u.BODY,e.bodyAttributes),w(u.HTML,n),function(e,t){void 0!==e&&document.title!==e&&(document.title=g(e)),w(u.TITLE,t)}(p,f);var d={baseTag:j(u.BASE,r),linkTags:j(u.LINK,i),metaTags:j(u.META,o),noscriptTags:j(u.NOSCRIPT,a),scriptTags:j(u.SCRIPT,c),styleTags:j(u.STYLE,l)},h={},m={};Object.keys(d).forEach(function(e){var t=d[e],r=t.newTags,n=t.oldTags;r.length&&(h[e]=r),n.length&&(m[e]=d[e].oldTags)}),t&&t(),s(e,h,m)},k=null,M=function(e){function t(){for(var t,r=arguments.length,n=new Array(r),i=0;i<r;i++)n[i]=arguments[i];return(t=e.call.apply(e,[this].concat(n))||this).rendered=!1,t}s(t,e);var r=t.prototype;return r.shouldComponentUpdate=function(e){return!o(e,this.props)},r.componentDidUpdate=function(){this.emitChange()},r.componentWillUnmount=function(){this.props.context.helmetInstances.remove(this),this.emitChange()},r.emitChange=function(){var e,t,r=this.props.context,n=r.setHelmet,i=null,o=(e=r.helmetInstances.get().map(function(e){var t=a({},e.props);return delete t.context,t}),{baseTag:T(["href"],e),bodyAttributes:y("bodyAttributes",e),defer:d(e,"defer"),encode:d(e,"encodeSpecialCharacters"),htmlAttributes:y("htmlAttributes",e),linkTags:b(u.LINK,["rel","href"],e),metaTags:b(u.META,["name","charset","http-equiv","property","itemprop"],e),noscriptTags:b(u.NOSCRIPT,["innerHTML"],e),onChangeClientState:m(e),scriptTags:b(u.SCRIPT,["src","innerHTML"],e),styleTags:b(u.STYLE,["cssText"],e),title:h(e),titleAttributes:y("titleAttributes",e)});x.canUseDOM?(t=o,k&&cancelAnimationFrame(k),t.defer?k=requestAnimationFrame(function(){H(t,function(){k=null})}):(H(t),k=null)):S&&(i=S(o)),n(i)},r.init=function(){this.rendered||(this.rendered=!0,this.props.context.helmetInstances.add(this),this.emitChange())},r.render=function(){return this.init(),null},t}(t);M.propTypes={context:P.isRequired},M.displayName="HelmetDispatcher";var N=function(t){function r(){return t.apply(this,arguments)||this}s(r,t);var o=r.prototype;return o.shouldComponentUpdate=function(e){return!n(this.props,e)},o.mapNestedChildrenToProps=function(e,t){if(!t)return null;switch(e.type){case u.SCRIPT:case u.NOSCRIPT:return{innerHTML:t};case u.STYLE:return{cssText:t};default:throw new Error("<"+e.type+" /> elements are self-closing and can not contain children. Refer to our API for more information.")}},o.flattenArrayTypeChildren=function(e){var t,r=e.child,n=e.arrayTypeChildren;return a({},n,((t={})[r.type]=[].concat(n[r.type]||[],[a({},e.newChildProps,this.mapNestedChildrenToProps(r,e.nestedChildren))]),t))},o.mapObjectTypeChildren=function(e){var t,r,n=e.child,i=e.newProps,o=e.newChildProps,s=e.nestedChildren;switch(n.type){case u.TITLE:return a({},i,((t={})[n.type]=s,t.titleAttributes=a({},o),t));case u.BODY:return a({},i,{bodyAttributes:a({},o)});case u.HTML:return a({},i,{htmlAttributes:a({},o)});default:return a({},i,((r={})[n.type]=a({},o),r))}},o.mapArrayTypeChildrenToProps=function(e,t){var r=a({},t);return Object.keys(e).forEach(function(t){var n;r=a({},r,((n={})[t]=e[t],n))}),r},o.warnOnInvalidChildren=function(e,t){return i(l.some(function(t){return e.type===t}),"function"==typeof e.type?"You may be attempting to nest <Helmet> components within each other, which is not allowed. Refer to our API for more information.":"Only elements types "+l.join(", ")+" are allowed. Helmet does not support rendering <"+e.type+"> elements. Refer to our API for more information."),i(!t||"string"==typeof t||Array.isArray(t)&&!t.some(function(e){return"string"!=typeof e}),"Helmet expects a string as a child of <"+e.type+">. Did you forget to wrap your children in braces? ( <"+e.type+">{``}</"+e.type+"> ) Refer to our API for more information."),!0},o.mapChildrenToProps=function(t,r){var n=this,i={};return e.Children.forEach(t,function(e){if(e&&e.props){var t=e.props,o=t.children,a=c(t,["children"]),s=Object.keys(a).reduce(function(e,t){return e[f[t]||t]=a[t],e},{}),l=e.type;switch("symbol"==typeof l?l=l.toString():n.warnOnInvalidChildren(e,o),l){case u.FRAGMENT:r=n.mapChildrenToProps(o,r);break;case u.LINK:case u.META:case u.NOSCRIPT:case u.SCRIPT:case u.STYLE:i=n.flattenArrayTypeChildren({child:e,arrayTypeChildren:i,newChildProps:s,nestedChildren:o});break;default:r=n.mapObjectTypeChildren({child:e,newProps:r,newChildProps:s,nestedChildren:o})}}}),this.mapArrayTypeChildrenToProps(i,r)},o.render=function(){var t=this.props,r=t.children,n=a({},c(t,["children"]));return r&&(n=this.mapChildrenToProps(r,n)),e.createElement(I.Consumer,null,function(t){return e.createElement(M,a({},n,{context:t}))})},r}(t);N.propTypes={base:r.object,bodyAttributes:r.object,children:r.oneOfType([r.arrayOf(r.node),r.node]),defaultTitle:r.string,defer:r.bool,encodeSpecialCharacters:r.bool,htmlAttributes:r.object,link:r.arrayOf(r.object),meta:r.arrayOf(r.object),noscript:r.arrayOf(r.object),onChangeClientState:r.func,script:r.arrayOf(r.object),style:r.arrayOf(r.object),title:r.string,titleAttributes:r.object,titleTemplate:r.string},N.defaultProps={defer:!0,encodeSpecialCharacters:!0},N.displayName="Helmet";export{N as Helmet,x as HelmetProvider}; | ||
import t,{Component as e}from"react";import r from"prop-types";import n from"react-fast-compare";import i from"invariant";import o from"shallowequal";function a(){return(a=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])}return t}).apply(this,arguments)}function s(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,c(t,e)}function c(t,e){return(c=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function u(t,e){if(null==t)return{};var r,n,i={},o=Object.keys(t);for(n=0;n<o.length;n++)e.indexOf(r=o[n])>=0||(i[r]=t[r]);return i}var l={BASE:"base",BODY:"body",HEAD:"head",HTML:"html",LINK:"link",META:"meta",NOSCRIPT:"noscript",SCRIPT:"script",STYLE:"style",TITLE:"title",FRAGMENT:"Symbol(react.fragment)"},p={rel:["amphtml","canonical","alternate"]},f={type:["application/ld+json"]},d={charset:"",name:["robots","description"],property:["og:type","og:title","og:url","og:image","og:image:alt","og:description","twitter:url","twitter:title","twitter:description","twitter:image","twitter:image:alt","twitter:card","twitter:site"]},h=Object.keys(l).map(function(t){return l[t]}),m={accesskey:"accessKey",charset:"charSet",class:"className",contenteditable:"contentEditable",contextmenu:"contextMenu","http-equiv":"httpEquiv",itemprop:"itemProp",tabindex:"tabIndex"},y=Object.keys(m).reduce(function(t,e){return t[m[e]]=e,t},{}),T=function(t,e){for(var r=t.length-1;r>=0;r-=1){var n=t[r];if(Object.prototype.hasOwnProperty.call(n,e))return n[e]}return null},g=function(t){var e=T(t,l.TITLE),r=T(t,"titleTemplate");if(Array.isArray(e)&&(e=e.join("")),r&&e)return r.replace(/%s/g,function(){return e});var n=T(t,"defaultTitle");return e||n||void 0},b=function(t){return T(t,"onChangeClientState")||function(){}},v=function(t,e){return e.filter(function(e){return void 0!==e[t]}).map(function(e){return e[t]}).reduce(function(t,e){return a({},t,e)},{})},A=function(t,e){return e.filter(function(t){return void 0!==t[l.BASE]}).map(function(t){return t[l.BASE]}).reverse().reduce(function(e,r){if(!e.length)for(var n=Object.keys(r),i=0;i<n.length;i+=1){var o=n[i].toLowerCase();if(-1!==t.indexOf(o)&&r[o])return e.concat(r)}return e},[])},C=function(t,e,r){var n={};return r.filter(function(e){return!!Array.isArray(e[t])||(void 0!==e[t]&&console&&"function"==typeof console.warn&&console.warn("Helmet: "+t+' should be of type "Array". Instead found type "'+typeof e[t]+'"'),!1)}).map(function(e){return e[t]}).reverse().reduce(function(t,r){var i={};r.filter(function(t){for(var r,o=Object.keys(t),a=0;a<o.length;a+=1){var s=o[a],c=s.toLowerCase();-1===e.indexOf(c)||"rel"===r&&"canonical"===t[r].toLowerCase()||"rel"===c&&"stylesheet"===t[c].toLowerCase()||(r=c),-1===e.indexOf(s)||"innerHTML"!==s&&"cssText"!==s&&"itemprop"!==s||(r=s)}if(!r||!t[r])return!1;var u=t[r].toLowerCase();return n[r]||(n[r]={}),i[r]||(i[r]={}),!n[r][u]&&(i[r][u]=!0,!0)}).reverse().forEach(function(e){return t.push(e)});for(var o=Object.keys(i),s=0;s<o.length;s+=1){var c=o[s],u=a({},n[c],i[c]);n[c]=u}return t},[]).reverse()},O=function(t,e){if(Array.isArray(t)&&t.length)for(var r=0;r<t.length;r+=1)if(t[r][e])return!0;return!1},S=function(t){return Array.isArray(t)?t.join(""):t},E=function(t,e){return Array.isArray(t)?t.reduce(function(t,r){return function(t,e){for(var r=Object.keys(t),n=0;n<r.length;n+=1)if(e[r[n]]&&e[r[n]].includes(t[r[n]]))return!0;return!1}(r,e)?t.priority.push(r):t.default.push(r),t},{priority:[],default:[]}):{default:t}},I=[l.NOSCRIPT,l.SCRIPT,l.STYLE],P=function(t,e){return void 0===e&&(e=!0),!1===e?String(t):String(t).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")},L=function(t){return Object.keys(t).reduce(function(e,r){var n=void 0!==t[r]?r+'="'+t[r]+'"':""+r;return e?e+" "+n:n},"")},w=function(t,e){return void 0===e&&(e={}),Object.keys(t).reduce(function(e,r){return e[m[r]||r]=t[r],e},e)},j=function(e,r){return r.map(function(r,n){var i,o=((i={key:n})["data-rh"]=!0,i);return Object.keys(r).forEach(function(t){var e=m[t]||t;"innerHTML"===e||"cssText"===e?o.dangerouslySetInnerHTML={__html:r.innerHTML||r.cssText}:o[e]=r[t]}),t.createElement(e,o)})},x=function(e,r,n){switch(e){case l.TITLE:return{toComponent:function(){return n=r.titleAttributes,(i={key:e=r.title})["data-rh"]=!0,o=w(n,i),[t.createElement(l.TITLE,o,e)];var e,n,i,o},toString:function(){return function(t,e,r,n){var i=L(r),o=S(e);return i?"<"+t+' data-rh="true" '+i+">"+P(o,n)+"</"+t+">":"<"+t+' data-rh="true">'+P(o,n)+"</"+t+">"}(e,r.title,r.titleAttributes,n)}};case"bodyAttributes":case"htmlAttributes":return{toComponent:function(){return w(r)},toString:function(){return L(r)}};default:return{toComponent:function(){return j(e,r)},toString:function(){return function(t,e,r){return e.reduce(function(e,n){var i=Object.keys(n).filter(function(t){return!("innerHTML"===t||"cssText"===t)}).reduce(function(t,e){var i=void 0===n[e]?e:e+'="'+P(n[e],r)+'"';return t?t+" "+i:i},""),o=n.innerHTML||n.cssText||"",a=-1===I.indexOf(t);return e+"<"+t+' data-rh="true" '+i+(a?"/>":">"+o+"</"+t+">")},"")}(e,r,n)}}}},k=function(t){var e=t.baseTag,r=t.bodyAttributes,n=t.encode,i=t.htmlAttributes,o=t.noscriptTags,a=t.styleTags,s=t.title,c=void 0===s?"":s,u=t.titleAttributes,h=t.linkTags,m=t.metaTags,y=t.scriptTags,T={toComponent:function(){},toString:function(){return""}};if(t.prioritizeSeoTags){var g=function(t){var e=t.linkTags,r=t.scriptTags,n=t.encode,i=E(t.metaTags,d),o=E(e,p),a=E(r,f);return{priorityMethods:{toComponent:function(){return[].concat(j(l.META,i.priority),j(l.LINK,o.priority),j(l.SCRIPT,a.priority))},toString:function(){return x(l.META,i.priority,n)+" "+x(l.LINK,o.priority,n)+" "+x(l.SCRIPT,a.priority,n)}},metaTags:i.default,linkTags:o.default,scriptTags:a.default}}(t);T=g.priorityMethods,h=g.linkTags,m=g.metaTags,y=g.scriptTags}return{priority:T,base:x(l.BASE,e,n),bodyAttributes:x("bodyAttributes",r,n),htmlAttributes:x("htmlAttributes",i,n),link:x(l.LINK,h,n),meta:x(l.META,m,n),noscript:x(l.NOSCRIPT,o,n),script:x(l.SCRIPT,y,n),style:x(l.STYLE,a,n),title:x(l.TITLE,{title:c,titleAttributes:u},n)}},M=t.createContext({}),H=r.shape({setHelmet:r.func,helmetInstances:r.shape({get:r.func,add:r.func,remove:r.func})}),N="undefined"!=typeof document,R=function(e){function r(t){var n;return(n=e.call(this,t)||this).instances=[],n.value={setHelmet:function(t){n.props.context.helmet=t},helmetInstances:{get:function(){return n.instances},add:function(t){n.instances.push(t)},remove:function(t){var e=n.instances.indexOf(t);n.instances.splice(e,1)}}},r.canUseDOM||(t.context.helmet=k({baseTag:[],bodyAttributes:{},encodeSpecialCharacters:!0,htmlAttributes:{},linkTags:[],metaTags:[],noscriptTags:[],scriptTags:[],styleTags:[],title:"",titleAttributes:{}})),n}return s(r,e),r.prototype.render=function(){return t.createElement(M.Provider,{value:this.value},this.props.children)},r}(e);R.canUseDOM=N,R.propTypes={context:r.shape({helmet:r.shape()}),children:r.node.isRequired},R.defaultProps={context:{}},R.displayName="HelmetProvider";var q=function(t,e){var r,n=document.head||document.querySelector(l.HEAD),i=n.querySelectorAll(t+"[data-rh]"),o=[].slice.call(i),a=[];return e&&e.length&&e.forEach(function(e){var n=document.createElement(t);for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&("innerHTML"===i?n.innerHTML=e.innerHTML:"cssText"===i?n.styleSheet?n.styleSheet.cssText=e.cssText:n.appendChild(document.createTextNode(e.cssText)):n.setAttribute(i,void 0===e[i]?"":e[i]));n.setAttribute("data-rh","true"),o.some(function(t,e){return r=e,n.isEqualNode(t)})?o.splice(r,1):a.push(n)}),o.forEach(function(t){return t.parentNode.removeChild(t)}),a.forEach(function(t){return n.appendChild(t)}),{oldTags:o,newTags:a}},D=function(t,e){var r=document.getElementsByTagName(t)[0];if(r){for(var n=r.getAttribute("data-rh"),i=n?n.split(","):[],o=[].concat(i),a=Object.keys(e),s=0;s<a.length;s+=1){var c=a[s],u=e[c]||"";r.getAttribute(c)!==u&&r.setAttribute(c,u),-1===i.indexOf(c)&&i.push(c);var l=o.indexOf(c);-1!==l&&o.splice(l,1)}for(var p=o.length-1;p>=0;p-=1)r.removeAttribute(o[p]);i.length===o.length?r.removeAttribute("data-rh"):r.getAttribute("data-rh")!==a.join(",")&&r.setAttribute("data-rh",a.join(","))}},Y=function(t,e){var r=t.baseTag,n=t.htmlAttributes,i=t.linkTags,o=t.metaTags,a=t.noscriptTags,s=t.onChangeClientState,c=t.scriptTags,u=t.styleTags,p=t.title,f=t.titleAttributes;D(l.BODY,t.bodyAttributes),D(l.HTML,n),function(t,e){void 0!==t&&document.title!==t&&(document.title=S(t)),D(l.TITLE,e)}(p,f);var d={baseTag:q(l.BASE,r),linkTags:q(l.LINK,i),metaTags:q(l.META,o),noscriptTags:q(l.NOSCRIPT,a),scriptTags:q(l.SCRIPT,c),styleTags:q(l.STYLE,u)},h={},m={};Object.keys(d).forEach(function(t){var e=d[t],r=e.newTags,n=e.oldTags;r.length&&(h[t]=r),n.length&&(m[t]=d[t].oldTags)}),e&&e(),s(t,h,m)},B=null,K=function(t){function e(){for(var e,r=arguments.length,n=new Array(r),i=0;i<r;i++)n[i]=arguments[i];return(e=t.call.apply(t,[this].concat(n))||this).rendered=!1,e}s(e,t);var r=e.prototype;return r.shouldComponentUpdate=function(t){return!o(t,this.props)},r.componentDidUpdate=function(){this.emitChange()},r.componentWillUnmount=function(){this.props.context.helmetInstances.remove(this),this.emitChange()},r.emitChange=function(){var t,e,r=this.props.context,n=r.setHelmet,i=null,o=(t=r.helmetInstances.get().map(function(t){var e=a({},t.props);return delete e.context,e}),{baseTag:A(["href"],t),bodyAttributes:v("bodyAttributes",t),defer:T(t,"defer"),encode:T(t,"encodeSpecialCharacters"),htmlAttributes:v("htmlAttributes",t),linkTags:C(l.LINK,["rel","href"],t),metaTags:C(l.META,["name","charset","http-equiv","property","itemprop"],t),noscriptTags:C(l.NOSCRIPT,["innerHTML"],t),onChangeClientState:b(t),scriptTags:C(l.SCRIPT,["src","innerHTML"],t),styleTags:C(l.STYLE,["cssText"],t),title:g(t),titleAttributes:v("titleAttributes",t),prioritizeSeoTags:O(t,"prioritizeSeoTags")});R.canUseDOM?(e=o,B&&cancelAnimationFrame(B),e.defer?B=requestAnimationFrame(function(){Y(e,function(){B=null})}):(Y(e),B=null)):k&&(i=k(o)),n(i)},r.init=function(){this.rendered||(this.rendered=!0,this.props.context.helmetInstances.add(this),this.emitChange())},r.render=function(){return this.init(),null},e}(e);K.propTypes={context:H.isRequired},K.displayName="HelmetDispatcher";var U=["children"],_=["children"],z=function(e){function r(){return e.apply(this,arguments)||this}s(r,e);var o=r.prototype;return o.shouldComponentUpdate=function(t){return!n(this.props,t)},o.mapNestedChildrenToProps=function(t,e){if(!e)return null;switch(t.type){case l.SCRIPT:case l.NOSCRIPT:return{innerHTML:e};case l.STYLE:return{cssText:e};default:throw new Error("<"+t.type+" /> elements are self-closing and can not contain children. Refer to our API for more information.")}},o.flattenArrayTypeChildren=function(t){var e,r=t.child,n=t.arrayTypeChildren;return a({},n,((e={})[r.type]=[].concat(n[r.type]||[],[a({},t.newChildProps,this.mapNestedChildrenToProps(r,t.nestedChildren))]),e))},o.mapObjectTypeChildren=function(t){var e,r,n=t.child,i=t.newProps,o=t.newChildProps,s=t.nestedChildren;switch(n.type){case l.TITLE:return a({},i,((e={})[n.type]=s,e.titleAttributes=a({},o),e));case l.BODY:return a({},i,{bodyAttributes:a({},o)});case l.HTML:return a({},i,{htmlAttributes:a({},o)});default:return a({},i,((r={})[n.type]=a({},o),r))}},o.mapArrayTypeChildrenToProps=function(t,e){var r=a({},e);return Object.keys(t).forEach(function(e){var n;r=a({},r,((n={})[e]=t[e],n))}),r},o.warnOnInvalidChildren=function(t,e){return i(h.some(function(e){return t.type===e}),"function"==typeof t.type?"You may be attempting to nest <Helmet> components within each other, which is not allowed. Refer to our API for more information.":"Only elements types "+h.join(", ")+" are allowed. Helmet does not support rendering <"+t.type+"> elements. Refer to our API for more information."),i(!e||"string"==typeof e||Array.isArray(e)&&!e.some(function(t){return"string"!=typeof t}),"Helmet expects a string as a child of <"+t.type+">. Did you forget to wrap your children in braces? ( <"+t.type+">{``}</"+t.type+"> ) Refer to our API for more information."),!0},o.mapChildrenToProps=function(e,r){var n=this,i={};return t.Children.forEach(e,function(t){if(t&&t.props){var e=t.props,o=e.children,a=u(e,U),s=Object.keys(a).reduce(function(t,e){return t[y[e]||e]=a[e],t},{}),c=t.type;switch("symbol"==typeof c?c=c.toString():n.warnOnInvalidChildren(t,o),c){case l.FRAGMENT:r=n.mapChildrenToProps(o,r);break;case l.LINK:case l.META:case l.NOSCRIPT:case l.SCRIPT:case l.STYLE:i=n.flattenArrayTypeChildren({child:t,arrayTypeChildren:i,newChildProps:s,nestedChildren:o});break;default:r=n.mapObjectTypeChildren({child:t,newProps:r,newChildProps:s,nestedChildren:o})}}}),this.mapArrayTypeChildrenToProps(i,r)},o.render=function(){var e=this.props,r=e.children,n=a({},u(e,_));return r&&(n=this.mapChildrenToProps(r,n)),t.createElement(M.Consumer,null,function(e){return t.createElement(K,a({},n,{context:e}))})},r}(e);z.propTypes={base:r.object,bodyAttributes:r.object,children:r.oneOfType([r.arrayOf(r.node),r.node]),defaultTitle:r.string,defer:r.bool,encodeSpecialCharacters:r.bool,htmlAttributes:r.object,link:r.arrayOf(r.object),meta:r.arrayOf(r.object),noscript:r.arrayOf(r.object),onChangeClientState:r.func,script:r.arrayOf(r.object),style:r.arrayOf(r.object),title:r.string,titleAttributes:r.object,titleTemplate:r.string,prioritizeSeoTags:r.bool},z.defaultProps={defer:!0,encodeSpecialCharacters:!0,prioritizeSeoTags:!1},z.displayName="Helmet";export{z as Helmet,R as HelmetProvider}; | ||
//# sourceMappingURL=index.module.js.map |
@@ -1,2 +0,2 @@ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react"),require("prop-types"),require("react-fast-compare"),require("invariant"),require("shallowequal")):"function"==typeof define&&define.amd?define(["exports","react","prop-types","react-fast-compare","invariant","shallowequal"],t):t((e=e||self).reactHelmetAsync={},e.react,e.propTypes,e.reactFastCompare,e.invariant,e.shallowequal)}(this,function(e,t,r,n,o,i){var a="default"in t?t.default:t;function s(){return(s=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e}).apply(this,arguments)}function c(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,e.__proto__=t}function u(e,t){if(null==e)return{};var r,n,o={},i=Object.keys(e);for(n=0;n<i.length;n++)t.indexOf(r=i[n])>=0||(o[r]=e[r]);return o}r=r&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r,n=n&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n,o=o&&Object.prototype.hasOwnProperty.call(o,"default")?o.default:o,i=i&&Object.prototype.hasOwnProperty.call(i,"default")?i.default:i;var l={BASE:"base",BODY:"body",HEAD:"head",HTML:"html",LINK:"link",META:"meta",NOSCRIPT:"noscript",SCRIPT:"script",STYLE:"style",TITLE:"title",FRAGMENT:"Symbol(react.fragment)"},p=Object.keys(l).map(function(e){return l[e]}),f={accesskey:"accessKey",charset:"charSet",class:"className",contenteditable:"contentEditable",contextmenu:"contextMenu","http-equiv":"httpEquiv",itemprop:"itemProp",tabindex:"tabIndex"},d=Object.keys(f).reduce(function(e,t){return e[f[t]]=t,e},{}),h=function(e,t){for(var r=e.length-1;r>=0;r-=1){var n=e[r];if(Object.prototype.hasOwnProperty.call(n,t))return n[t]}return null},y=function(e){var t=h(e,l.TITLE),r=h(e,"titleTemplate");if(Array.isArray(t)&&(t=t.join("")),r&&t)return r.replace(/%s/g,function(){return t});var n=h(e,"defaultTitle");return t||n||void 0},m=function(e){return h(e,"onChangeClientState")||function(){}},T=function(e,t){return t.filter(function(t){return void 0!==t[e]}).map(function(t){return t[e]}).reduce(function(e,t){return s({},e,t)},{})},b=function(e,t){return t.filter(function(e){return void 0!==e[l.BASE]}).map(function(e){return e[l.BASE]}).reverse().reduce(function(t,r){if(!t.length)for(var n=Object.keys(r),o=0;o<n.length;o+=1){var i=n[o].toLowerCase();if(-1!==e.indexOf(i)&&r[i])return t.concat(r)}return t},[])},g=function(e,t,r){var n={};return r.filter(function(t){return!!Array.isArray(t[e])||(void 0!==t[e]&&console&&"function"==typeof console.warn&&console.warn("Helmet: "+e+' should be of type "Array". Instead found type "'+typeof t[e]+'"'),!1)}).map(function(t){return t[e]}).reverse().reduce(function(e,r){var o={};r.filter(function(e){for(var r,i=Object.keys(e),a=0;a<i.length;a+=1){var s=i[a],c=s.toLowerCase();-1===t.indexOf(c)||"rel"===r&&"canonical"===e[r].toLowerCase()||"rel"===c&&"stylesheet"===e[c].toLowerCase()||(r=c),-1===t.indexOf(s)||"innerHTML"!==s&&"cssText"!==s&&"itemprop"!==s||(r=s)}if(!r||!e[r])return!1;var u=e[r].toLowerCase();return n[r]||(n[r]={}),o[r]||(o[r]={}),!n[r][u]&&(o[r][u]=!0,!0)}).reverse().forEach(function(t){return e.push(t)});for(var i=Object.keys(o),a=0;a<i.length;a+=1){var c=i[a],u=s({},n[c],o[c]);n[c]=u}return e},[]).reverse()},v=function(e){return Array.isArray(e)?e.join(""):e},A=[l.NOSCRIPT,l.SCRIPT,l.STYLE],C=function(e,t){return void 0===t&&(t=!0),!1===t?String(e):String(e).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")},O=function(e){return Object.keys(e).reduce(function(t,r){var n=void 0!==e[r]?r+'="'+e[r]+'"':""+r;return t?t+" "+n:n},"")},E=function(e,t){return void 0===t&&(t={}),Object.keys(e).reduce(function(t,r){return t[f[r]||r]=e[r],t},t)},S=function(e,t,r){switch(e){case l.TITLE:return{toComponent:function(){return r=t.titleAttributes,(n={key:e=t.title})["data-rh"]=!0,o=E(r,n),[a.createElement(l.TITLE,o,e)];var e,r,n,o},toString:function(){return function(e,t,r,n){var o=O(r),i=v(t);return o?"<"+e+' data-rh="true" '+o+">"+C(i,n)+"</"+e+">":"<"+e+' data-rh="true">'+C(i,n)+"</"+e+">"}(e,t.title,t.titleAttributes,r)}};case"bodyAttributes":case"htmlAttributes":return{toComponent:function(){return E(t)},toString:function(){return O(t)}};default:return{toComponent:function(){return function(e,t){return t.map(function(t,r){var n,o=((n={key:r})["data-rh"]=!0,n);return Object.keys(t).forEach(function(e){var r=f[e]||e;"innerHTML"===r||"cssText"===r?o.dangerouslySetInnerHTML={__html:t.innerHTML||t.cssText}:o[r]=t[e]}),a.createElement(e,o)})}(e,t)},toString:function(){return function(e,t,r){return t.reduce(function(t,n){var o=Object.keys(n).filter(function(e){return!("innerHTML"===e||"cssText"===e)}).reduce(function(e,t){var o=void 0===n[t]?t:t+'="'+C(n[t],r)+'"';return e?e+" "+o:o},""),i=n.innerHTML||n.cssText||"",a=-1===A.indexOf(e);return t+"<"+e+' data-rh="true" '+o+(a?"/>":">"+i+"</"+e+">")},"")}(e,t,r)}}}},P=function(e){var t=e.bodyAttributes,r=e.encode,n=e.htmlAttributes,o=e.linkTags,i=e.metaTags,a=e.noscriptTags,s=e.scriptTags,c=e.styleTags,u=e.title,p=void 0===u?"":u,f=e.titleAttributes;return{base:S(l.BASE,e.baseTag,r),bodyAttributes:S("bodyAttributes",t,r),htmlAttributes:S("htmlAttributes",n,r),link:S(l.LINK,o,r),meta:S(l.META,i,r),noscript:S(l.NOSCRIPT,a,r),script:S(l.SCRIPT,s,r),style:S(l.STYLE,c,r),title:S(l.TITLE,{title:p,titleAttributes:f},r)}},j=a.createContext({}),x=r.shape({setHelmet:r.func,helmetInstances:r.shape({get:r.func,add:r.func,remove:r.func})}),I="undefined"!=typeof document,w=function(e){function t(r){var n;return(n=e.call(this,r)||this).instances=[],n.value={setHelmet:function(e){n.props.context.helmet=e},helmetInstances:{get:function(){return n.instances},add:function(e){n.instances.push(e)},remove:function(e){var t=n.instances.indexOf(e);n.instances.splice(t,1)}}},t.canUseDOM||(r.context.helmet=P({baseTag:[],bodyAttributes:{},encodeSpecialCharacters:!0,htmlAttributes:{},linkTags:[],metaTags:[],noscriptTags:[],scriptTags:[],styleTags:[],title:"",titleAttributes:{}})),n}return c(t,e),t.prototype.render=function(){return a.createElement(j.Provider,{value:this.value},this.props.children)},t}(t.Component);w.canUseDOM=I,w.propTypes={context:r.shape({helmet:r.shape()}),children:r.node.isRequired},w.defaultProps={context:{}},w.displayName="HelmetProvider";var L=function(e,t){var r,n=document.head||document.querySelector(l.HEAD),o=n.querySelectorAll(e+"[data-rh]"),i=[].slice.call(o),a=[];return t&&t.length&&t.forEach(function(t){var n=document.createElement(e);for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&("innerHTML"===o?n.innerHTML=t.innerHTML:"cssText"===o?n.styleSheet?n.styleSheet.cssText=t.cssText:n.appendChild(document.createTextNode(t.cssText)):n.setAttribute(o,void 0===t[o]?"":t[o]));n.setAttribute("data-rh","true"),i.some(function(e,t){return r=t,n.isEqualNode(e)})?i.splice(r,1):a.push(n)}),i.forEach(function(e){return e.parentNode.removeChild(e)}),a.forEach(function(e){return n.appendChild(e)}),{oldTags:i,newTags:a}},H=function(e,t){var r=document.getElementsByTagName(e)[0];if(r){for(var n=r.getAttribute("data-rh"),o=n?n.split(","):[],i=[].concat(o),a=Object.keys(t),s=0;s<a.length;s+=1){var c=a[s],u=t[c]||"";r.getAttribute(c)!==u&&r.setAttribute(c,u),-1===o.indexOf(c)&&o.push(c);var l=i.indexOf(c);-1!==l&&i.splice(l,1)}for(var p=i.length-1;p>=0;p-=1)r.removeAttribute(i[p]);o.length===i.length?r.removeAttribute("data-rh"):r.getAttribute("data-rh")!==a.join(",")&&r.setAttribute("data-rh",a.join(","))}},k=function(e,t){var r=e.baseTag,n=e.htmlAttributes,o=e.linkTags,i=e.metaTags,a=e.noscriptTags,s=e.onChangeClientState,c=e.scriptTags,u=e.styleTags,p=e.title,f=e.titleAttributes;H(l.BODY,e.bodyAttributes),H(l.HTML,n),function(e,t){void 0!==e&&document.title!==e&&(document.title=v(e)),H(l.TITLE,t)}(p,f);var d={baseTag:L(l.BASE,r),linkTags:L(l.LINK,o),metaTags:L(l.META,i),noscriptTags:L(l.NOSCRIPT,a),scriptTags:L(l.SCRIPT,c),styleTags:L(l.STYLE,u)},h={},y={};Object.keys(d).forEach(function(e){var t=d[e],r=t.newTags,n=t.oldTags;r.length&&(h[e]=r),n.length&&(y[e]=d[e].oldTags)}),t&&t(),s(e,h,y)},M=null,N=function(e){function t(){for(var t,r=arguments.length,n=new Array(r),o=0;o<r;o++)n[o]=arguments[o];return(t=e.call.apply(e,[this].concat(n))||this).rendered=!1,t}c(t,e);var r=t.prototype;return r.shouldComponentUpdate=function(e){return!i(e,this.props)},r.componentDidUpdate=function(){this.emitChange()},r.componentWillUnmount=function(){this.props.context.helmetInstances.remove(this),this.emitChange()},r.emitChange=function(){var e,t,r=this.props.context,n=r.setHelmet,o=null,i=(e=r.helmetInstances.get().map(function(e){var t=s({},e.props);return delete t.context,t}),{baseTag:b(["href"],e),bodyAttributes:T("bodyAttributes",e),defer:h(e,"defer"),encode:h(e,"encodeSpecialCharacters"),htmlAttributes:T("htmlAttributes",e),linkTags:g(l.LINK,["rel","href"],e),metaTags:g(l.META,["name","charset","http-equiv","property","itemprop"],e),noscriptTags:g(l.NOSCRIPT,["innerHTML"],e),onChangeClientState:m(e),scriptTags:g(l.SCRIPT,["src","innerHTML"],e),styleTags:g(l.STYLE,["cssText"],e),title:y(e),titleAttributes:T("titleAttributes",e)});w.canUseDOM?(t=i,M&&cancelAnimationFrame(M),t.defer?M=requestAnimationFrame(function(){k(t,function(){M=null})}):(k(t),M=null)):P&&(o=P(i)),n(o)},r.init=function(){this.rendered||(this.rendered=!0,this.props.context.helmetInstances.add(this),this.emitChange())},r.render=function(){return this.init(),null},t}(t.Component);N.propTypes={context:x.isRequired},N.displayName="HelmetDispatcher";var R=function(e){function t(){return e.apply(this,arguments)||this}c(t,e);var r=t.prototype;return r.shouldComponentUpdate=function(e){return!n(this.props,e)},r.mapNestedChildrenToProps=function(e,t){if(!t)return null;switch(e.type){case l.SCRIPT:case l.NOSCRIPT:return{innerHTML:t};case l.STYLE:return{cssText:t};default:throw new Error("<"+e.type+" /> elements are self-closing and can not contain children. Refer to our API for more information.")}},r.flattenArrayTypeChildren=function(e){var t,r=e.child,n=e.arrayTypeChildren;return s({},n,((t={})[r.type]=[].concat(n[r.type]||[],[s({},e.newChildProps,this.mapNestedChildrenToProps(r,e.nestedChildren))]),t))},r.mapObjectTypeChildren=function(e){var t,r,n=e.child,o=e.newProps,i=e.newChildProps,a=e.nestedChildren;switch(n.type){case l.TITLE:return s({},o,((t={})[n.type]=a,t.titleAttributes=s({},i),t));case l.BODY:return s({},o,{bodyAttributes:s({},i)});case l.HTML:return s({},o,{htmlAttributes:s({},i)});default:return s({},o,((r={})[n.type]=s({},i),r))}},r.mapArrayTypeChildrenToProps=function(e,t){var r=s({},t);return Object.keys(e).forEach(function(t){var n;r=s({},r,((n={})[t]=e[t],n))}),r},r.warnOnInvalidChildren=function(e,t){return o(p.some(function(t){return e.type===t}),"function"==typeof e.type?"You may be attempting to nest <Helmet> components within each other, which is not allowed. Refer to our API for more information.":"Only elements types "+p.join(", ")+" are allowed. Helmet does not support rendering <"+e.type+"> elements. Refer to our API for more information."),o(!t||"string"==typeof t||Array.isArray(t)&&!t.some(function(e){return"string"!=typeof e}),"Helmet expects a string as a child of <"+e.type+">. Did you forget to wrap your children in braces? ( <"+e.type+">{``}</"+e.type+"> ) Refer to our API for more information."),!0},r.mapChildrenToProps=function(e,t){var r=this,n={};return a.Children.forEach(e,function(e){if(e&&e.props){var o=e.props,i=o.children,a=u(o,["children"]),s=Object.keys(a).reduce(function(e,t){return e[d[t]||t]=a[t],e},{}),c=e.type;switch("symbol"==typeof c?c=c.toString():r.warnOnInvalidChildren(e,i),c){case l.FRAGMENT:t=r.mapChildrenToProps(i,t);break;case l.LINK:case l.META:case l.NOSCRIPT:case l.SCRIPT:case l.STYLE:n=r.flattenArrayTypeChildren({child:e,arrayTypeChildren:n,newChildProps:s,nestedChildren:i});break;default:t=r.mapObjectTypeChildren({child:e,newProps:t,newChildProps:s,nestedChildren:i})}}}),this.mapArrayTypeChildrenToProps(n,t)},r.render=function(){var e=this.props,t=e.children,r=s({},u(e,["children"]));return t&&(r=this.mapChildrenToProps(t,r)),a.createElement(j.Consumer,null,function(e){return a.createElement(N,s({},r,{context:e}))})},t}(t.Component);R.propTypes={base:r.object,bodyAttributes:r.object,children:r.oneOfType([r.arrayOf(r.node),r.node]),defaultTitle:r.string,defer:r.bool,encodeSpecialCharacters:r.bool,htmlAttributes:r.object,link:r.arrayOf(r.object),meta:r.arrayOf(r.object),noscript:r.arrayOf(r.object),onChangeClientState:r.func,script:r.arrayOf(r.object),style:r.arrayOf(r.object),title:r.string,titleAttributes:r.object,titleTemplate:r.string},R.defaultProps={defer:!0,encodeSpecialCharacters:!0},R.displayName="Helmet",e.Helmet=R,e.HelmetProvider=w}); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react"),require("prop-types"),require("react-fast-compare"),require("invariant"),require("shallowequal")):"function"==typeof define&&define.amd?define(["exports","react","prop-types","react-fast-compare","invariant","shallowequal"],t):t((e||self).reactHelmetAsync={},e.react,e.propTypes,e.reactFastCompare,e.invariant,e.shallowequal)}(this,function(e,t,r,n,i,o){function a(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var u=a(t),s=a(r),c=a(n),l=a(i),f=a(o);function p(){return(p=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e}).apply(this,arguments)}function d(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,h(e,t)}function h(e,t){return(h=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function y(e,t){if(null==e)return{};var r,n,i={},o=Object.keys(e);for(n=0;n<o.length;n++)t.indexOf(r=o[n])>=0||(i[r]=e[r]);return i}var m="cssText",T="href",g="innerHTML",b="itemprop",v="rel",A="bodyAttributes",C="htmlAttributes",O={BASE:"base",BODY:"body",HEAD:"head",HTML:"html",LINK:"link",META:"meta",NOSCRIPT:"noscript",SCRIPT:"script",STYLE:"style",TITLE:"title",FRAGMENT:"Symbol(react.fragment)"},S={rel:["amphtml","canonical","alternate"]},E={type:["application/ld+json"]},I={charset:"",name:["robots","description"],property:["og:type","og:title","og:url","og:image","og:image:alt","og:description","twitter:url","twitter:title","twitter:description","twitter:image","twitter:image:alt","twitter:card","twitter:site"]},P=Object.keys(O).map(function(e){return O[e]}),w={accesskey:"accessKey",charset:"charSet",class:"className",contenteditable:"contentEditable",contextmenu:"contextMenu","http-equiv":"httpEquiv",itemprop:"itemProp",tabindex:"tabIndex"},j=Object.keys(w).reduce(function(e,t){return e[w[t]]=t,e},{}),x="data-rh",L=function(e,t){for(var r=e.length-1;r>=0;r-=1){var n=e[r];if(Object.prototype.hasOwnProperty.call(n,t))return n[t]}return null},k=function(e){var t=L(e,O.TITLE),r=L(e,"titleTemplate");if(Array.isArray(t)&&(t=t.join("")),r&&t)return r.replace(/%s/g,function(){return t});var n=L(e,"defaultTitle");return t||n||void 0},N=function(e){return L(e,"onChangeClientState")||function(){}},H=function(e,t){return t.filter(function(t){return void 0!==t[e]}).map(function(t){return t[e]}).reduce(function(e,t){return p({},e,t)},{})},M=function(e,t){return t.filter(function(e){return void 0!==e[O.BASE]}).map(function(e){return e[O.BASE]}).reverse().reduce(function(t,r){if(!t.length)for(var n=Object.keys(r),i=0;i<n.length;i+=1){var o=n[i].toLowerCase();if(-1!==e.indexOf(o)&&r[o])return t.concat(r)}return t},[])},R=function(e,t,r){var n={};return r.filter(function(t){return!!Array.isArray(t[e])||(void 0!==t[e]&&console&&"function"==typeof console.warn&&console.warn("Helmet: "+e+' should be of type "Array". Instead found type "'+typeof t[e]+'"'),!1)}).map(function(t){return t[e]}).reverse().reduce(function(e,r){var i={};r.filter(function(e){for(var r,o=Object.keys(e),a=0;a<o.length;a+=1){var u=o[a],s=u.toLowerCase();-1===t.indexOf(s)||r===v&&"canonical"===e[r].toLowerCase()||s===v&&"stylesheet"===e[s].toLowerCase()||(r=s),-1===t.indexOf(u)||u!==g&&u!==m&&u!==b||(r=u)}if(!r||!e[r])return!1;var c=e[r].toLowerCase();return n[r]||(n[r]={}),i[r]||(i[r]={}),!n[r][c]&&(i[r][c]=!0,!0)}).reverse().forEach(function(t){return e.push(t)});for(var o=Object.keys(i),a=0;a<o.length;a+=1){var u=o[a],s=p({},n[u],i[u]);n[u]=s}return e},[]).reverse()},q=function(e,t){if(Array.isArray(e)&&e.length)for(var r=0;r<e.length;r+=1)if(e[r][t])return!0;return!1},D=function(e){return Array.isArray(e)?e.join(""):e},Y=function(e,t){return Array.isArray(e)?e.reduce(function(e,r){return function(e,t){for(var r=Object.keys(e),n=0;n<r.length;n+=1)if(t[r[n]]&&t[r[n]].includes(e[r[n]]))return!0;return!1}(r,t)?e.priority.push(r):e.default.push(r),e},{priority:[],default:[]}):{default:e}},B=[O.NOSCRIPT,O.SCRIPT,O.STYLE],K=function(e,t){return void 0===t&&(t=!0),!1===t?String(e):String(e).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")},U=function(e){return Object.keys(e).reduce(function(t,r){var n=void 0!==e[r]?r+'="'+e[r]+'"':""+r;return t?t+" "+n:n},"")},_=function(e,t){return void 0===t&&(t={}),Object.keys(e).reduce(function(t,r){return t[w[r]||r]=e[r],t},t)},z=function(e,t){return t.map(function(t,r){var n,i=((n={key:r})["data-rh"]=!0,n);return Object.keys(t).forEach(function(e){var r=w[e]||e;r===g||r===m?i.dangerouslySetInnerHTML={__html:t.innerHTML||t.cssText}:i[r]=t[e]}),u.default.createElement(e,i)})},F=function(e,t,r){switch(e){case O.TITLE:return{toComponent:function(){return r=t.titleAttributes,(n={key:e=t.title})["data-rh"]=!0,i=_(r,n),[u.default.createElement(O.TITLE,i,e)];var e,r,n,i},toString:function(){return function(e,t,r,n){var i=U(r),o=D(t);return i?"<"+e+' data-rh="true" '+i+">"+K(o,n)+"</"+e+">":"<"+e+' data-rh="true">'+K(o,n)+"</"+e+">"}(e,t.title,t.titleAttributes,r)}};case A:case C:return{toComponent:function(){return _(t)},toString:function(){return U(t)}};default:return{toComponent:function(){return z(e,t)},toString:function(){return function(e,t,r){return t.reduce(function(t,n){var i=Object.keys(n).filter(function(e){return!(e===g||e===m)}).reduce(function(e,t){var i=void 0===n[t]?t:t+'="'+K(n[t],r)+'"';return e?e+" "+i:i},""),o=n.innerHTML||n.cssText||"",a=-1===B.indexOf(e);return t+"<"+e+' data-rh="true" '+i+(a?"/>":">"+o+"</"+e+">")},"")}(e,t,r)}}}},G=function(e){var t=e.baseTag,r=e.bodyAttributes,n=e.encode,i=e.htmlAttributes,o=e.noscriptTags,a=e.styleTags,u=e.title,s=void 0===u?"":u,c=e.titleAttributes,l=e.linkTags,f=e.metaTags,p=e.scriptTags,d={toComponent:function(){},toString:function(){return""}};if(e.prioritizeSeoTags){var h=function(e){var t=e.linkTags,r=e.scriptTags,n=e.encode,i=Y(e.metaTags,I),o=Y(t,S),a=Y(r,E);return{priorityMethods:{toComponent:function(){return[].concat(z(O.META,i.priority),z(O.LINK,o.priority),z(O.SCRIPT,a.priority))},toString:function(){return F(O.META,i.priority,n)+" "+F(O.LINK,o.priority,n)+" "+F(O.SCRIPT,a.priority,n)}},metaTags:i.default,linkTags:o.default,scriptTags:a.default}}(e);d=h.priorityMethods,l=h.linkTags,f=h.metaTags,p=h.scriptTags}return{priority:d,base:F(O.BASE,t,n),bodyAttributes:F(A,r,n),htmlAttributes:F(C,i,n),link:F(O.LINK,l,n),meta:F(O.META,f,n),noscript:F(O.NOSCRIPT,o,n),script:F(O.SCRIPT,p,n),style:F(O.STYLE,a,n),title:F(O.TITLE,{title:s,titleAttributes:c},n)}},W=u.default.createContext({}),J=s.default.shape({setHelmet:s.default.func,helmetInstances:s.default.shape({get:s.default.func,add:s.default.func,remove:s.default.func})}),Q="undefined"!=typeof document,V=function(e){function t(r){var n;return(n=e.call(this,r)||this).instances=[],n.value={setHelmet:function(e){n.props.context.helmet=e},helmetInstances:{get:function(){return n.instances},add:function(e){n.instances.push(e)},remove:function(e){var t=n.instances.indexOf(e);n.instances.splice(t,1)}}},t.canUseDOM||(r.context.helmet=G({baseTag:[],bodyAttributes:{},encodeSpecialCharacters:!0,htmlAttributes:{},linkTags:[],metaTags:[],noscriptTags:[],scriptTags:[],styleTags:[],title:"",titleAttributes:{}})),n}return d(t,e),t.prototype.render=function(){return u.default.createElement(W.Provider,{value:this.value},this.props.children)},t}(t.Component);V.canUseDOM=Q,V.propTypes={context:s.default.shape({helmet:s.default.shape()}),children:s.default.node.isRequired},V.defaultProps={context:{}},V.displayName="HelmetProvider";var X=function(e,t){var r,n=document.head||document.querySelector(O.HEAD),i=n.querySelectorAll(e+"[data-rh]"),o=[].slice.call(i),a=[];return t&&t.length&&t.forEach(function(t){var n=document.createElement(e);for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(i===g?n.innerHTML=t.innerHTML:i===m?n.styleSheet?n.styleSheet.cssText=t.cssText:n.appendChild(document.createTextNode(t.cssText)):n.setAttribute(i,void 0===t[i]?"":t[i]));n.setAttribute(x,"true"),o.some(function(e,t){return r=t,n.isEqualNode(e)})?o.splice(r,1):a.push(n)}),o.forEach(function(e){return e.parentNode.removeChild(e)}),a.forEach(function(e){return n.appendChild(e)}),{oldTags:o,newTags:a}},Z=function(e,t){var r=document.getElementsByTagName(e)[0];if(r){for(var n=r.getAttribute(x),i=n?n.split(","):[],o=[].concat(i),a=Object.keys(t),u=0;u<a.length;u+=1){var s=a[u],c=t[s]||"";r.getAttribute(s)!==c&&r.setAttribute(s,c),-1===i.indexOf(s)&&i.push(s);var l=o.indexOf(s);-1!==l&&o.splice(l,1)}for(var f=o.length-1;f>=0;f-=1)r.removeAttribute(o[f]);i.length===o.length?r.removeAttribute(x):r.getAttribute(x)!==a.join(",")&&r.setAttribute(x,a.join(","))}},$=function(e,t){var r=e.baseTag,n=e.htmlAttributes,i=e.linkTags,o=e.metaTags,a=e.noscriptTags,u=e.onChangeClientState,s=e.scriptTags,c=e.styleTags,l=e.title,f=e.titleAttributes;Z(O.BODY,e.bodyAttributes),Z(O.HTML,n),function(e,t){void 0!==e&&document.title!==e&&(document.title=D(e)),Z(O.TITLE,t)}(l,f);var p={baseTag:X(O.BASE,r),linkTags:X(O.LINK,i),metaTags:X(O.META,o),noscriptTags:X(O.NOSCRIPT,a),scriptTags:X(O.SCRIPT,s),styleTags:X(O.STYLE,c)},d={},h={};Object.keys(p).forEach(function(e){var t=p[e],r=t.newTags,n=t.oldTags;r.length&&(d[e]=r),n.length&&(h[e]=p[e].oldTags)}),t&&t(),u(e,d,h)},ee=null,te=function(e){function t(){for(var t,r=arguments.length,n=new Array(r),i=0;i<r;i++)n[i]=arguments[i];return(t=e.call.apply(e,[this].concat(n))||this).rendered=!1,t}d(t,e);var r=t.prototype;return r.shouldComponentUpdate=function(e){return!f.default(e,this.props)},r.componentDidUpdate=function(){this.emitChange()},r.componentWillUnmount=function(){this.props.context.helmetInstances.remove(this),this.emitChange()},r.emitChange=function(){var e,t,r=this.props.context,n=r.setHelmet,i=null,o=(e=r.helmetInstances.get().map(function(e){var t=p({},e.props);return delete t.context,t}),{baseTag:M([T],e),bodyAttributes:H(A,e),defer:L(e,"defer"),encode:L(e,"encodeSpecialCharacters"),htmlAttributes:H(C,e),linkTags:R(O.LINK,[v,T],e),metaTags:R(O.META,["name","charset","http-equiv","property",b],e),noscriptTags:R(O.NOSCRIPT,[g],e),onChangeClientState:N(e),scriptTags:R(O.SCRIPT,["src",g],e),styleTags:R(O.STYLE,[m],e),title:k(e),titleAttributes:H("titleAttributes",e),prioritizeSeoTags:q(e,"prioritizeSeoTags")});V.canUseDOM?(t=o,ee&&cancelAnimationFrame(ee),t.defer?ee=requestAnimationFrame(function(){$(t,function(){ee=null})}):($(t),ee=null)):G&&(i=G(o)),n(i)},r.init=function(){this.rendered||(this.rendered=!0,this.props.context.helmetInstances.add(this),this.emitChange())},r.render=function(){return this.init(),null},t}(t.Component);te.propTypes={context:J.isRequired},te.displayName="HelmetDispatcher";var re=["children"],ne=["children"],ie=function(e){function t(){return e.apply(this,arguments)||this}d(t,e);var r=t.prototype;return r.shouldComponentUpdate=function(e){return!c.default(this.props,e)},r.mapNestedChildrenToProps=function(e,t){if(!t)return null;switch(e.type){case O.SCRIPT:case O.NOSCRIPT:return{innerHTML:t};case O.STYLE:return{cssText:t};default:throw new Error("<"+e.type+" /> elements are self-closing and can not contain children. Refer to our API for more information.")}},r.flattenArrayTypeChildren=function(e){var t,r=e.child,n=e.arrayTypeChildren;return p({},n,((t={})[r.type]=[].concat(n[r.type]||[],[p({},e.newChildProps,this.mapNestedChildrenToProps(r,e.nestedChildren))]),t))},r.mapObjectTypeChildren=function(e){var t,r,n=e.child,i=e.newProps,o=e.newChildProps,a=e.nestedChildren;switch(n.type){case O.TITLE:return p({},i,((t={})[n.type]=a,t.titleAttributes=p({},o),t));case O.BODY:return p({},i,{bodyAttributes:p({},o)});case O.HTML:return p({},i,{htmlAttributes:p({},o)});default:return p({},i,((r={})[n.type]=p({},o),r))}},r.mapArrayTypeChildrenToProps=function(e,t){var r=p({},t);return Object.keys(e).forEach(function(t){var n;r=p({},r,((n={})[t]=e[t],n))}),r},r.warnOnInvalidChildren=function(e,t){return l.default(P.some(function(t){return e.type===t}),"function"==typeof e.type?"You may be attempting to nest <Helmet> components within each other, which is not allowed. Refer to our API for more information.":"Only elements types "+P.join(", ")+" are allowed. Helmet does not support rendering <"+e.type+"> elements. Refer to our API for more information."),l.default(!t||"string"==typeof t||Array.isArray(t)&&!t.some(function(e){return"string"!=typeof e}),"Helmet expects a string as a child of <"+e.type+">. Did you forget to wrap your children in braces? ( <"+e.type+">{``}</"+e.type+"> ) Refer to our API for more information."),!0},r.mapChildrenToProps=function(e,t){var r=this,n={};return u.default.Children.forEach(e,function(e){if(e&&e.props){var i=e.props,o=i.children,a=y(i,re),u=Object.keys(a).reduce(function(e,t){return e[j[t]||t]=a[t],e},{}),s=e.type;switch("symbol"==typeof s?s=s.toString():r.warnOnInvalidChildren(e,o),s){case O.FRAGMENT:t=r.mapChildrenToProps(o,t);break;case O.LINK:case O.META:case O.NOSCRIPT:case O.SCRIPT:case O.STYLE:n=r.flattenArrayTypeChildren({child:e,arrayTypeChildren:n,newChildProps:u,nestedChildren:o});break;default:t=r.mapObjectTypeChildren({child:e,newProps:t,newChildProps:u,nestedChildren:o})}}}),this.mapArrayTypeChildrenToProps(n,t)},r.render=function(){var e=this.props,t=e.children,r=p({},y(e,ne));return t&&(r=this.mapChildrenToProps(t,r)),u.default.createElement(W.Consumer,null,function(e){return u.default.createElement(te,p({},r,{context:e}))})},t}(t.Component);ie.propTypes={base:s.default.object,bodyAttributes:s.default.object,children:s.default.oneOfType([s.default.arrayOf(s.default.node),s.default.node]),defaultTitle:s.default.string,defer:s.default.bool,encodeSpecialCharacters:s.default.bool,htmlAttributes:s.default.object,link:s.default.arrayOf(s.default.object),meta:s.default.arrayOf(s.default.object),noscript:s.default.arrayOf(s.default.object),onChangeClientState:s.default.func,script:s.default.arrayOf(s.default.object),style:s.default.arrayOf(s.default.object),title:s.default.string,titleAttributes:s.default.object,titleTemplate:s.default.string,prioritizeSeoTags:s.default.bool},ie.defaultProps={defer:!0,encodeSpecialCharacters:!0,prioritizeSeoTags:!1},ie.displayName="Helmet",e.Helmet=ie,e.HelmetProvider=V}); | ||
//# sourceMappingURL=index.umd.js.map |
{ | ||
"name": "react-helmet-async", | ||
"version": "1.0.9", | ||
"version": "1.1.0", | ||
"description": "Thread-safe Helmet for React 16+ and friends", | ||
@@ -26,30 +26,29 @@ "main": "lib/index.js", | ||
"devDependencies": { | ||
"@babel/cli": "7.12.1", | ||
"@babel/core": "7.12.3", | ||
"@babel/eslint-parser": "7.12.1", | ||
"@babel/eslint-plugin": "7.12.1", | ||
"@commitlint/cli": "11.0.0", | ||
"@commitlint/config-conventional": "11.0.0", | ||
"babel-eslint": "10.1.0", | ||
"babel-preset-kyt-react": "1.1.3", | ||
"@babel/cli": "7.14.8", | ||
"@babel/core": "7.15.0", | ||
"@babel/eslint-parser": "7.15.0", | ||
"@babel/eslint-plugin": "7.14.5", | ||
"@commitlint/cli": "13.1.0", | ||
"@commitlint/config-conventional": "13.1.0", | ||
"babel-preset-kyt-react": "1.3.16", | ||
"enzyme": "3.11.0", | ||
"enzyme-adapter-react-16": "1.15.5", | ||
"enzyme-to-json": "3.6.1", | ||
"eslint": "7.13.0", | ||
"enzyme-adapter-react-16": "1.15.6", | ||
"enzyme-to-json": "3.6.2", | ||
"eslint": "7.32.0", | ||
"eslint-config-airbnb": "18.2.1", | ||
"eslint-config-kyt": "1.3.5", | ||
"eslint-config-prettier": "6.15.0", | ||
"eslint-plugin-import": "2.22.1", | ||
"eslint-plugin-jest": "24.1.3", | ||
"eslint-plugin-jest-formatting": "2.0.0", | ||
"eslint-plugin-json": "2.1.2", | ||
"eslint-config-kyt": "1.6.2", | ||
"eslint-config-prettier": "8.3.0", | ||
"eslint-plugin-import": "2.24.1", | ||
"eslint-plugin-jest": "24.4.0", | ||
"eslint-plugin-jest-formatting": "3.0.0", | ||
"eslint-plugin-json": "3.1.0", | ||
"eslint-plugin-jsx-a11y": "6.4.1", | ||
"eslint-plugin-prettier": "3.1.4", | ||
"eslint-plugin-react": "7.21.5", | ||
"eslint-plugin-prettier": "3.4.1", | ||
"eslint-plugin-react": "7.24.0", | ||
"eslint-plugin-react-hooks": "4.2.0", | ||
"husky": "4.3.0", | ||
"jest": "26.6.3", | ||
"husky": "7.0.1", | ||
"jest": "27.0.6", | ||
"jsdom": "16.4.0", | ||
"microbundle": "0.12.4", | ||
"prettier": "2.1.2", | ||
"microbundle": "0.13.3", | ||
"prettier": "2.3.2", | ||
"raf": "3.4.1", | ||
@@ -72,9 +71,4 @@ "react": "16.14.0", | ||
"compile": "yarn run clean && KYT_ENV_TYPE=client NODE_ENV=production microbundle --jsx React.createElement", | ||
"prepare": "yarn compile" | ||
}, | ||
"husky": { | ||
"hooks": { | ||
"commit-msg": "commitlint -E HUSKY_GIT_PARAMS" | ||
} | ||
"prepare": "yarn compile && husky install" | ||
} | ||
} |
@@ -129,4 +129,52 @@ # react-helmet-async | ||
## Prioritizing tags for SEO | ||
It is understood that in some cases for SEO, certain tags should appear earlier in the HEAD. Using the `prioritizeSeoTags` flag on any `<Helmet>` component allows the server render of react-helmet-async to expose a method for prioritizing relevant SEO tags. | ||
In the component: | ||
``` | ||
<Helmet prioritizeSeoTags> | ||
<title>A fancy webpage</title> | ||
<link rel="notImportant" href="https://www.chipotle.com" /> | ||
<meta name="whatever" value="notImportant" /> | ||
<link rel="canonical" href="https://www.tacobell.com" /> | ||
<meta property="og:title" content="A very important title"/> | ||
</Helmet> | ||
``` | ||
In your server template: | ||
``` | ||
<html> | ||
<head> | ||
${helmet.title.toString()} | ||
${helmet.priority.toString()} | ||
${helmet.meta.toString()} | ||
${helmet.link.toString()} | ||
${helmet.script.toString()} | ||
</head> | ||
... | ||
</html> | ||
``` | ||
Will result in: | ||
``` | ||
<html> | ||
<head> | ||
<title>A fancy webpage</title> | ||
<meta property="og:title" content="A very important title"/> | ||
<link rel="canonical" href="https://www.tacobell.com" /> | ||
<meta name="whatever" value="notImportant" /> | ||
<link rel="notImportant" href="https://www.chipotle.com" /> | ||
</head> | ||
... | ||
</html> | ||
``` | ||
A list of prioritized tags and attributes can be found in [constants.js](./blob/master/src/constants.js). | ||
## License | ||
Licensed under the Apache 2.0 License, Copyright © 2018 Scott Taylor |
@@ -34,2 +34,26 @@ export const TAG_PROPERTIES = { | ||
export const SEO_PRIORITY_TAGS = { | ||
link: { rel: ['amphtml', 'canonical', 'alternate'] }, | ||
script: { type: ['application/ld+json'] }, | ||
meta: { | ||
charset: '', | ||
name: ['robots', 'description'], | ||
property: [ | ||
'og:type', | ||
'og:title', | ||
'og:url', | ||
'og:image', | ||
'og:image:alt', | ||
'og:description', | ||
'twitter:url', | ||
'twitter:title', | ||
'twitter:description', | ||
'twitter:image', | ||
'twitter:image:alt', | ||
'twitter:card', | ||
'twitter:site', | ||
], | ||
}, | ||
}; | ||
export const VALID_TAG_NAMES = Object.keys(TAG_NAMES).map(name => TAG_NAMES[name]); | ||
@@ -36,0 +60,0 @@ |
@@ -30,2 +30,3 @@ import React, { Component } from 'react'; | ||
* @param {String} titleTemplate: "MySite.com - %s" | ||
* @param {Boolean} prioritizeSeoTags: false | ||
*/ | ||
@@ -50,2 +51,3 @@ /* eslint-disable react/forbid-prop-types, react/require-default-props */ | ||
titleTemplate: PropTypes.string, | ||
prioritizeSeoTags: PropTypes.bool, | ||
}; | ||
@@ -57,2 +59,3 @@ /* eslint-enable react/prop-types, react/forbid-prop-types, react/require-default-props */ | ||
encodeSpecialCharacters: true, | ||
prioritizeSeoTags: false, | ||
}; | ||
@@ -59,0 +62,0 @@ |
@@ -8,4 +8,5 @@ import React from 'react'; | ||
ATTRIBUTE_NAMES, | ||
SEO_PRIORITY_TAGS, | ||
} from './constants'; | ||
import { flattenArray } from './utils'; | ||
import { flattenArray, prioritizer } from './utils'; | ||
@@ -134,26 +135,65 @@ const SELF_CLOSING_TAGS = [TAG_NAMES.NOSCRIPT, TAG_NAMES.SCRIPT, TAG_NAMES.STYLE]; | ||
const mapStateOnServer = ({ | ||
baseTag, | ||
bodyAttributes, | ||
encode, | ||
htmlAttributes, | ||
linkTags, | ||
metaTags, | ||
noscriptTags, | ||
scriptTags, | ||
styleTags, | ||
title = '', | ||
titleAttributes, | ||
}) => ({ | ||
base: getMethodsForTag(TAG_NAMES.BASE, baseTag, encode), | ||
bodyAttributes: getMethodsForTag(ATTRIBUTE_NAMES.BODY, bodyAttributes, encode), | ||
htmlAttributes: getMethodsForTag(ATTRIBUTE_NAMES.HTML, htmlAttributes, encode), | ||
link: getMethodsForTag(TAG_NAMES.LINK, linkTags, encode), | ||
meta: getMethodsForTag(TAG_NAMES.META, metaTags, encode), | ||
noscript: getMethodsForTag(TAG_NAMES.NOSCRIPT, noscriptTags, encode), | ||
script: getMethodsForTag(TAG_NAMES.SCRIPT, scriptTags, encode), | ||
style: getMethodsForTag(TAG_NAMES.STYLE, styleTags, encode), | ||
title: getMethodsForTag(TAG_NAMES.TITLE, { title, titleAttributes }, encode), | ||
}); | ||
const getPriorityMethods = ({ metaTags, linkTags, scriptTags, encode }) => { | ||
const meta = prioritizer(metaTags, SEO_PRIORITY_TAGS.meta); | ||
const link = prioritizer(linkTags, SEO_PRIORITY_TAGS.link); | ||
const script = prioritizer(scriptTags, SEO_PRIORITY_TAGS.script); | ||
// need to have toComponent() and toString() | ||
const priorityMethods = { | ||
toComponent: () => [ | ||
...generateTagsAsReactComponent(TAG_NAMES.META, meta.priority), | ||
...generateTagsAsReactComponent(TAG_NAMES.LINK, link.priority), | ||
...generateTagsAsReactComponent(TAG_NAMES.SCRIPT, script.priority), | ||
], | ||
toString: () => | ||
// generate all the tags as strings and concatenate them | ||
`${getMethodsForTag(TAG_NAMES.META, meta.priority, encode)} ${getMethodsForTag( | ||
TAG_NAMES.LINK, | ||
link.priority, | ||
encode | ||
)} ${getMethodsForTag(TAG_NAMES.SCRIPT, script.priority, encode)}`, | ||
}; | ||
return { | ||
priorityMethods, | ||
metaTags: meta.default, | ||
linkTags: link.default, | ||
scriptTags: script.default, | ||
}; | ||
}; | ||
const mapStateOnServer = props => { | ||
const { | ||
baseTag, | ||
bodyAttributes, | ||
encode, | ||
htmlAttributes, | ||
noscriptTags, | ||
styleTags, | ||
title = '', | ||
titleAttributes, | ||
prioritizeSeoTags, | ||
} = props; | ||
let { linkTags, metaTags, scriptTags } = props; | ||
let priorityMethods = { | ||
toComponent: () => {}, | ||
toString: () => '', | ||
}; | ||
if (prioritizeSeoTags) { | ||
({ priorityMethods, linkTags, metaTags, scriptTags } = getPriorityMethods(props)); | ||
} | ||
return { | ||
priority: priorityMethods, | ||
base: getMethodsForTag(TAG_NAMES.BASE, baseTag, encode), | ||
bodyAttributes: getMethodsForTag(ATTRIBUTE_NAMES.BODY, bodyAttributes, encode), | ||
htmlAttributes: getMethodsForTag(ATTRIBUTE_NAMES.HTML, htmlAttributes, encode), | ||
link: getMethodsForTag(TAG_NAMES.LINK, linkTags, encode), | ||
meta: getMethodsForTag(TAG_NAMES.META, metaTags, encode), | ||
noscript: getMethodsForTag(TAG_NAMES.NOSCRIPT, noscriptTags, encode), | ||
script: getMethodsForTag(TAG_NAMES.SCRIPT, scriptTags, encode), | ||
style: getMethodsForTag(TAG_NAMES.STYLE, styleTags, encode), | ||
title: getMethodsForTag(TAG_NAMES.TITLE, { title, titleAttributes }, encode), | ||
}; | ||
}; | ||
export default mapStateOnServer; |
@@ -9,2 +9,3 @@ import { TAG_NAMES, TAG_PROPERTIES, ATTRIBUTE_NAMES } from './constants'; | ||
TITLE_TEMPLATE: 'titleTemplate', | ||
PRIORITIZE_SEO_TAGS: 'prioritizeSeoTags', | ||
}; | ||
@@ -174,2 +175,14 @@ | ||
const getAnyTrueFromPropsList = (propsList, checkedTag) => { | ||
if (Array.isArray(propsList) && propsList.length) { | ||
for (let index = 0; index < propsList.length; index += 1) { | ||
const prop = propsList[index]; | ||
if (prop[checkedTag]) { | ||
return true; | ||
} | ||
} | ||
} | ||
return false; | ||
}; | ||
const reducePropsToState = propsList => ({ | ||
@@ -207,2 +220,3 @@ baseTag: getBaseTagFromPropsList([TAG_PROPERTIES.HREF], propsList), | ||
titleAttributes: getAttributesFromPropsList(ATTRIBUTE_NAMES.TITLE, propsList), | ||
prioritizeSeoTags: getAnyTrueFromPropsList(propsList, HELMET_PROPS.PRIORITIZE_SEO_TAGS), | ||
}); | ||
@@ -214,1 +228,29 @@ | ||
export { reducePropsToState }; | ||
const checkIfPropsMatch = (props, toMatch) => { | ||
const keys = Object.keys(props); | ||
for (let i = 0; i < keys.length; i += 1) { | ||
// e.g. if rel exists in the list of allowed props [amphtml, alternate, etc] | ||
if (toMatch[keys[i]] && toMatch[keys[i]].includes(props[keys[i]])) { | ||
return true; | ||
} | ||
} | ||
return false; | ||
}; | ||
export const prioritizer = (elementsList, propsToMatch) => { | ||
if (Array.isArray(elementsList)) { | ||
return elementsList.reduce( | ||
(acc, elementAttrs) => { | ||
if (checkIfPropsMatch(elementAttrs, propsToMatch)) { | ||
acc.priority.push(elementAttrs); | ||
} else { | ||
acc.default.push(elementAttrs); | ||
} | ||
return acc; | ||
}, | ||
{ priority: [], default: [] } | ||
); | ||
} | ||
return { default: elementsList }; | ||
}; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
309420
11.47%31
-3.12%1220
11.31%180
36.36%5
25%