npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@pubsweet/component-email-templating

v0.3.18

Published

Send journal emails using templates from xPub/PubSweet

Downloads

71

Readme

Email Templating

About

The email-templating component contains an EmailTemplate class with one main instance method sendEmail for sending the email using the send-email component from PubSweet.

  1. sendEmail():
    • uses the send-email component from PubSweet to actually send the email based on the Email properties passed in the constructor

The Email class also provides a constructor whose properties will be used when sending the email:

  1. type: a String that can be either user or system which can be used in the unsubscribe process
  2. fromEmail: a String indicating the from name and from email address: Coko <[email protected]>
  3. toUser: an Object with two properties: email and name. The name property will be used when addressing the recipient in the email content - for example: "Dear Dr. Rachel Smith".
  4. cc: can be either a string containing an email address, or an array of string with email addresses
  5. bcc: can be either a string containing an email address, or an array of string with email addresses
  6. content: an Object which contains properties about the email:
    • subject
    • paragraph: the main text part of the email body which informs the recipient
    • signatureName - the name which will appear in the signature
    • ctaLink - the URL which will be placed in the button
    • ctaText - the text which appears on the button
    • unsubscribeLink
    • signatureJournal - the journal or company name which will appear in the signature
  7. bodyProps:
    • hasLink: a boolean which indicates if the email body contains a CTA (big button) or not
    • hasIntro: a boolean which indicates if the email body contains the "Dear Dr. John" introduction or not.
    • hasSignature: a boolean which indicates if the email body contains a typical "Kind regards," signature or not

Usage

  1. Config

    In order to use this component, you need the to add the following data in your main config file:

      journal: {
        name: 'Coko Foundation',
        staffEmail: 'Coko <[email protected]>',
        logo: 'https://coko.foundation/wp-content/uploads/2017/11/logo-coko.png',
        ctaColor: '#EE2B77', // the color of the email button
        logoLink: 'https://coko.foundation/',
        publisher: 'Coko Foundation', // this will appear in the email footer
        privacy: '', // a text containing information about the privacy policy that will appear in the email footer
        address: '2973 16th St., Suite 300, San Francisco, CA 94103', // the address in the footer
        footerText: 'You have received this email in regards to the account creation, submission, or peer review process of a paper submitted to a journal published by Coko Foundation.'
      },
  2. Dependencies

  3. Notifications

    These are the most basic emails, which contain at least a piece of text, called a paragraph, and may or may not contain an intro, an action button and a signature.

    notification

    const EmailTemplate = require('@pubsweet/component-email-template')
    const config = require('config')
    
    const { name: journalName, fromEmail: staffEmail } = config.get('journal')
    
    const paragraph = `We are please to inform you that the manuscript has passed the technical check process and is now submitted. Please click the link below to access the manuscript.`
    
    const sendNotifications = ({ user, editor, collection, fragment }) => {
      const email = new EmailTemplate({
        type: 'user',
        fromEmail,
        toUser: {
          email: user.email,
          name: `${user.lastName}`,
        },
        content: {
          ctaText: 'MANUSCRIPT DETAILS',
          signatureJournal: journalName,
          signatureName: `${editor.name}`,
          subject: `${collection.customId}: Manuscript Update`,
          paragraph,
          unsubscribeLink: `http://localhost:3000/unsubscribe/${user.id}`,
          ctaLink: `http://localhost:3000/projects/${collection.id}/versions/${fragment.id}/details`,
        },
        bodyProps: {
          hasLink: true,
          hasIntro: true,
          hasSignature: true,
        },
      })
    
      return email.sendEmail()
    }
  4. Reviewer Invitation This email template is specific to Hindawi and it requires some data that might not be available in other PubSweet apps.

    invitation