bookshop already supports this: ALLOWED_ORIGIN + CORS on POST
/arc/{code} exist specifically so a page on the brand's own domain can
call it cross-origin. There was no reason for bookshop to also render
the marketing/landing page itself — that put book copy inside a
generic, brand-agnostic Go template shared across every brand instead
of under normal editorial control like every other page on this site.
/books/neon-tan/ is now a plain Hugo page (content/books/neon-tan.md,
no longer draft-only/metadata-only — it's rendered for real via the new
layouts/books/single.html) with a small JS form
(layouts/partials/arc-redeem-form.html, mirroring the existing
course-enroll-form.html pattern) that POSTs form-encoded straight to
shop.michaelferrara.org/arc/neon-tan. bookshop's GET /arc/{code} page
rendering is no longer used for this campaign; only the POST redemption
and the download/Kindle/read/checkout endpoints still are.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
+1
-1
@@ -5,4 +5,4 @@ description: "TODO: one-line author bio/description"
|
||||
|
||||
TODO: Michael's homepage copy goes here.
|
||||
|
||||
Get a free short story: [download the reader magnet](https://shop.michaelferrara.org/arc/neon-tan).
|
||||
Get a free short story: [download the reader magnet](/books/neon-tan/).
|
||||
|
||||
@@ -2,6 +2,20 @@
|
||||
title: "Neon Tan"
|
||||
author: "Michael Ferrara"
|
||||
cover_image: "https://downloads.michaelferrara.org/neon-tan/neon_tan_cover.jpg"
|
||||
description: "The world is stranger than it looks and more meaningful than it lets on. You know this. Sign up to my mailing list and I'll send you a story about an AI, a wisecracking seagull, and a song that needs to be heard."
|
||||
draft: true
|
||||
description: "An AI's trademark silver-blue suit isn't exactly beach-town vibes, but he's determined to land his song a spot on the weekly top 40 countdown anyway. After a string of failed attempts to get noticed by the countdown's enigmatic curator DJ, he and his wisecracking seagull sidekick stumble into an open mic night just as a malware glitch hits, forcing him to trade analysis for improvisation, rallying tourists into one spontaneous singalong to discover connection was never something you could calculate."
|
||||
|
||||
# Optional italic line under the title, for handling an objection up front.
|
||||
hero_subhead: "A free short story, plus occasional emails when something new comes out."
|
||||
|
||||
# Label on the signup form's submit button.
|
||||
cta_text: "Send me the story"
|
||||
|
||||
# Code of the bookshop ARC campaign this form redeems (see
|
||||
# reground-tools/arc-campaign.sh) — shop.michaelferrara.org/arc/<arc_code>.
|
||||
arc_code: "neon-tan"
|
||||
---
|
||||
The world is stranger than it looks and more meaningful than it lets on.
|
||||
|
||||
You know this.
|
||||
|
||||
Sign up to my mailing list and I'll send you a story about an AI, a wisecracking seagull, and a song that needs to be heard.
|
||||
|
||||
@@ -13,6 +13,7 @@ disableKinds = ["taxonomy", "term"]
|
||||
description = "TODO: one-line author bio/description"
|
||||
author = "Michael Ferrara"
|
||||
eec_base_url = "https://eec.michaelferrara.org"
|
||||
bookshop_base_url = "https://shop.michaelferrara.org"
|
||||
|
||||
[[menu.footer]]
|
||||
name = "Contact"
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
{{ define "main" }}
|
||||
<section class="book-hero">
|
||||
<h1>{{ .Title }}</h1>
|
||||
{{ with .Params.cover_image }}<img class="book-cover" src="{{ . }}" alt="{{ $.Title }} cover">{{ end }}
|
||||
{{ with .Params.hero_subhead }}<p class="book-subhead">{{ . }}</p>{{ end }}
|
||||
|
||||
{{ .Content }}
|
||||
|
||||
{{ partial "arc-redeem-form.html" (dict "id" "top" "page" .) }}
|
||||
</section>
|
||||
{{ end }}
|
||||
@@ -0,0 +1,61 @@
|
||||
{{ $id := .id }}
|
||||
{{ $page := .page }}
|
||||
<form id="arc-form-{{ $id }}" class="enroll-form">
|
||||
<label for="arc-email-{{ $id }}">Email</label>
|
||||
<input type="email" id="arc-email-{{ $id }}" name="email" required autocomplete="email" placeholder="you@example.com">
|
||||
|
||||
<div class="field-honeypot" aria-hidden="true">
|
||||
<label for="arc-website-{{ $id }}">Leave this field empty</label>
|
||||
<input type="text" id="arc-website-{{ $id }}" name="website" tabindex="-1" autocomplete="off">
|
||||
</div>
|
||||
|
||||
<p class="field-subscribe">
|
||||
<label><input type="checkbox" id="arc-subscribe-{{ $id }}" name="subscribe" value="1"> Keep me posted on new releases and giveaways</label>
|
||||
</p>
|
||||
|
||||
<button type="submit" class="btn">{{ $page.Params.cta_text | default "Send me the story" }}</button>
|
||||
</form>
|
||||
<p id="arc-status-{{ $id }}" role="status" class="enroll-status"></p>
|
||||
|
||||
<script>
|
||||
(function () {
|
||||
var form = document.getElementById("arc-form-{{ $id }}");
|
||||
var status = document.getElementById("arc-status-{{ $id }}");
|
||||
var arcURL = {{ $page.Site.Params.bookshop_base_url }} + "/arc/" + {{ $page.Params.arc_code }};
|
||||
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 = "Sending…";
|
||||
var body = new URLSearchParams();
|
||||
body.set("email", form.email.value);
|
||||
if (form.subscribe.checked) body.set("subscribe", "1");
|
||||
fetch(arcURL, {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/x-www-form-urlencoded" },
|
||||
body: body.toString()
|
||||
}).then(function (res) {
|
||||
if (res.ok) {
|
||||
form.reset();
|
||||
form.hidden = true;
|
||||
status.textContent = "Check your email — it's on its way.";
|
||||
return;
|
||||
}
|
||||
submitBtn.disabled = false;
|
||||
if (res.status === 400) {
|
||||
status.textContent = "That doesn't look like a valid email address.";
|
||||
} else if (res.status === 429) {
|
||||
status.textContent = "Too many attempts — try again in a minute.";
|
||||
} else if (res.status === 410) {
|
||||
status.textContent = "This giveaway has ended.";
|
||||
} else {
|
||||
status.textContent = "Something went wrong. Try again in a moment.";
|
||||
}
|
||||
}).catch(function () {
|
||||
submitBtn.disabled = false;
|
||||
status.textContent = "Something went wrong. Try again in a moment.";
|
||||
});
|
||||
});
|
||||
})();
|
||||
</script>
|
||||
Reference in New Issue
Block a user