How to use the juice.default.juiceResourcesAsync function in juice

To help you get started, we’ve selected a few juice examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github FreeFeed / freefeed-server / app / mailers / BestOfDigestMailer.js View on Github external
export async function sendWeeklyBestOfEmail(user, data, digestDate) {
  const debug = createDebug('freefeed:BestOfDigestMailer');

  // TODO: const subject = config.mailer.weeklyBestOfDigestEmailSubject
  const emailBody = ReactDOMServer.renderToStaticMarkup(SummaryEmail(data));
  const emailBodyWithInlineStyles = await juice.juiceResourcesAsync(emailBody, (err, html) => {
    debug('Error occurred while trying to inline styles', err, html);
  });

  const attachments = [fa['fa-heart'], fa['fa-lock'], fa['fa-comment-o'], fa['post-protected'], fa['fa-chevron-right']];

  return Mailer.sendMail(user, `The best of your FreeFeed for the week of ${digestDate}`, {
    digest: {
      body: emailBodyWithInlineStyles,
      date: digestDate
    },
    recipient:    user,
    baseUrl:      config.host,
    mailerConfig: { subjectTransformation: (subject) => subject, },
  }, `${config.appRoot}/app/scripts/views/mailer/weeklyBestOfDigest.ejs`, true, attachments);
}
github FreeFeed / freefeed-server / app / mailers / BestOfDigestMailer.js View on Github external
export async function sendDailyBestOfEmail(user, data, digestDate) {
  const debug = createDebug('freefeed:BestOfDigestMailer');

  // TODO: const subject = config.mailer.dailyBestOfDigestEmailSubject
  const emailBody = ReactDOMServer.renderToStaticMarkup(SummaryEmail(data));
  const emailBodyWithInlineStyles = await juice.juiceResourcesAsync(emailBody, (err, html) => {
    debug('Error occurred while trying to inline styles', err, html);
  });

  const attachments = [fa['fa-heart'], fa['fa-lock'], fa['fa-comment-o'], fa['post-protected'], fa['fa-chevron-right']];

  return Mailer.sendMail(user, `The best of your FreeFeed for ${digestDate}`, {
    digest: {
      body: emailBodyWithInlineStyles,
      date: digestDate
    },
    recipient:    user,
    baseUrl:      config.host,
    mailerConfig: { subjectTransformation: (subject) => subject, },
  }, `${config.appRoot}/app/scripts/views/mailer/dailyBestOfDigest.ejs`, true, attachments);
}