Skip to content

Commit 2e0aad8

Browse files
committed
Add EmailOctopus
1 parent 923da1b commit 2e0aad8

File tree

5 files changed

+41
-4
lines changed

5 files changed

+41
-4
lines changed

.env.example

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,8 @@ KLAVIYO_API_KEY=
2222
KLAVIYO_LIST_ID=
2323

2424
REVUE_API_URL=https://www.getrevue.co/api/v2/
25-
REVUE_API_KEY=
25+
REVUE_API_KEY=
26+
27+
EMAILOCTOPUS_API_URL=https://emailoctopus.com/api/1.6/
28+
EMAILOCTOPUS_API_KEY=
29+
EMAILOCTOPUS_LIST_ID=

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ I wanted it to be nearly as feature-rich as popular blogging templates like [bea
7575
- Blog templates
7676
- TOC component
7777
- Support for nested routing of blog posts
78-
- Newsletter component with support for mailchimp, buttondown, convertkit, klaviyo and revue
78+
- Newsletter component with support for mailchimp, buttondown, convertkit, klaviyo, revue, and emailoctopus
7979
- Supports [giscus](https://github.com/laymonage/giscus), [utterances](https://github.com/utterance/utterances) or disqus
8080
- Projects page
8181
- Preconfigured security headers

data/blog/introducing-tailwind-nextjs-starter-blog.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ I wanted it to be nearly as feature-rich as popular blogging templates like [bea
6060
- Blog templates
6161
- TOC component
6262
- Support for nested routing of blog posts
63-
- Newsletter component with support for mailchimp, buttondown and convertkit
63+
- Newsletter component with support for mailchimp, buttondown, convertkit, klaviyo, revue, and emailoctopus
6464
- Supports [giscus](https://github.com/laymonage/giscus), [utterances](https://github.com/utterance/utterances) or disqus
6565
- Projects page
6666
- Preconfigured security headers

data/siteMetadata.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ const siteMetadata = {
2727
googleAnalyticsId: '', // e.g. UA-000000-2 or G-XXXXXXX
2828
},
2929
newsletter: {
30-
// supports mailchimp, buttondown, convertkit, klaviyo, revue
30+
// supports mailchimp, buttondown, convertkit, klaviyo, revue, emailoctopus
3131
// Please add your .env file and modify it according to your selection
3232
provider: 'buttondown',
3333
},

pages/api/emailoctopus.js

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
// eslint-disable-next-line import/no-anonymous-default-export
2+
export default async (req, res) => {
3+
const { email } = req.body
4+
if (!email) {
5+
return res.status(400).json({ error: 'Email is required' })
6+
}
7+
8+
try {
9+
const API_URL = process.env.EMAILOCTOPUS_API_URL
10+
const API_KEY = process.env.EMAILOCTOPUS_API_KEY
11+
const LIST_ID = process.env.EMAILOCTOPUS_LIST_ID
12+
13+
const data = { email_address: email, api_key: API_KEY }
14+
15+
const API_ROUTE = `${API_URL}lists/${LIST_ID}/contacts`
16+
17+
const response = await fetch(API_ROUTE, {
18+
body: JSON.stringify(data),
19+
headers: {
20+
'Content-Type': 'application/json',
21+
},
22+
method: 'POST',
23+
})
24+
25+
if (response.status >= 400) {
26+
return res.status(500).json({ error: `There was an error subscribing to the list.` })
27+
}
28+
29+
return res.status(201).json({ error: '' })
30+
} catch (error) {
31+
return res.status(500).json({ error: error.message || error.toString() })
32+
}
33+
}

0 commit comments

Comments
 (0)