lib/utils/head.js
function BuildHead(metaObject = {}) {
    const metaCopy = Object.assign({}, metaObject);
    let finalString = "";
    if (metaCopy.title) {
        finalString += `<title>${metaCopy.title}</title>`;
    }

    if (metaCopy.meta) {
        throw new Error("WARNING - DEPRECATED: It looks like you're using the old meta object, please migrate to the new one");
    }

    if (metaCopy.metas) {
        for (let index = 0; index < metaCopy.metas.length; index++) {
            const headItem = metaCopy.metas[index];
            const processedItem = ProcessMetaItem(headItem);
            if (processedItem !== undefined) {
                finalString += processedItem;
            }
        }
    }

    if (metaCopy.scripts) {
        for (let index = 0; index < metaCopy.scripts.length; index++) {
            const headItem = metaCopy.scripts[index];
            const processedItem = ProcessScriptItem(headItem);
            if (processedItem !== undefined) {
                finalString += processedItem;
            }
        }
    }

    if (metaCopy.styles) {
        for (let index = 0; index < metaCopy.styles.length; index++) {
            const headItem = metaCopy.styles[index];
            const processedItem = ProcessStyleItem(headItem);
            if (processedItem !== undefined) {
                finalString += processedItem;
            }
        }
    }

    if (metaCopy.structuredData) {
        finalString += `<script type="application/ld+json">${JSON.stringify(metaCopy.structuredData)}</script>`;
    }

    return finalString;
}
function BuildHead(metaObject = {}) {
    const metaCopy = Object.assign({}, metaObject);
    let finalString = "";
    if (metaCopy.title) {
        finalString += `<title>${metaCopy.title}</title>`;
    }

    if (metaCopy.meta) {
        throw new Error("WARNING - DEPRECATED: It looks like you're using the old meta object, please migrate to the new one");
    }

    if (metaCopy.metas) {
        for (let index = 0; index < metaCopy.metas.length; index++) {
            const headItem = metaCopy.metas[index];
            const processedItem = ProcessMetaItem(headItem);
            if (processedItem !== undefined) {
                finalString += processedItem;
            }
        }
    }

    if (metaCopy.scripts) {
        for (let index = 0; index < metaCopy.scripts.length; index++) {
            const headItem = metaCopy.scripts[index];
            const processedItem = ProcessScriptItem(headItem);
            if (processedItem !== undefined) {
                finalString += processedItem;
            }
        }
    }

    if (metaCopy.styles) {
        for (let index = 0; index < metaCopy.styles.length; index++) {
            const headItem = metaCopy.styles[index];
            const processedItem = ProcessStyleItem(headItem);
            if (processedItem !== undefined) {
                finalString += processedItem;
            }
        }
    }

    if (metaCopy.structuredData) {
        finalString += `<script type="application/ld+json">${JSON.stringify(metaCopy.structuredData)}</script>`;
    }

    return finalString;
}
function BuildHead ( metaObject = { } ) { const metaCopy = Object . assign ( { } , metaObject ) ; let finalString = "" ; if ( metaCopy . title ) { finalString += ` ${ metaCopy . title } ` ; } if ( metaCopy . meta ) { throw new Error ( "WARNING - DEPRECATED: It looks like you're using the old meta object, please migrate to the new one" ) ; } if ( metaCopy . metas ) { for ( let index = 0 ; index < metaCopy . metas . length ; index ++ ) { const headItem = metaCopy . metas [ index ] ; const processedItem = ProcessMetaItem ( headItem ) ; if ( processedItem !== undefined ) { finalString += processedItem ; } } } if ( metaCopy . scripts ) { for ( let index = 0 ; index < metaCopy . scripts . length ; index ++ ) { const headItem = metaCopy . scripts [ index ] ; const processedItem = ProcessScriptItem ( headItem ) ; if ( processedItem !== undefined ) { finalString += processedItem ; } } } if ( metaCopy . styles ) { for ( let index = 0 ; index < metaCopy . styles . length ; index ++ ) { const headItem = metaCopy . styles [ index ] ; const processedItem = ProcessStyleItem ( headItem ) ; if ( processedItem !== undefined ) { finalString += processedItem ; } } } if ( metaCopy . structuredData ) { finalString += ` ${ JSON . stringify ( metaCopy . structuredData ) } ` ; } return finalString ; }
BuildHead takes the array and splits it up for processing
@param {object} metaObject
@returns {String}
BuildHead takes the array and splits it up for processing