Restructure course landing page into data-driven sections

Splits the single hardcoded-feeling course template into hero,
credibility, curriculum, and repeat-CTA sections, each rendering only
when its front matter fields are set. The enroll form (and its
EEC-trigger JS) moves into a reusable partial so it can appear more
than once on a page without id collisions.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
2026-07-09 08:51:49 -04:00
parent 6afa0cdf0d
commit ca5c8862fd
3 changed files with 157 additions and 48 deletions
+48
View File
@@ -0,0 +1,48 @@
{{ $id := .id }}
{{ $page := .page }}
<form id="enroll-form-{{ $id }}" class="enroll-form">
<label for="email-{{ $id }}">Email</label>
<input type="email" id="email-{{ $id }}" name="email" required autocomplete="email" placeholder="you@example.com">
<div class="field-honeypot" aria-hidden="true">
<label for="website-{{ $id }}">Leave this field empty</label>
<input type="text" id="website-{{ $id }}" name="website" tabindex="-1" autocomplete="off">
</div>
<button type="submit" class="btn">{{ $page.Params.cta_text | default "Send me day one" }}</button>
</form>
<p id="enroll-status-{{ $id }}" role="status" class="enroll-status"></p>
<script>
(function () {
var form = document.getElementById("enroll-form-{{ $id }}");
var status = document.getElementById("enroll-status-{{ $id }}");
var slug = {{ $page.Params.eec_slug }};
form.addEventListener("submit", function (e) {
e.preventDefault();
if (form.website.value) return; // honeypot
var submitBtn = form.querySelector("button[type=submit]");
submitBtn.disabled = true;
status.textContent = "Signing you up…";
fetch("{{ $page.Site.Params.eec_base_url }}/courses/" + slug + "/enroll", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ email: form.email.value })
}).then(function (res) {
if (res.ok) {
form.reset();
form.hidden = true;
status.textContent = "Check your inbox — let us know you're ready and we'll get started.";
return;
}
return res.text().then(function (msg) {
submitBtn.disabled = false;
status.textContent = msg || "Something went wrong. Try again in a moment.";
});
}).catch(function () {
submitBtn.disabled = false;
status.textContent = "Something went wrong. Try again in a moment.";
});
});
})();
</script>