A Scrivito widget including a Mailchimp mailing list signup via lambda function
Install the package in your scrivito app:
$ npm install scrivito-mailchimp-widget
Import the widget in your javascript (e.g. in src/Widgets/index.js
):
import "scrivito-mailchimp-widget";
This widget is designed to be used with Netlify Functions. To do so add or update the following to your netlify.toml
file:
command = "npm run build && npm run build:lambda"
functions = "lambda"
Then add these scripts to your package.json
file:
"build:lambda": "netlify-lambda build src/lambda",
"start:lambda": "netlify-lambda serve src/lambda",
Then extract the lambda/
folder and contents from
/node_modules/scrivito-mailchimp-widget/src/
and set it at the root level of your project in /src/
.
ie:
$ cp -r node_modules/scrivito-mailchimp-widget/src/lambda src/
Finally, you will need to add your Mailchimp credentials for your list to the the Environment variables in your Netlify dashboard.
MAILCHIMP_API_KEY
MAILCHIMP_LIST_ID
MAILCHIMP_REGION
In the widget properties you can set:
- Submit button text
- Success message text
$ npm run eslint
and
$ npm run es-check