Skip to content

Commit 96ecb23

Browse files
author
SPRINX0\prochazka
committed
newsletter
1 parent 217ee00 commit 96ecb23

File tree

4 files changed

+62
-1
lines changed

4 files changed

+62
-1
lines changed

content/_index.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,5 @@ download_button: true
2424

2525

2626
{{< sponsor >}}
27-
{{< feedback >}}
27+
{{< feedback >}}
28+
{{< newsletter >}}

content/about.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,3 +51,5 @@ You can see, what wrote about DbGate [Softpedia](https://www.softpedia.com/get/I
5151
Any feedback is welcome, please create issue on [GitHub](https://github.com/dbgate/dbgate/issues/new/choose)
5252

5353
{{< sponsor >}}
54+
55+
{{< newsletter >}}

content/download.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,5 @@ aliases:
1111
{{< download >}}
1212

1313
{{< feedback >}}
14+
15+
{{< newsletter >}}

layouts/shortcodes/newsletter.html

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
<p>
2+
<h2>Join our newsletter</h2>
3+
Stay informed! One mail per month about DbGate, SQL and databases. We will not share your info with anyone.
4+
</p>
5+
6+
<form>
7+
<!-- Newsletter Email -->
8+
<div class="form-group mb-3">
9+
<input type="email" class="input" id="newsletterEmail" placeholder="Email addres" />
10+
<p class="help is-danger" id="email-error" style="display: none">Please enter valid e-mail</p>
11+
</div>
12+
13+
<p>
14+
<a onclick="subscribeNewsletter()" class="button is-info is-medium"> Subscribe </a>
15+
</p>
16+
</form>
17+
18+
<script>
19+
async function subscribeNewsletter() {
20+
const emailInput = document.getElementById('newsletterEmail');
21+
const emailError = document.getElementById('email-error');
22+
const email = emailInput.value;
23+
24+
// Simple e-mail pattern
25+
const emailPattern = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
26+
if (!emailPattern.test(email)) {
27+
emailInput.classList.add('is-danger'); // You could also handle is-invalid via .form-control
28+
emailError.style.display = 'block';
29+
return;
30+
} else {
31+
emailInput.classList.remove('is-danger');
32+
emailError.style.display = 'none';
33+
}
34+
35+
const data = {
36+
email: email,
37+
};
38+
39+
try {
40+
const response = await fetch(
41+
'https://api.dbgate.io/newsletter/dbgate.org',
42+
{
43+
method: 'POST',
44+
headers: {
45+
'Content-Type': 'application/json',
46+
},
47+
body: JSON.stringify(data),
48+
}
49+
);
50+
alert('Thank you for joining our newslette.');
51+
} catch (error) {
52+
console.error('Error:', error);
53+
alert('An error occurred while sending data.');
54+
}
55+
}
56+
</script>

0 commit comments

Comments
 (0)