Skip to content

Commit 01c180e

Browse files
authored
added Revue support (#397)
feat: add Revue support
1 parent 70e78ae commit 01c180e

File tree

4 files changed

+36
-3
lines changed

4 files changed

+36
-3
lines changed

.env.example

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,7 @@ CONVERTKIT_API_KEY=
1919
CONVERTKIT_FORM_ID=
2020

2121
KLAVIYO_API_KEY=
22-
KLAVIYO_LIST_ID=
22+
KLAVIYO_LIST_ID=
23+
24+
REVUE_API_URL=https://www.getrevue.co/api/v2/
25+
REVUE_API_KEY=

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ I wanted it to be nearly as feature-rich as popular blogging templates like [bea
7070
- Blog templates
7171
- TOC component
7272
- Support for nested routing of blog posts
73-
- Newsletter component with support for mailchimp, buttondown, convertkit and klaviyo
73+
- Newsletter component with support for mailchimp, buttondown, convertkit, klaviyo and revue
7474
- Supports [giscus](https://github.com/laymonage/giscus), [utterances](https://github.com/utterance/utterances) or disqus
7575
- Projects page
7676
- 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
30+
// supports mailchimp, buttondown, convertkit, klaviyo, revue
3131
// Please add your .env file and modify it according to your selection
3232
provider: 'buttondown',
3333
},

pages/api/revue.js

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

0 commit comments

Comments
 (0)