upstream #1
| @@ -19,4 +19,7 @@ CONVERTKIT_API_KEY= | ||||
| CONVERTKIT_FORM_ID=  | ||||
|  | ||||
| KLAVIYO_API_KEY= | ||||
| KLAVIYO_LIST_ID= | ||||
| KLAVIYO_LIST_ID= | ||||
|  | ||||
| REVUE_API_URL=https://www.getrevue.co/api/v2/ | ||||
| REVUE_API_KEY= | ||||
| @@ -70,7 +70,7 @@ I wanted it to be nearly as feature-rich as popular blogging templates like [bea | ||||
| - Blog templates | ||||
| - TOC component | ||||
| - Support for nested routing of blog posts | ||||
| - Newsletter component with support for mailchimp, buttondown, convertkit and klaviyo | ||||
| - Newsletter component with support for mailchimp, buttondown, convertkit, klaviyo and revue | ||||
| - Supports [giscus](https://github.com/laymonage/giscus), [utterances](https://github.com/utterance/utterances) or disqus | ||||
| - Projects page | ||||
| - Preconfigured security headers | ||||
|   | ||||
| @@ -27,7 +27,7 @@ const siteMetadata = { | ||||
|     googleAnalyticsId: '', // e.g. UA-000000-2 or G-XXXXXXX | ||||
|   }, | ||||
|   newsletter: { | ||||
|     // supports mailchimp, buttondown, convertkit, klaviyo | ||||
|     // supports mailchimp, buttondown, convertkit, klaviyo, revue | ||||
|     // Please add your .env file and modify it according to your selection | ||||
|     provider: 'buttondown', | ||||
|   }, | ||||
|   | ||||
							
								
								
									
										30
									
								
								pages/api/revue.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										30
									
								
								pages/api/revue.js
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,30 @@ | ||||
| // eslint-disable-next-line import/no-anonymous-default-export | ||||
| export default async (req, res) => { | ||||
|   const { email } = req.body | ||||
|  | ||||
|   if (!email) { | ||||
|     return res.status(400).json({ error: 'Email is required' }) | ||||
|   } | ||||
|  | ||||
|   try { | ||||
|     const API_KEY = process.env.REVUE_API_KEY | ||||
|     const revueRoute = `${process.env.REVUE_API_URL}subscribers` | ||||
|  | ||||
|     const response = await fetch(revueRoute, { | ||||
|       method: 'POST', | ||||
|       headers: { | ||||
|         Authorization: `Token ${API_KEY}`, | ||||
|         'Content-Type': 'application/json', | ||||
|       }, | ||||
|       body: JSON.stringify({ email, double_opt_in: false }), | ||||
|     }) | ||||
|  | ||||
|     if (response.status >= 400) { | ||||
|       return res.status(500).json({ error: `There was an error subscribing to the list.` }) | ||||
|     } | ||||
|  | ||||
|     return res.status(201).json({ error: '' }) | ||||
|   } catch (error) { | ||||
|     return res.status(500).json({ error: error.message || error.toString() }) | ||||
|   } | ||||
| } | ||||
		Reference in New Issue
	
	Block a user