mirror of
https://github.com/svemagie/blog-eleventy-indiekit.git
synced 2026-04-02 16:44:56 +02:00
fix: reply buttons hidden + missing webmentions on pages without build-time data
Two bugs fixed: 1. Reply buttons stayed hidden despite owner being detected. The alpine:initialized event fires before the async checkOwner() fetch resolves, so isOwner was always false when the handler ran. Fix: dispatch custom owner:detected event from init() after both owner check and owner replies are loaded. 2. Client-side webmentions not rendering on pages with zero build-time webmentions. createWebmentionsSection() looked for .webmention-form but the <details> element lacked that class, so the insertion point was never found. Fix: add webmention-form class to the details element. Confab-Link: http://localhost:8080/sessions/184584f4-67e1-485a-aba8-02ac34a600fe
This commit is contained in:
@@ -192,7 +192,7 @@
|
||||
{% endif %}
|
||||
|
||||
{# Webmention send form — collapsed by default #}
|
||||
<details class="mt-8">
|
||||
<details class="webmention-form mt-8">
|
||||
<summary class="text-sm font-semibold text-surface-600 dark:text-surface-400 cursor-pointer hover:text-surface-700 dark:hover:text-surface-300 transition-colors list-none [&::-webkit-details-marker]:hidden flex items-center gap-1.5">
|
||||
<svg class="w-3.5 h-3.5 transition-transform [[open]>&]:rotate-90" fill="none" stroke="currentColor" viewBox="0 0 24 24" aria-hidden="true">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 5l7 7-7 7"/>
|
||||
|
||||
@@ -41,6 +41,9 @@ document.addEventListener("alpine:init", () => {
|
||||
await this.loadComments();
|
||||
if (this.isOwner) {
|
||||
await this.loadOwnerReplies();
|
||||
// Notify webmentions.js that owner state + replies are ready
|
||||
// (alpine:initialized fires before these async fetches resolve)
|
||||
document.dispatchEvent(new CustomEvent("owner:detected"));
|
||||
}
|
||||
this.handleAuthReturn();
|
||||
},
|
||||
@@ -79,6 +82,9 @@ document.addEventListener("alpine:init", () => {
|
||||
Alpine.store("owner").isOwner = true;
|
||||
Alpine.store("owner").profile = this.ownerProfile;
|
||||
Alpine.store("owner").syndicationTargets = this.syndicationTargets;
|
||||
|
||||
// Note: owner:detected event is dispatched from init() after
|
||||
// loadOwnerReplies() completes, so replies are available in the store
|
||||
}
|
||||
}
|
||||
} catch {
|
||||
|
||||
@@ -596,8 +596,8 @@
|
||||
});
|
||||
|
||||
// Show reply buttons and wire click handlers if owner is detected
|
||||
// Wait for Alpine to initialize the store
|
||||
document.addEventListener('alpine:initialized', function() {
|
||||
// Listen for custom event dispatched by comments.js after async owner check
|
||||
document.addEventListener('owner:detected', function() {
|
||||
var ownerStore = Alpine.store && Alpine.store('owner');
|
||||
if (!ownerStore || !ownerStore.isOwner) return;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user