Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow for configuring the Mailgun region/host #12

Merged
merged 2 commits into from
Mar 21, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ Staticwoman is a fork of [Staticman](https://github.com/eduardoboucas/staticman)
- [Customizing the size of generated comment IDs](https://github.com/hispanic/staticwoman/pull/9)
- [Bypassing Akismet spam-checking when testing](https://github.com/hispanic/staticwoman/pull/10)
- [Support for a development lifecycle that progresses through multiple environments (e.g., dev, staging, prod)](https://github.com/hispanic/staticwoman/pull/11)
- [Configuring the Mailgun region/host](https://github.com/hispanic/staticwoman/pull/12)

I expect that the original Staticman project will include some version of the above functionality sooner or later. Until then, here 'tis. I haven't made any effort to document this new functionality beyond the comments found in the above-referenced pull requests. If you have interest in making use of any of these features and you'd like to see said documentation created, please open an issue and I'll see what I can do.

Expand Down
6 changes: 6 additions & 0 deletions config.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,12 @@ const schema = {
env: 'BRANCH'
},
email: {
apiHost: {
doc: 'Mailgun API host/region to be used for email notifications. Will be overridden by a `notifications.apiHost` parameter in the site/repo config, if one is set.',
format: String,
default: 'api.mailgun.net',
env: 'EMAIL_API_HOST'
},
apiKey: {
doc: 'Mailgun API key to be used for email notifications. Will be overridden by a `notifications.apiKey` parameter in the site/repo config, if one is set.',
format: String,
Expand Down
1 change: 1 addition & 0 deletions lib/Staticman.js
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,7 @@ class Staticman {
// Initialise Mailgun
const mailgun = Mailgun({
apiKey: this.siteConfig.get('notifications.apiKey') || config.get('email.apiKey'),
host: this.siteConfig.get('notifications.apiHost') || config.get('email.apiHost'),
domain: this.siteConfig.get('notifications.domain') || config.get('email.domain')
})

Expand Down
5 changes: 5 additions & 0 deletions siteConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,11 @@ const schema = {
format: ['none', 'single', 'double'],
default: 'none'
},
apiHost: {
doc: 'Mailgun API host/region',
format: String,
default: ''
},
apiKey: {
doc: 'Mailgun API key',
format: 'EncryptedString',
Expand Down
3 changes: 3 additions & 0 deletions staticman.sample.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ comments:
# Mailgun API key
#apiKey: "1q2w3e4r"

# Mailgun API host/region. If in EU region, use 'api.eu.mailgun.net'.
#apiHost: "api.mailgun.net"

# (!) ENCRYPTED
#
# Mailgun domain (encrypted)
Expand Down