diff --git a/functions/go/[code].ts b/functions/go/[code].ts index 0205fa4..c5091e7 100644 --- a/functions/go/[code].ts +++ b/functions/go/[code].ts @@ -8,10 +8,12 @@ * Destination = canonical listing URL from src/config.ts + ref=site- and UTM tags. * page is sanitised to [a-z0-9-], max 80 chars; missing or invalid → "direct". * coupon is passed through only when it is BFCM15 or PARTNER20; anything else is dropped. + * During Fri 27 Nov 00:00–Mon 30 Nov 23:59 AEDT, BFCM15 is added if no coupon was given. * noindex, no-store (the destination depends on page), and not in the sitemap. * Nothing is stored. No KV, no PII. */ import { listingDestination, sanitiseCoupon, shopDestination, type EtsyCode } from '../../src/config'; +import { couponForHop } from '../../src/lib/bfcm-window'; type Ctx = { request: Request; params: { code?: string | string[] } }; @@ -65,7 +67,7 @@ export const onRequestGet = async ({ request, params }: Ctx): Promise const raw = Array.isArray(params.code) ? params.code[0] : params.code; const url = new URL(request.url); const pageSlug = sanitisePage(url.searchParams.get('page')); - const coupon = sanitiseCoupon(url.searchParams.get('coupon')); + const coupon = couponForHop(sanitiseCoupon(url.searchParams.get('coupon'))); let dest: string; let kind: 'listing' | 'shop' = 'listing'; if ((raw ?? '') === 'etsy-shop') { diff --git a/package.json b/package.json index b9f09cf..45b593c 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,7 @@ "dev": "astro dev --port 4391 --host 127.0.0.1", "build": "astro build", "preview": "astro preview --port 4392 --host 127.0.0.1", - "test": "node --experimental-strip-types scripts/test-rate.ts && node --experimental-strip-types scripts/test-tagged-links.ts && node --experimental-strip-types scripts/test-go.ts", + "test": "node --experimental-strip-types scripts/test-rate.ts && node --experimental-strip-types scripts/test-tagged-links.ts && node --experimental-strip-types scripts/test-go.ts && node --experimental-strip-types scripts/test-bfcm-window.ts", "check:dist": "node scripts/check-dist.mjs", "astro": "astro" }, diff --git a/public/bfcm-window.js b/public/bfcm-window.js new file mode 100644 index 0000000..5dcbb32 --- /dev/null +++ b/public/bfcm-window.js @@ -0,0 +1,25 @@ +/** + * Shows the BFCM15 bar and the lines under buy buttons only during + * Fri 27 Nov 2026 00:00 to Mon 30 Nov 2026 23:59:59.999, Australia/Sydney. + * Banner markup is hidden by default so it stays off if this file does not run. + * Keep the ISO bounds in sync with src/lib/bfcm-window.ts. + */ +(function () { + function apply() { + var start = Date.parse('2026-11-27T00:00:00+11:00'); + var end = Date.parse('2026-11-30T23:59:59.999+11:00'); + var now = Date.now(); + var on = now >= start && now <= end; + document.documentElement.classList.toggle('bfcm-on', on); + var nodes = document.querySelectorAll('[data-bfcm-window]'); + for (var i = 0; i < nodes.length; i++) { + if (on) nodes[i].removeAttribute('hidden'); + else nodes[i].setAttribute('hidden', ''); + } + } + if (document.readyState === 'loading') { + document.addEventListener('DOMContentLoaded', apply); + } else { + apply(); + } +})(); diff --git a/scripts/check-dist.mjs b/scripts/check-dist.mjs index bf07c00..d978c41 100644 --- a/scripts/check-dist.mjs +++ b/scripts/check-dist.mjs @@ -658,7 +658,7 @@ const firstBuyPrices = { 'products/bas-gst-workbook/index.html': 'A$48.99 incl. GST', 'products/getting-paid-kit/index.html': 'A$29 incl. GST', 'products/subcontractor-compliance-pack/index.html': 'A$99 incl. GST', - 'products/full-kitbag-bundle/index.html': 'A$179 incl. GST', + 'products/full-kitbag-bundle/index.html': 'A$179.00 incl. GST, save A$36.99', }; for (const [file, price] of Object.entries(firstBuyPrices)) { const html = read(join(dist, file)); @@ -671,9 +671,18 @@ for (const [file, price] of Object.entries(firstBuyPrices)) { } } const home = read(join(dist, 'index.html')); -if (!home.includes('href="#tools"') || !home.includes('See the tools')) { +if (!home.includes('href="#tools"') || !home.includes('See the tools — from A$29 incl. GST')) { throw new Error('Homepage should keep a clear See the tools path to #tools'); } +if (!home.includes('Buy on Etsy — A$39 incl. GST')) { + throw new Error('Homepage kit cards should use priced Buy on Etsy buttons'); +} +if (!home.includes('Buy on Etsy — A$179.00 incl. GST, save A$36.99')) { + throw new Error('Homepage P05 button should use A$179.00 and save A$36.99'); +} +if (!home.includes('The Digital Kitbag is an Australian business.')) { + throw new Error('Homepage kit intro should say The Digital Kitbag is an Australian business'); +} for (const slug of [ 'charge-out-rate-calculator', 'bas-gst-workbook', @@ -688,3 +697,61 @@ for (const slug of [ if (!home.includes('p04-hero-card.webp')) { throw new Error('Homepage should show a preview card for the Subcontractor Compliance Pack (P04)'); } + +// --- fix13: BFCM window, shop hops, refund line --- +for (const page of ['header', 'menu', 'footer']) { + if (!home.includes(`/go/etsy-shop/?page=${page}`)) { + throw new Error(`Shop on Etsy should hop through /go/etsy-shop/?page=${page}`); + } +} +if (!home.includes('data-bfcm-window') || !home.includes('Black Friday: 15% off everything with code BFCM15 at Etsy checkout. Fri 27 – Mon 30 Nov.')) { + throw new Error('Homepage should include the gated BFCM15 bar copy, hidden by default'); +} +if (!home.includes('src="/bfcm-window.js"')) { + throw new Error('Homepage should load /bfcm-window.js to gate the BFCM15 bar'); +} +if (/\/go\/etsy-[^"']*coupon=/.test(home)) { + throw new Error('Static /go/ hrefs must not bake in a coupon; the Function adds BFCM15 in-window'); +} +const p05 = read(join(dist, 'products/full-kitbag-bundle/index.html')); +if (!p05.includes('A$215.99 separately / save A$36.99')) { + throw new Error('P05 sidebar should keep A$215.99 separately / save A$36.99'); +} +if (!p05.includes('Prefer to start with a free charge-out rate check?')) { + throw new Error('P05 should offer the existing charge-out form under the buy panel'); +} +for (const file of [ + 'products/getting-paid-kit/index.html', + 'products/subcontractor-compliance-pack/index.html', +]) { + const html = read(join(dist, file)); + if (!html.includes('Prefer to start with a free charge-out rate check?')) { + throw new Error(`${file} should move the form under Prefer to start with a free charge-out rate check?`); + } +} +for (const file of [ + 'products/charge-out-rate-calculator/index.html', + 'products/bas-gst-workbook/index.html', + 'products/getting-paid-kit/index.html', + 'products/subcontractor-compliance-pack/index.html', + 'products/full-kitbag-bundle/index.html', +]) { + const html = read(join(dist, file)); + if (!html.includes('Instant download on Etsy.') || !html.includes('href="/refund-policy/"')) { + throw new Error(`${file} should include the refund / Australian Consumer Law line under the buy buttons`); + } + if (!html.includes('The Digital Kitbag is an Australian business.')) { + throw new Error(`${file} should include the Australian business line`); + } +} +const p02 = read(join(dist, 'products/bas-gst-workbook/index.html')); +if (!p02.includes('A registered tax agent has reviewed the template. That review is of the file. It is not tax advice about your business.')) { + throw new Error('P02 should keep the existing tax-agent review wording near the price'); +} +const p04 = read(join(dist, 'products/subcontractor-compliance-pack/index.html')); +if (!p04.includes('A lawyer has reviewed the template. That review is of the file. It is not legal advice about your job.')) { + throw new Error('P04 should keep the existing lawyer review wording near the price'); +} +if (/\bToby\b/.test(home + p05 + p02 + p04)) { + throw new Error('Visible fix13 pages must not use Toby’s name'); +} diff --git a/scripts/test-bfcm-window.ts b/scripts/test-bfcm-window.ts new file mode 100644 index 0000000..3122e66 --- /dev/null +++ b/scripts/test-bfcm-window.ts @@ -0,0 +1,26 @@ +import assert from 'node:assert/strict'; +import { BFCM_COUPON, BFCM_END, BFCM_START, couponForHop, isBfcmWindow } from '../src/lib/bfcm-window.ts'; + +const before = Date.parse('2026-11-26T23:59:59.999+11:00'); +const start = Date.parse(BFCM_START); +const mid = Date.parse('2026-11-28T12:00:00+11:00'); +const end = Date.parse(BFCM_END); +const after = Date.parse('2026-12-01T00:00:00+11:00'); + +assert.equal(isBfcmWindow(before), false); +assert.equal(isBfcmWindow(start), true); +assert.equal(isBfcmWindow(mid), true); +assert.equal(isBfcmWindow(end), true); +assert.equal(isBfcmWindow(after), false); + +assert.equal(couponForHop(null, before), null); +assert.equal(couponForHop(null, start), BFCM_COUPON); +assert.equal(couponForHop(null, mid), BFCM_COUPON); +assert.equal(couponForHop(null, end), BFCM_COUPON); +assert.equal(couponForHop(null, after), null); + +// Explicit allowlisted coupons still pass through outside the window. +assert.equal(couponForHop('BFCM15', before), 'BFCM15'); +assert.equal(couponForHop('PARTNER20', mid), 'PARTNER20'); + +console.log('bfcm window checks passed'); diff --git a/scripts/test-tagged-links.ts b/scripts/test-tagged-links.ts index 0b09723..fc2b4f1 100644 --- a/scripts/test-tagged-links.ts +++ b/scripts/test-tagged-links.ts @@ -27,7 +27,7 @@ assert.equal(taggedDestination('a'.repeat(41)), null); // Query strings on the request are not part of the code and cannot retarget it. assert.equal(taggedDestination('ig-bio?dest=https://evil.example'), null); -assert.equal(Object.keys(taggedRoutes).length, 263); +assert.equal(Object.keys(taggedRoutes).length, 274); for (const [code, dest] of Object.entries(taggedRoutes)) { assert.match(code, /^[a-z0-9-]{1,40}$/); assert.equal(isSameSitePath(dest), true, `${code} destination must be same-site`); @@ -68,6 +68,8 @@ assert.equal(taggedDestination('em-270216-bundle'), '/go/etsy-p05/?page=em-27021 assert.equal(taggedDestination('pt-your-trade-bookkeeping'), '/'); assert.equal(taggedDestination('pt-gold-coast-construction-accountants'), '/'); assert.equal(taggedDestination('pt-versace-timbers'), '/'); +assert.equal(taggedDestination('pt-lbtt'), '/'); +assert.equal(taggedDestination('pt-arboriculture-australia'), '/'); assert.equal(isSameSitePath('/free/car-logbook/'), true); assert.equal(taggedDestination('pt-master-locksmiths'), null); diff --git a/src/components/BuyNotes.astro b/src/components/BuyNotes.astro new file mode 100644 index 0000000..c2fd0fa --- /dev/null +++ b/src/components/BuyNotes.astro @@ -0,0 +1,40 @@ +--- +import { site } from '../config'; +import { BFCM_COPY } from '../lib/bfcm-window'; + +interface Props { + /** Refund and ACL line under a buy button (product pages). */ + refund?: boolean; + /** Existing reviewGate sentence only, never new wording. */ + review?: string; + /** Extra P05 caution, shown only during the BFCM15 window. */ + bundleCaution?: boolean; + /** Australian-business line from existing site wording. */ + australian?: boolean; + /** BFCM15 line under a buy button. Off when this block is only the Australian line. */ + promo?: boolean; +} + +const { refund = false, review, bundleCaution = false, australian = false, promo = true } = Astro.props; +--- + +{refund && ( +

+ Instant download on Etsy. If the file is faulty or not as described, we’ll fix, replace or refund it. Your rights under Australian Consumer Law always apply. + {' '} + Refund policy. +

+)} +{promo && } +{bundleCaution && ( + +)} +{review &&

{review}

} +{australian && ( +

+ The Digital Kitbag is an Australian business. Questions:{' '} + {site.supportEmail}. +

+)} diff --git a/src/components/Footer.astro b/src/components/Footer.astro index e23653a..f893d62 100644 --- a/src/components/Footer.astro +++ b/src/components/Footer.astro @@ -1,6 +1,6 @@ --- import ExternalLink from './ExternalLink.astro'; -import { etsy, site } from '../config'; +import { etsyShopGoHref, site } from '../config'; interface Props { /** Article pages show the disclaimer once in the body, so they hide this copy. */ @@ -27,7 +27,7 @@ const { showDisclaimer = true } = Astro.props;
  • About
  • Contact
  • - Shop on Etsy + Shop on Etsy
  • diff --git a/src/components/Header.astro b/src/components/Header.astro index c8252a2..095652f 100644 --- a/src/components/Header.astro +++ b/src/components/Header.astro @@ -1,7 +1,7 @@ --- import ExternalLink from './ExternalLink.astro'; import Logo from './Logo.astro'; -import { etsy } from '../config'; +import { etsyShopGoHref } from '../config'; const links = [ { href: '/products/', label: 'Tools' }, @@ -40,7 +40,7 @@ function current(href: string): boolean { )) }
  • - Shop on Etsy + Shop on Etsy
  • @@ -58,7 +58,7 @@ function current(href: string): boolean { )) }
  • - Shop on Etsy + Shop on Etsy
  • diff --git a/src/config.ts b/src/config.ts index af52630..cc2c6d4 100644 --- a/src/config.ts +++ b/src/config.ts @@ -52,6 +52,11 @@ export function etsyGoHref(code: EtsyCode, page: string): string { return `/go/etsy-${code}/?page=${encodeURIComponent(pageSlug(page))}`; } +/** Same-origin click-through to the Etsy shop. Coupon is added by the /go/ Function during the BFCM15 window. */ +export function etsyShopGoHref(page: string): string { + return `/go/etsy-shop/?page=${encodeURIComponent(pageSlug(page))}`; +} + export const site = { name: 'The Digital Kitbag', url: 'https://thedigitalkitbag.com', @@ -322,6 +327,17 @@ export const taggedRoutes = { 'pt-drillcut': '/', 'pt-cleveland-trade-centre': '/', 'pt-versace-timbers': '/', + 'pt-lbtt': '/', + 'pt-trouble-free': '/', + 'pt-trade-sbs': '/', + 'pt-bottrell': '/', + 'pt-g2-accounting': '/', + 'pt-equal-books': '/', + 'pt-affordbookstax': '/', + 'pt-oakridge-accounting': '/', + 'pt-master-painters-nsw': '/', + 'pt-agwa': '/', + 'pt-arboriculture-australia': '/', // Kitbag Email 'em-261127': '/go/etsy-p05/?page=em-261127&coupon=BFCM15', 'em-261127-shop': '/go/etsy-shop/?page=em-261127-shop&coupon=BFCM15', diff --git a/src/layouts/Base.astro b/src/layouts/Base.astro index 976faf6..813a20a 100644 --- a/src/layouts/Base.astro +++ b/src/layouts/Base.astro @@ -16,6 +16,7 @@ const fontCss = ` import Header from '../components/Header.astro'; import Footer from '../components/Footer.astro'; import { absoluteUrl, site, brandAssetVersion } from '../config'; +import { BFCM_COPY } from '../lib/bfcm-window'; const v = `?v=${brandAssetVersion}`; interface Props { @@ -92,10 +93,14 @@ const blocks = [organization, ...(Array.isArray(jsonLd) ? jsonLd : jsonLd ? [jso +