Skip to content

Commit fb750f7

Browse files
committed
feat: update contact form with hCaptcha integration and fallback to Formspree; refresh sitemap lastmod dates
1 parent 42b39a8 commit fb750f7

4 files changed

Lines changed: 33 additions & 19 deletions

File tree

contact.html

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -146,10 +146,10 @@ <h3 class="contact-subheading">Send Me A Message</h3>
146146
<textarea id="contact-message" name="message" rows="5"
147147
placeholder="Tell me about your project or idea..." required></textarea>
148148
</div>
149-
<!-- Formspree honeypot -->
149+
<!-- Formspree fallback honeypot -->
150150
<input type="text" name="_gotcha" style="display:none">
151-
<!-- Web3Forms honeypot -->
152-
<input type="checkbox" name="botcheck" style="display:none">
151+
<!-- Web3Forms Native hCaptcha -->
152+
<div class="h-captcha" data-captcha="true" style="margin-bottom: 1.25rem;"></div>
153153
<button type="submit" id="contact-submit" class="form-submit-btn">
154154
<span class="btn-text">Send Message</span>
155155
<span class="btn-loading" style="display:none;">
@@ -180,6 +180,7 @@ <h3 class="contact-subheading">Send Me A Message</h3>
180180
<div id="theme-toggle-icon" class="theme-icon"><i class="fas"></i></div>
181181
</div>
182182

183+
<script src="https://web3forms.com/client/script.js" async defer></script>
183184
<script src="js/contact.js"></script>
184185
<script src="js/app.js"></script>
185186

contact_template.html

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,10 +114,10 @@ <h3 class="contact-subheading">Send Me A Message</h3>
114114
<textarea id="contact-message" name="message" rows="5"
115115
placeholder="Tell me about your project or idea..." required></textarea>
116116
</div>
117-
<!-- Formspree honeypot -->
117+
<!-- Formspree fallback honeypot -->
118118
<input type="text" name="_gotcha" style="display:none">
119-
<!-- Web3Forms honeypot -->
120-
<input type="checkbox" name="botcheck" style="display:none">
119+
<!-- Web3Forms Native hCaptcha -->
120+
<div class="h-captcha" data-captcha="true" style="margin-bottom: 1.25rem;"></div>
121121
<button type="submit" id="contact-submit" class="form-submit-btn">
122122
<span class="btn-text">Send Message</span>
123123
<span class="btn-loading" style="display:none;">
@@ -148,6 +148,7 @@ <h3 class="contact-subheading">Send Me A Message</h3>
148148
<div id="theme-toggle-icon" class="theme-icon"><i class="fas"></i></div>
149149
</div>
150150

151+
<script src="https://web3forms.com/client/script.js" async defer></script>
151152
<script src="js/contact.js"></script>
152153
<script src="js/app.js"></script>
153154

js/contact.js

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,18 @@
1515
form.addEventListener('submit', function (e) {
1616
e.preventDefault();
1717

18+
var formData = new FormData(form);
19+
20+
var hCaptchaResponse = formData.get('h-captcha-response');
21+
if (!hCaptchaResponse) {
22+
showStatus('error', 'Please complete the CAPTCHA spam check before sending.');
23+
return;
24+
}
25+
1826
btnText.style.display = 'none';
1927
btnLoading.style.display = 'inline';
2028
submitBtn.disabled = true;
2129

22-
var formData = new FormData(form);
23-
2430
var primaryData = new FormData();
2531
for (var pair of formData.entries()) {
2632
primaryData.append(pair[0], pair[1]);
@@ -33,13 +39,16 @@
3339
headers: { 'Accept': 'application/json' }
3440
})
3541
.then(function (response) {
36-
if (response.ok) {
42+
return response.json();
43+
})
44+
.then(function (data) {
45+
if (data && data.success) {
3746
showStatus('success', 'Thank you! Your message has been sent successfully.');
3847
form.reset();
39-
return;
48+
} else {
49+
console.warn('Web3Forms failed. Falling back to Formspree...');
50+
return sendFormspree(formData);
4051
}
41-
console.warn('Web3Forms failed. Falling back to Formspree...');
42-
return sendFormspree(formData);
4352
})
4453
.catch(function () {
4554
console.warn('Web3Forms network error. Falling back to Formspree...');
@@ -53,6 +62,9 @@
5362
});
5463

5564
function sendFormspree(formData) {
65+
formData.delete('h-captcha-response');
66+
formData.delete('g-recaptcha-response');
67+
5668
return fetch(FORMSPREE_URL, {
5769
method: 'POST',
5870
body: formData,
@@ -89,4 +101,4 @@
89101
}, 400);
90102
}, 6000);
91103
}
92-
})();
104+
})();

sitemap.xml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,37 +2,37 @@
22
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
33
<url>
44
<loc>https://gojo-rika.github.io/</loc>
5-
<lastmod>2026-04-03</lastmod>
5+
<lastmod>2026-04-04</lastmod>
66
<changefreq>monthly</changefreq>
77
<priority>1.0</priority>
88
</url>
99
<url>
1010
<loc>https://gojo-rika.github.io/resume.html</loc>
11-
<lastmod>2026-04-03</lastmod>
11+
<lastmod>2026-04-04</lastmod>
1212
<changefreq>monthly</changefreq>
1313
<priority>0.8</priority>
1414
</url>
1515
<url>
1616
<loc>https://gojo-rika.github.io/projects.html</loc>
17-
<lastmod>2026-04-03</lastmod>
17+
<lastmod>2026-04-04</lastmod>
1818
<changefreq>monthly</changefreq>
1919
<priority>0.8</priority>
2020
</url>
2121
<url>
2222
<loc>https://gojo-rika.github.io/blog.html</loc>
23-
<lastmod>2026-04-03</lastmod>
23+
<lastmod>2026-04-04</lastmod>
2424
<changefreq>weekly</changefreq>
2525
<priority>0.9</priority>
2626
</url>
2727
<url>
2828
<loc>https://gojo-rika.github.io/contact.html</loc>
29-
<lastmod>2026-04-03</lastmod>
29+
<lastmod>2026-04-04</lastmod>
3030
<changefreq>yearly</changefreq>
3131
<priority>0.6</priority>
3232
</url>
3333
<url>
3434
<loc>https://gojo-rika.github.io/tech-stack.html</loc>
35-
<lastmod>2026-04-03</lastmod>
35+
<lastmod>2026-04-04</lastmod>
3636
<changefreq>monthly</changefreq>
3737
<priority>0.7</priority>
3838
</url>

0 commit comments

Comments
 (0)