summaryrefslogtreecommitdiffstats
path: root/themes/danix-xyz-hacker/layouts/shortcodes
diff options
context:
space:
mode:
authorDanilo M. <danix@danix.xyz>2026-04-15 16:38:12 +0200
committerDanilo M. <danix@danix.xyz>2026-04-15 16:38:12 +0200
commit231d29bf26820ca058dec57c06345943ca6dbbf2 (patch)
treeb60f6e4afd1bf88bcfeb02b6d28f00cc1806ccc9 /themes/danix-xyz-hacker/layouts/shortcodes
parent46065a5077f113ab772e3a46f83748efe5f81caf (diff)
downloaddanixxyz-231d29bf26820ca058dec57c06345943ca6dbbf2.tar.gz
danixxyz-231d29bf26820ca058dec57c06345943ca6dbbf2.zip
Fix shortcode location: move from shortcodes/ to layouts/shortcodes/
Hugo v0.156.0+ requires shortcodes to be in layouts/shortcodes/ directory. Moved all shortcodes (gravatar, image, gallery, contact-form) to correct location. Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
Diffstat (limited to 'themes/danix-xyz-hacker/layouts/shortcodes')
-rw-r--r--themes/danix-xyz-hacker/layouts/shortcodes/contact-form.html114
-rw-r--r--themes/danix-xyz-hacker/layouts/shortcodes/gallery.html12
-rw-r--r--themes/danix-xyz-hacker/layouts/shortcodes/gravatar.html17
-rw-r--r--themes/danix-xyz-hacker/layouts/shortcodes/image.html22
4 files changed, 165 insertions, 0 deletions
diff --git a/themes/danix-xyz-hacker/layouts/shortcodes/contact-form.html b/themes/danix-xyz-hacker/layouts/shortcodes/contact-form.html
new file mode 100644
index 0000000..19884aa
--- /dev/null
+++ b/themes/danix-xyz-hacker/layouts/shortcodes/contact-form.html
@@ -0,0 +1,114 @@
+{{- $contactFormData := dict -}}
+
+<form id="contact-form" x-data="contactForm()" @submit.prevent="submitContactForm" class="space-y-6">
+ <!-- Name Field -->
+ <div>
+ <label for="name" class="block text-sm font-medium text-text mb-2">
+ {{ i18n "name" }}
+ </label>
+ <input
+ id="name"
+ type="text"
+ x-model="formData.name"
+ required
+ class="w-full px-4 py-2 bg-bg border border-border/50 rounded-lg text-text placeholder-text-dim focus:outline-none focus:border-accent focus:ring-1 focus:ring-accent transition-colors"
+ :aria-busy="isSubmitting"
+ />
+ </div>
+
+ <!-- Email Field -->
+ <div>
+ <label for="email" class="block text-sm font-medium text-text mb-2">
+ {{ i18n "email" }}
+ </label>
+ <input
+ id="email"
+ type="email"
+ x-model="formData.email"
+ required
+ class="w-full px-4 py-2 bg-bg border border-border/50 rounded-lg text-text placeholder-text-dim focus:outline-none focus:border-accent focus:ring-1 focus:ring-accent transition-colors"
+ :aria-busy="isSubmitting"
+ />
+ </div>
+
+ <!-- Message Field -->
+ <div>
+ <label for="message" class="block text-sm font-medium text-text mb-2">
+ {{ i18n "message" }}
+ </label>
+ <textarea
+ id="message"
+ x-model="formData.message"
+ rows="5"
+ required
+ class="w-full px-4 py-2 bg-bg border border-border/50 rounded-lg text-text placeholder-text-dim focus:outline-none focus:border-accent focus:ring-1 focus:ring-accent transition-colors resize-none"
+ :aria-busy="isSubmitting"
+ ></textarea>
+ </div>
+
+ <!-- Status Message -->
+ <div
+ x-show="statusMessage"
+ x-text="statusMessage"
+ :class="statusClass"
+ class="px-4 py-3 rounded-lg text-sm transition-all"
+ ></div>
+
+ <!-- Submit Button -->
+ <button
+ type="submit"
+ :disabled="isSubmitting"
+ class="w-full px-4 py-2 bg-accent text-bg font-medium rounded-lg hover:bg-accent/90 disabled:opacity-50 disabled:cursor-not-allowed transition-colors"
+ >
+ <span x-show="!isSubmitting">{{ i18n "submit" }}</span>
+ <span x-show="isSubmitting">{{ i18n "sending" }}</span>
+ </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>
diff --git a/themes/danix-xyz-hacker/layouts/shortcodes/gallery.html b/themes/danix-xyz-hacker/layouts/shortcodes/gallery.html
new file mode 100644
index 0000000..b66c327
--- /dev/null
+++ b/themes/danix-xyz-hacker/layouts/shortcodes/gallery.html
@@ -0,0 +1,12 @@
+{{- $cols := .Get "cols" | default "2" -}}
+
+<div class="my-8 grid gap-4" style="grid-template-columns: repeat({{ $cols }}, 1fr)">
+ {{- range $line := strings.Split .Inner "\n" -}}
+ {{- if strings.Contains $line "![" -}}
+ {{- $image := strings.TrimSpace $line -}}
+ {{- if $image -}}
+ {{ $image | markdownify | safeHTML }}
+ {{- end -}}
+ {{- end -}}
+ {{- end -}}
+</div>
diff --git a/themes/danix-xyz-hacker/layouts/shortcodes/gravatar.html b/themes/danix-xyz-hacker/layouts/shortcodes/gravatar.html
new file mode 100644
index 0000000..7151ee5
--- /dev/null
+++ b/themes/danix-xyz-hacker/layouts/shortcodes/gravatar.html
@@ -0,0 +1,17 @@
+{{- $email := .Get "email" -}}
+{{- $size := .Get "size" | default "256" -}}
+{{- $alt := .Get "alt" | default "User avatar" -}}
+{{- $class := .Get "class" | default "w-32 h-32 rounded-full" -}}
+
+{{- if $email -}}
+ {{- $hash := md5 (trim (strings.ToLower $email)) -}}
+ {{- $gravatarURL := printf "https://www.gravatar.com/avatar/%s?s=%s&d=identicon" $hash $size -}}
+ <img
+ src="{{ $gravatarURL }}"
+ alt="{{ $alt }}"
+ class="{{ $class }}"
+ loading="lazy"
+ />
+{{- else -}}
+ {{- errorf "gravatar shortcode: 'email' parameter is required" -}}
+{{- end -}}
diff --git a/themes/danix-xyz-hacker/layouts/shortcodes/image.html b/themes/danix-xyz-hacker/layouts/shortcodes/image.html
new file mode 100644
index 0000000..07a698d
--- /dev/null
+++ b/themes/danix-xyz-hacker/layouts/shortcodes/image.html
@@ -0,0 +1,22 @@
+{{- $src := .Get "src" -}}
+{{- $alt := .Get "alt" | default "Image" -}}
+{{- $caption := .Get "caption" -}}
+{{- $class := .Get "class" | default "rounded-lg border border-border/30" -}}
+
+{{- if $src -}}
+ <figure class="my-8">
+ <img
+ src="{{ $src }}"
+ alt="{{ $alt }}"
+ class="{{ $class }} w-full h-auto"
+ loading="lazy"
+ />
+ {{- if $caption -}}
+ <figcaption class="mt-3 text-center text-sm text-text-dim italic">
+ {{ $caption }}
+ </figcaption>
+ {{- end -}}
+ </figure>
+{{- else -}}
+ {{- errorf "image shortcode: 'src' parameter is required" -}}
+{{- end -}}