Skip to content

Commit

Permalink
chore: place the form at the top of blog post
Browse files Browse the repository at this point in the history
  • Loading branch information
meysam81 committed Jan 5, 2025
1 parent 868857c commit 3042fa5
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 11 deletions.
15 changes: 8 additions & 7 deletions docs/static/subscribe.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ document$.subscribe(function prepareSubForm() {
var subscriptionForm = document.getElementById("subscription-form-b8eb1947");
var subscribeButton = document.getElementById("subscribe-button-ea4577c9");
var submitInfo = document.getElementById("subscribe-submit-info-345a25b9");
var captchaElement = document.getElementById('h-captcha-0de6fb2e-eb24-454a-8dfe-4f6c9670ab7e');
var captchaElement = document.getElementById(
"h-captcha-0de6fb2e-eb24-454a-8dfe-4f6c9670ab7e"
);

function resetSubscriptionForm() {
formParentDiv.classList.add("hidden");
Expand All @@ -15,11 +17,10 @@ document$.subscribe(function prepareSubForm() {
}

function initializeCaptcha() {
if (captchaElement) {
hcaptcha.render(captchaElement, {
sitekey: '0de6fb2e-eb24-454a-8dfe-4f6c9670ab7e'
});
}
hcaptcha.reset();
hcaptcha.render(captchaElement, {
sitekey: "0de6fb2e-eb24-454a-8dfe-4f6c9670ab7e",
});
}

function subscribeButtonSubmit(event) {
Expand Down Expand Up @@ -52,4 +53,4 @@ document$.subscribe(function prepareSubForm() {
resetSubscriptionForm();
subscribeButton.addEventListener("click", subscribeButtonClick);
subscriptionForm.addEventListener("submit", subscribeButtonSubmit);
})
});
5 changes: 2 additions & 3 deletions overrides/partials/post.html
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
{% include "partials/subscription-form.html" ignore missing %}

<!-- Post excerpt -->
<article class="md-post md-post--excerpt">
<header class="md-post__header">
Expand Down Expand Up @@ -78,9 +80,6 @@

<!-- Post content -->
<div class="md-post__content md-typeset">

{% include "partials/subscription-form.html" ignore missing %}

{{ post.content }}

<!-- Continue reading link -->
Expand Down
6 changes: 5 additions & 1 deletion overrides/partials/subscription-form.html
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,11 @@ <h3>Subscribe to Newsletter</h3>
checked
value="ea947371-ce6e-46e5-ade0-736c1a72d55e"
/>
<div id="h-captcha-0de6fb2e-eb24-454a-8dfe-4f6c9670ab7e"></div>
<div
id="h-captcha-0de6fb2e-eb24-454a-8dfe-4f6c9670ab7e"
class="h-captcha"
data-sitekey="0de6fb2e-eb24-454a-8dfe-4f6c9670ab7e"
></div>
<input
class="md-button md-button--primary"
type="submit"
Expand Down

0 comments on commit 3042fa5

Please sign in to comment.