appendLinks(html, links) {
    const { JSDOM } = JsDom;
    const parsed = new JSDOM(html);
    const { document } = parsed && parsed.window;
    const head = document && document.getElementsByTagName("head")[0];
    const insertBeforeTag =
      document && document.querySelector(this.options.insertBefore);
    if (head) {
      if (!insertBeforeTag) {
        // The `insertBeforeTag` is not present. Prepend to head itself.
        head.innerHTML = `${links}${head.innerHTML.trim()}`;
      } else {
        const parent = insertBeforeTag.parentNode;
        const newNodes = Array.from(this.createNodeFromHtml(document, links));
        if (newNodes && newNodes.length > 0) {
          newNodes.forEach((n) => {
            parent.insertBefore(n, insertBeforeTag);
          });
        }
      }
      return parsed.serialize();
    }
    return html;
  }
/**
   * Parse the passed html string and add <link> tags.
   *
   * @param {String} html Source html string
   * @param {String} links String representation of all links
   * @returns {String} Modified html as string
   *
   */
Parse the passed html string and add  tags.
@param {String} html Source html string
@param {String} links String representation of all links
@returns {String} Modified html as string
Parse the passed html string and add tags . @param { String } html Source html string @param { String } links String representation of all links @returns { String } Modified html as string
appendLinks(html, links) {
    const { JSDOM } = JsDom;
    const parsed = new JSDOM(html);
    const { document } = parsed && parsed.window;
    const head = document && document.getElementsByTagName("head")[0];
    const insertBeforeTag =
      document && document.querySelector(this.options.insertBefore);
    if (head) {
      if (!insertBeforeTag) {
        head.innerHTML = `${links}${head.innerHTML.trim()}`;
      } else {
        const parent = insertBeforeTag.parentNode;
        const newNodes = Array.from(this.createNodeFromHtml(document, links));
        if (newNodes && newNodes.length > 0) {
          newNodes.forEach((n) => {
            parent.insertBefore(n, insertBeforeTag);
          });
        }
      }
      return parsed.serialize();
    }
    return html;
  }
appendLinks ( html , links ) { const { JSDOM } = JsDom ; const parsed = new JSDOM ( html ) ; const { document } = parsed && parsed . window ; const head = document && document . getElementsByTagName ( "head" ) [ 0 ] ; const insertBeforeTag = document && document . querySelector ( this . options . insertBefore ) ; if ( head ) { if ( ! insertBeforeTag ) { head . innerHTML = ` ${ links } ${ head . innerHTML . trim ( ) } ` ; } else { const parent = insertBeforeTag . parentNode ; const newNodes = Array . from ( this . createNodeFromHtml ( document , links ) ) ; if ( newNodes && newNodes . length > 0 ) { newNodes . forEach ( ( n ) => { parent . insertBefore ( n , insertBeforeTag ) ; } ) ; } } return parsed . serialize ( ) ; } return html ; }
Parse the passed html string and add <link> tags.
Parse the passed html string and add <link > tags .
// The `insertBeforeTag` is not present. Prepend to head itself.