Skip to content

Commit

Permalink
Read listId from markdown frontmatter
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcL committed May 8, 2020
1 parent c627ae5 commit 91cb40c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ const options = {
output: './directory/to/output/html/to/'

// Optional if you want a Mailchimp campaign to be created
// The Mailchimp list ID can also be set as frontmatter in your markdown email
apikey: 'mailchimp-api-key',
listid: 'mailchimp-list-id',
};
Expand All @@ -91,6 +92,7 @@ If you plan to create the Mailchimp campaign in addition to rendering an HTML te
* **title** - The title of the campaign
* **fromName** - The name of the person that is sending the email
* **replyTo** - The email address to reply to
* **listId** - (Optional) Mailchimp List (Audience) identifier. If this is not set then the list ID should be passed in the `options` or as the `MAILCHIMP_LIST_ID` environment variable.

You can use [Mailchimp merge tags](https://mailchimp.com/help/all-the-merge-tags-cheat-sheet/) in your markdown but ensure that you set the `keeptags` option when converting. This allows you to keep a tag such as `*|MC:DATE|*` without it being converted to italic text.

Expand Down
7 changes: 5 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
const markdownToHtmlEmail = require('./markdownToHtmlEmail');
const createMailchimpCampaign = require('./createMailchimpCampaign');

const convertAndCreateCampaign = async args => {
const convertAndCreateCampaign = async (args) => {
try {
const emailData = await markdownToHtmlEmail(args);
const {
frontmatter: { listId: frontmatterListId },
} = emailData;

const { apikey: apiKey, listid: listId } = args;
const options = {
apiKey,
listId,
listId: listId || frontmatterListId,
...emailData,
};

Expand Down

0 comments on commit 91cb40c

Please sign in to comment.