From 3053803c26fad45de3b949d463dce9f4d12875a1 Mon Sep 17 00:00:00 2001 From: Archicratia Date: Mon, 19 Jan 2026 18:52:35 +0100 Subject: [PATCH] Proposer: href Gitea complet (fallback B), lien antifragile --- src/layouts/EditionLayout.astro | 36 ++++++++++++--------------------- 1 file changed, 13 insertions(+), 23 deletions(-) diff --git a/src/layouts/EditionLayout.astro b/src/layouts/EditionLayout.astro index d9addae..b863dfe 100644 --- a/src/layouts/EditionLayout.astro +++ b/src/layouts/EditionLayout.astro @@ -154,33 +154,23 @@ const GITEA_REPO = import.meta.env.PUBLIC_GITEA_REPO ?? ""; tools.appendChild(citeBtn); if (giteaReady) { - const propose = document.createElement("a"); - propose.className = "para-propose"; - propose.href = "#"; - propose.textContent = "Proposer"; - propose.setAttribute("aria-label", "Proposer une correction sur Gitea"); - propose.setAttribute("data-propose","1"); + const propose = document.createElement("a"); + propose.className = "para-propose"; + propose.textContent = "Proposer"; + propose.setAttribute("aria-label", "Proposer une correction sur Gitea"); + propose.setAttribute("data-propose", "1"); - propose.addEventListener("click", (e) => { - e.preventDefault(); - const raw = (p.textContent || "").trim().replace(/\s+/g, " "); - const excerpt = raw.length > 420 ? (raw.slice(0, 420) + "…") : raw; - const url = buildIssueURL(p.id, excerpt); + const raw = (p.textContent || "").trim().replace(/\s+/g, " "); + const excerpt = raw.length > 420 ? (raw.slice(0, 420) + "…") : raw; + const url = buildIssueURL(p.id, excerpt); - // on stocke l'URL pour le modal - propose.dataset.url = url.toString(); + // progressive enhancement : sans JS/modal, href fonctionne. + propose.href = url; - // fallback: si le modal n'existe pas -> ouverture directe - const dlg = document.getElementById("propose-modal"); - if (!dlg || typeof dlg.showModal !== "function") { - window.open(propose.dataset.url, "_blank", "noopener,noreferrer"); - return; - } - // si modal existe, il va intercepter le click globalement - // donc on ne fait rien ici de plus. - }); + // compat : la modal lit data-url en priorité (garde aussi href). + propose.dataset.url = url; - tools.appendChild(propose); + tools.appendChild(propose); } p.appendChild(tools);