diff --git a/backend/src/piece-page.mjs b/backend/src/piece-page.mjs
index bc8ffbe..780d623 100644
--- a/backend/src/piece-page.mjs
+++ b/backend/src/piece-page.mjs
@@ -5,6 +5,7 @@
// styles and scripts of every page): the piece replaces [[piece]] in , its title replaces the
// shell's, and its head tags go before . Without a shell it is a plain page that search
// engines are asked not to list, so a passing failure is never what they keep.
+import { labelDollars } from "./shipping.mjs";
const SITE_NAME = "Updraft Pottery Studio";
const esc = (s = "") => String(s).replace(/[&<>"]/g, (c) => ({ "&": "&", "<": "<", ">": ">", '"': """ })[c]);
@@ -78,12 +79,49 @@ function picture(url, { alt, sizes, widths, eager }) {
);
}
+/** OfferShippingDetails for one parcel of billed weight shipLb (WA state + US ceiling), or null when unpriced. */
+function shippingDetailsFor(shipLb) {
+ if (!(shipLb > 0)) return null;
+ const maxForZone = (zone) => {
+ const ups = labelDollars("ups", zone, shipLb);
+ if (ups === null) return null;
+ return Math.ceil(Math.max(ups, labelDollars("usps", zone, shipLb) ?? 0));
+ };
+ const wa = maxForZone(3);
+ const us = maxForZone(8);
+ if (wa === null || us === null) return null;
+ const handlingTime = { "@type": "QuantitativeValue", minValue: 1, maxValue: 2, unitCode: "DAY" };
+ return [
+ {
+ "@type": "OfferShippingDetails",
+ shippingRate: { "@type": "MonetaryAmount", value: wa.toFixed(2), currency: "USD" },
+ shippingDestination: { "@type": "DefinedRegion", addressCountry: "US", addressRegion: "WA" },
+ deliveryTime: {
+ "@type": "ShippingDeliveryTime",
+ handlingTime,
+ transitTime: { "@type": "QuantitativeValue", minValue: 1, maxValue: 3, unitCode: "DAY" },
+ },
+ },
+ {
+ "@type": "OfferShippingDetails",
+ shippingRate: { "@type": "MonetaryAmount", value: us.toFixed(2), currency: "USD" },
+ shippingDestination: { "@type": "DefinedRegion", addressCountry: "US" },
+ deliveryTime: {
+ "@type": "ShippingDeliveryTime",
+ handlingTime,
+ transitTime: { "@type": "QuantitativeValue", minValue: 1, maxValue: 6, unitCode: "DAY" },
+ },
+ },
+ ];
+}
+
/** schema.org data: the Product with an Offer per option, and where it sits in the shop. */
export function structuredData(item, site) {
const url = `${site}/p/${item.id}`;
const many = item.variations.length > 1;
const delivery =
item.shipLb > 0 ? ["https://schema.org/OnSitePickup", "https://schema.org/ParcelService"] : ["https://schema.org/OnSitePickup"];
+ const shippingDetails = shippingDetailsFor(item.shipLb);
const crumbs = [
{ name: "Home", item: `${site}/` },
{ name: "Shop", item: `${site}/shop.html` },
@@ -123,6 +161,7 @@ export function structuredData(item, site) {
applicableCountry: "US",
returnPolicyCategory: "https://schema.org/MerchantReturnNotPermitted",
},
+ ...(shippingDetails ? { shippingDetails } : {}),
})),
},
{
diff --git a/backend/test/shop-pages.test.mjs b/backend/test/shop-pages.test.mjs
index c47f907..f477e53 100644
--- a/backend/test/shop-pages.test.mjs
+++ b/backend/test/shop-pages.test.mjs
@@ -193,6 +193,19 @@ test("a piece's page has its name, price, photos, words and product data, and no
assert.equal(product.offers[0].price, "65.00");
assert.equal(product.offers[0].availability, "https://schema.org/InStock");
assert.deepEqual(product.offers[0].availableDeliveryMethod, ["https://schema.org/OnSitePickup", "https://schema.org/ParcelService"]);
+ assert.deepEqual(
+ product.offers[0].shippingDetails.map((s) => [s.shippingDestination.addressRegion ?? "US", s.shippingRate.value]),
+ [
+ ["WA", "33.00"],
+ ["US", "52.00"],
+ ],
+ );
+ assert.equal(
+ structuredData({ id: "P", name: "Pot", variations: [{ id: "V", name: "R", price: 1000, stock: 1 }] }, "")["@graph"][0].offers[0]
+ .shippingDetails,
+ undefined,
+ "pickup-only or unweighted items omit parcel shippingDetails",
+ );
assert.equal(product.image.length, 2);
assert.deepEqual(
crumbs.itemListElement.map((c) => c.name),
diff --git a/e2e/home.spec.mjs b/e2e/home.spec.mjs
index b46260d..44d1516 100644
--- a/e2e/home.spec.mjs
+++ b/e2e/home.spec.mjs
@@ -64,8 +64,18 @@ test("the page runs in the planned order, with the full story on the About page"
els.map((e) => e.id || e.className.split(" ").find((c) => ["hero", "studio", "signup", "trust"].includes(c)) || e.tagName),
);
expect(order).toEqual(["hero", "available", "about", "work", "signup", "trust"]);
- await expect(page.locator(".studio").getByRole("link", { name: "Read the full story →" })).toHaveAttribute("href", "/about.html");
- await expect(page.locator(".studio").getByRole("link", { name: "See the kilns →" })).toHaveAttribute("href", "/kilns.html");
+ await expect(page.locator(".studio").getByRole("link", { name: "More about Aaron and the studio →" })).toHaveAttribute(
+ "href",
+ "/about.html",
+ );
+ await expect(page.locator(".studio").getByRole("link", { name: "See the soda and propane kilns →" })).toHaveAttribute(
+ "href",
+ "/kilns.html",
+ );
+ await expect(page.locator("#work").getByRole("link", { name: "See earlier pottery in the archive →" })).toHaveAttribute(
+ "href",
+ "/past-work.html",
+ );
await expect(page.locator(".trust")).toContainText("Orders ship in 1–2 business days.");
await page.goto("/about.html");
await expect(page.locator("h1")).toHaveText("About the studio");
diff --git a/e2e/piece-page.spec.mjs b/e2e/piece-page.spec.mjs
index 015b4ec..a6ed837 100644
--- a/e2e/piece-page.spec.mjs
+++ b/e2e/piece-page.spec.mjs
@@ -33,6 +33,7 @@ test("a piece's page has its name, price, product data and its own address", asy
"65.00",
14,
]);
+ expect(product.offers[0].shippingDetails.map((s) => s.shippingRate.value)).toEqual(["33.00", "52.00"]);
await expect(page.locator(".crumbs li")).toHaveText(["Home", "Shop", "Bowls", "Celadon footed bowl"]);
expect(crumbs.itemListElement.map((c) => c.name)).toEqual(["Home", "Shop", "Bowls", "Celadon footed bowl"]);
// Other pieces still for sale, each by its own page; the sold jar isn't among them.
diff --git a/e2e/seo.spec.mjs b/e2e/seo.spec.mjs
index dcca997..1437247 100644
--- a/e2e/seo.spec.mjs
+++ b/e2e/seo.spec.mjs
@@ -22,6 +22,7 @@ for (const [path, type, crumbs] of expectedTypes) {
expect(schema["@graph"][0]["@type"]).toBe(type);
if (!crumbs) {
await expect(page.locator("nav.crumbs")).toHaveCount(0);
+ expect(schema["@graph"][0].areaServed.map((a) => a.name)).toContain("Tacoma");
} else {
await expect(page.locator("nav.crumbs li")).toHaveText(crumbs);
await expect(page.locator("nav.crumbs [aria-current='page']")).toHaveText(crumbs.at(-1));
diff --git a/scripts/build.mjs b/scripts/build.mjs
index 42796ff..ada8363 100644
--- a/scripts/build.mjs
+++ b/scripts/build.mjs
@@ -436,7 +436,12 @@ function pageSchema(name, html, { ogs, icon512, email, meta, archive, terms }) {
...(email ? { email } : {}),
founder: { "@type": "Person", "@id": personId, name: "Aaron Filson", url: pageUrl("about.html") },
address: { "@type": "PostalAddress", addressLocality: "Tacoma", addressRegion: "WA", addressCountry: "US" },
- areaServed: { "@type": "Country", name: "US" },
+ areaServed: [
+ { "@type": "City", name: "Tacoma", containedInPlace: { "@type": "State", name: "Washington" } },
+ { "@type": "AdministrativeArea", name: "Pierce County, WA" },
+ { "@type": "Place", name: "Seattle-Tacoma metropolitan area" },
+ { "@type": "Country", name: "US" },
+ ],
sameAs: SAME_AS,
hasMerchantReturnPolicy: {
"@type": "MerchantReturnPolicy",
diff --git a/site/css/style.css b/site/css/style.css
index 36d66fb..2689ce1 100644
--- a/site/css/style.css
+++ b/site/css/style.css
@@ -124,7 +124,7 @@ section { padding-block: clamp(2.5rem, 7vw, 5rem); }
.chip { font: inherit; font-size: .95rem; min-height: 44px; padding: .4rem 1rem; border-radius: 99px; border: 1.5px solid var(--control); background: var(--surface); color: var(--ink); cursor: pointer; }
.chip[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.card-body { padding: 1rem 1.1rem 1.2rem; display: flex; flex-direction: column; gap: .5rem; flex: 1; }
-.card-body h3 { font-size: 1.25rem; margin: 0 0 .3em; }
+.card-body :is(h3, .ph-title) { font-size: 1.25rem; line-height: 1.15; margin: 0 0 .3em; }
.card-body p { margin: 0; color: var(--muted); font-size: .95rem; }
.price { font-weight: 600; }
.product-strip { grid-template-columns: repeat(auto-fill, minmax(min(100%, 200px), 1fr)); }
@@ -135,7 +135,7 @@ section { padding-block: clamp(2.5rem, 7vw, 5rem); }
@media (max-width: 599px) {
:is(.products, .product-strip) { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .75rem; }
:is(.products, .product-strip) .card-body { padding: .7rem .75rem .85rem; }
- :is(.products, .product-strip) .card-body h3 { font-size: 1.05rem; }
+ :is(.products, .product-strip) .card-body :is(h3, .ph-title) { font-size: 1.05rem; }
.products .row { flex-direction: column; align-items: stretch; gap: .4rem; }
.products .row .btn { padding-inline: .5rem; }
}
diff --git a/site/index.html b/site/index.html
index f6b85da..6b38186 100644
--- a/site/index.html
+++ b/site/index.html
@@ -30,10 +30,10 @@ Pottery shaped by hand,
fired in Tacoma.
@@ -49,7 +49,7 @@ Meet the potter
I'm Aaron Filson. I discovered pottery in my last semester at the University of Puget Sound, drawn in by the
wheel and the tangible results. Updraft Pottery Studio is my studio in Tacoma.
- Read the full story →
+ More about Aaron and the studio →
@@ -72,7 +72,7 @@ Kiln projects
diff --git a/site/js/test/seo.test.mjs b/site/js/test/seo.test.mjs
index ddb72c2..7f3ab40 100644
--- a/site/js/test/seo.test.mjs
+++ b/site/js/test/seo.test.mjs
@@ -13,6 +13,15 @@ test("every indexable page has one h1, a title <= 60 chars, and a 70-160 char de
const desc = (html.match(/`);
+ for (const [tag, , inner] of html.matchAll(/]*)?>([\s\S]*?)<\/h\1>/g)) {
+ const text = inner
+ .split("<")
+ .map((part, i) => (i === 0 ? part : part.slice(part.indexOf(">") + 1)))
+ .join("")
+ .replaceAll(" ", "")
+ .trim();
+ assert.ok(text.length > 0, `${name}: empty heading ${tag}`);
+ }
assert.ok(title.length >= 20 && title.length <= 60, `${name}: title length ${title.length} ("${title}")`);
assert.ok(desc.length >= 70 && desc.length <= 160, `${name}: description length ${desc.length}`);
if (name !== "index.html") assert.ok(html.includes(""), `${name}: missing placeholder`);
diff --git a/site/partials/footer.html b/site/partials/footer.html
index 9d4e4b5..9ec0d16 100644
--- a/site/partials/footer.html
+++ b/site/partials/footer.html
@@ -4,6 +4,10 @@
Updraft Pottery Studio · Tacoma, WA{{contactLine}}