diff options
| author | Danilo M. <danix@danix.xyz> | 2026-04-15 17:43:32 +0200 |
|---|---|---|
| committer | Danilo M. <danix@danix.xyz> | 2026-04-15 17:43:32 +0200 |
| commit | e9883e5732c243ced33020e7f2e1c12388cd6686 (patch) | |
| tree | d74f05153f5ea44c1a95927641832e76db4ab7af /themes/danix-xyz-hacker/layouts | |
| parent | 93aa1b4bb969093a256a9938e6563c301023a899 (diff) | |
| download | danixxyz-e9883e5732c243ced33020e7f2e1c12388cd6686.tar.gz danixxyz-e9883e5732c243ced33020e7f2e1c12388cd6686.zip | |
Extract contact form JavaScript to separate file and remove shortcode from contact pages
- Move contact form Alpine.js logic to assets/js/contact-form.js
- Simplify contact-form.html shortcode by removing inline script
- Load contact-form.js in baseof.html after Alpine.js
- Temporarily remove {{< contact_form >}} shortcode from contact pages
(shortcode parsing issue to investigate later)
- Contact pages now display with placeholder text
Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
Diffstat (limited to 'themes/danix-xyz-hacker/layouts')
| -rw-r--r-- | themes/danix-xyz-hacker/layouts/_default/baseof.html | 4 | ||||
| -rw-r--r-- | themes/danix-xyz-hacker/layouts/shortcodes/contact-form.html | 47 |
2 files changed, 4 insertions, 47 deletions
diff --git a/themes/danix-xyz-hacker/layouts/_default/baseof.html b/themes/danix-xyz-hacker/layouts/_default/baseof.html index face55d..80137c1 100644 --- a/themes/danix-xyz-hacker/layouts/_default/baseof.html +++ b/themes/danix-xyz-hacker/layouts/_default/baseof.html @@ -71,5 +71,9 @@ <!-- Language switcher script --> {{ $langScript := resources.Get "js/language-switcher.js" | minify }} <script src="{{ $langScript.RelPermalink }}"></script> + + <!-- Contact form script --> + {{ $contactScript := resources.Get "js/contact-form.js" | minify }} + <script src="{{ $contactScript.RelPermalink }}"></script> </body> </html> diff --git a/themes/danix-xyz-hacker/layouts/shortcodes/contact-form.html b/themes/danix-xyz-hacker/layouts/shortcodes/contact-form.html index 19884aa..6dbdb2d 100644 --- a/themes/danix-xyz-hacker/layouts/shortcodes/contact-form.html +++ b/themes/danix-xyz-hacker/layouts/shortcodes/contact-form.html @@ -65,50 +65,3 @@ </button> </form> -<script> -document.addEventListener('alpine:init', () => { - Alpine.data('contactForm', () => ({ - formData: { - name: '', - email: '', - message: '' - }, - isSubmitting: false, - statusMessage: '', - statusClass: '', - - async submitContactForm() { - this.isSubmitting = true; - this.statusMessage = ''; - this.statusClass = ''; - - try { - const response = await fetch('/contact.php', { - method: 'POST', - headers: { - 'Content-Type': 'application/json', - }, - body: JSON.stringify(this.formData) - }); - - const data = await response.json(); - - if (response.ok) { - this.statusMessage = '{{ i18n "form_success" | default "Message sent successfully!" }}'; - this.statusClass = 'bg-green-100 text-green-800 border border-green-300'; - this.formData = { name: '', email: '', message: '' }; - } else { - this.statusMessage = data.error || '{{ i18n "form_error" | default "An error occurred. Please try again." }}'; - this.statusClass = 'bg-red-100 text-red-800 border border-red-300'; - } - } catch (error) { - this.statusMessage = '{{ i18n "form_error" | default "An error occurred. Please try again." }}'; - this.statusClass = 'bg-red-100 text-red-800 border border-red-300'; - console.error('Form submission error:', error); - } finally { - this.isSubmitting = false; - } - } - })); -}); -</script> |
