diff --git a/README.md b/README.md --- a/README.md +++ b/README.md @@ -58,7 +58,7 @@ - The KV binding is set on the Pages project (production and preview), not in a wrangler file. - Export to CSV: `node scripts/export-subscribers.mjs > subscribers.csv` (copy on the box: `/workspace/kitbag/export-subscribers.mjs`) (token needs Workers KV Storage: Read). - Deploy from the repo root (`npx wrangler pages deploy dist --project-name thedigitalkitbag --branch main`) so the `functions/` folder is included. -- The free spreadsheet files are not built yet. When the charge-out rate check `.xlsx` exists, deliver the Excel file only (no Google Sheets make-a-copy link) with the thank-you line stored as `thankYouLine` in that version, and switch to consent version `lm-charge-out-2026-11-18`. +- Free lead magnets are static files at `/downloads/TDK-Charge-Out-Rate-Check.xlsx` and `/downloads/TDK-BAS-Quarter-Checklist.pdf`. They are noindexed with an `X-Robots-Tag` header, kept out of the sitemap and the public nav, and given on the thank-you pages after a consented sign-up. Live consent versions are `lm-charge-out-2026-11-18` and `lm-bas-checklist-2026-11-18`. There is no Google Sheets make-a-copy link, and no bundle-waitlist form. ## Deploy diff --git a/astro.config.mjs b/astro.config.mjs --- a/astro.config.mjs +++ b/astro.config.mjs @@ -1,10 +1,52 @@ // @ts-check +import fs from 'node:fs'; +import path from 'node:path'; +import { fileURLToPath } from 'node:url'; import { defineConfig } from 'astro/config'; import sitemap from '@astrojs/sitemap'; import { unified } from '@astrojs/markdown-remark'; import rehypeExternalLinks from 'rehype-external-links'; import rehypeRaw from 'rehype-raw'; +/** Thank-you pages and lead-magnet files stay live, but must not be indexed or listed in the sitemap. */ +function isUnindexedPath(page) { + try { + const pathname = new URL(page).pathname; + return ( + pathname === '/subscribed/' || + pathname.startsWith('/subscribed/') || + pathname === '/downloads/' || + pathname.startsWith('/downloads/') + ); + } catch { + return page.includes('/subscribed') || page.includes('/downloads'); + } +} + +/** lastmod is the article updatedDate if present, otherwise pubDate. */ +function loadBlogLastmods() { + const dir = fileURLToPath(new URL('./src/content/blog/', import.meta.url)); + /** @type {Map} */ + const map = new Map(); + for (const name of fs.readdirSync(dir)) { + if (!name.endsWith('.md')) continue; + const raw = fs.readFileSync(path.join(dir, name), 'utf8'); + const fm = raw.match(/^---\r?\n([\s\S]*?)\r?\n---/)?.[1] ?? ''; + const pub = fm.match(/^pubDate:\s*['"]?(\d{4}-\d{2}-\d{2})/m)?.[1]; + const upd = fm.match(/^updatedDate:\s*['"]?(\d{4}-\d{2}-\d{2})/m)?.[1]; + const date = upd || pub; + if (!date) continue; + const slug = name.replace(/\.md$/, ''); + map.set(`https://thedigitalkitbag.com/blog/${slug}/`, date); + } + return map; +} + +const blogLastmods = loadBlogLastmods(); +const latestBlogLastmod = [...blogLastmods.values()].sort().at(-1) ?? '2026-11-18'; +/** First time we emit lastmod for non-article pages; there is no per-page updated date in source. */ +const DEFAULT_LASTMOD = '2026-11-18'; + const ownHosts = new Set(['thedigitalkitbag.com', 'www.thedigitalkitbag.com']); /** Off-site http(s) links only. mailto:, relative URLs, and this site stay untouched. */ @@ -79,7 +121,14 @@ }, integrations: [ sitemap({ - filter: (page) => !page.includes('/draft'), + filter: (page) => !page.includes('/draft') && !isUnindexedPath(page), + serialize(item) { + const lastmod = + blogLastmods.get(item.url) ?? + (item.url === 'https://thedigitalkitbag.com/blog/' ? latestBlogLastmod : DEFAULT_LASTMOD); + item.lastmod = lastmod; + return item; + }, }), ], }); diff --git a/public/_headers b/public/_headers --- a/public/_headers +++ b/public/_headers @@ -29,3 +29,17 @@ /apple-touch-icon.png Cache-Control: public, max-age=86400 + +/downloads/* + X-Robots-Tag: noindex + Cache-Control: public, max-age=0, must-revalidate + +/downloads/TDK-Charge-Out-Rate-Check.xlsx + X-Robots-Tag: noindex + Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet + Content-Disposition: attachment; filename="TDK-Charge-Out-Rate-Check.xlsx" + +/downloads/TDK-BAS-Quarter-Checklist.pdf + X-Robots-Tag: noindex + Content-Type: application/pdf + Content-Disposition: attachment; filename="TDK-BAS-Quarter-Checklist.pdf" # New binary file public/downloads/TDK-BAS-Quarter-Checklist.pdf is in fix3-handoff.tar.gz (not in this text patch) # New binary file public/downloads/TDK-Charge-Out-Rate-Check.xlsx is in fix3-handoff.tar.gz (not in this text patch) diff --git a/scripts/check-dist.mjs b/scripts/check-dist.mjs --- a/scripts/check-dist.mjs +++ b/scripts/check-dist.mjs @@ -8,6 +8,11 @@ return readFileSync(path, 'utf8'); } +function hasText(html, phrase) { + const norm = (s) => s.replace(/[\u2018\u2019\u201A\u201B]/g, "'"); + return norm(html).includes(norm(phrase)); +} + function walk(dir) { const out = []; for (const name of readdirSync(dir)) { @@ -159,6 +164,32 @@ if (sitemap.includes(slug)) throw new Error(`Draft leaked into sitemap: ${slug}`); } +const sitemap0 = read(join(dist, 'sitemap-0.xml')); +if (/https:\/\/thedigitalkitbag\.com\/subscribed\//.test(sitemap0)) { + throw new Error('Thank-you /subscribed/ pages must not appear in the sitemap'); +} +const sitemapUrls = [...sitemap0.matchAll(/([\s\S]*?)<\/url>/g)].map((m) => m[1]); +if (sitemapUrls.length === 0) throw new Error('sitemap-0.xml has no URLs'); +for (const entry of sitemapUrls) { + const loc = (entry.match(/(.*?)<\/loc>/) || [])[1]; + if (!/\d{4}-\d{2}-\d{2}(T\d{2}:\d{2}:\d{2}(?:\.\d+)?Z)?<\/lastmod>/.test(entry)) { + throw new Error(`Sitemap entry missing lastmod: ${loc || entry}`); + } +} +const expectedLastmod = { + 'https://thedigitalkitbag.com/blog/subcontractor-insurance-requirements-nsw/': '2026-11-18', + 'https://thedigitalkitbag.com/blog/tpar-building-and-construction/': '2026-11-18', + 'https://thedigitalkitbag.com/blog/bas-for-sole-traders/': '2026-11-17', + 'https://thedigitalkitbag.com/blog/how-to-calculate-your-charge-out-rate-in-australia/': '2026-11-16', +}; +for (const [url, date] of Object.entries(expectedLastmod)) { + const entry = sitemapUrls.find((block) => block.includes(`${url}`)); + if (!entry) throw new Error(`Sitemap missing ${url}`); + if (!entry.includes(`${date}`) && !entry.includes(`${date}T00:00:00.000Z`)) { + throw new Error(`Sitemap lastmod for ${url} should be ${date}`); + } +} + const calculator = read(join(dist, 'tools/rate-calculator/index.html')); if (!calculator.includes('action="/api/subscribe"')) { throw new Error('Signup form should post to /api/subscribe'); @@ -169,7 +200,9 @@ if (!calculator.includes('name="tag" value="lm-charge-out"')) { throw new Error('Calculator signup should be tagged lm-charge-out'); } -if (!calculator.includes('name="consent_version"')) throw new Error('Signup form is missing the consent version'); +if (!calculator.includes('name="consent_version" value="lm-charge-out-2026-11-18"')) { + throw new Error('Calculator signup should use consent version lm-charge-out-2026-11-18'); +} if (/name="consent"[^>]*checked/i.test(calculator)) throw new Error('The opt-in box must start unticked'); if (!existsSync(join(root, 'functions/api/subscribe.ts'))) throw new Error('Pages Function /api/subscribe missing'); for (const file of htmlFiles) { @@ -186,6 +219,149 @@ 'subscribed/not-added/index.html', ]) { if (!existsSync(join(dist, page))) throw new Error(`Missing ${page}`); + const html = read(join(dist, page)); + if (!html.includes('name="robots" content="noindex"')) { + throw new Error(`Missing noindex on ${page}`); + } +} + +const sentenceCaseTitles = { + 'blog/quote-template-australia/index.html': 'Quote template Australia: what to put on a trades quote', + 'blog/subcontractor-insurance-requirements-nsw/index.html': 'Subcontractor insurance requirements NSW: what to check', + 'blog/tpar-building-and-construction/index.html': 'TPAR for building and construction: what to record', + 'blog/late-payment-fees-on-invoices/index.html': 'Late payment fees on invoices in Australia: set them right', + 'blog/is-hipages-worth-it/index.html': 'Is hipages worth it? Work out your real cost per won job', + 'blog/bas-for-sole-traders/index.html': 'BAS for sole traders: do you lodge, when, and what to save', + 'blog/tax-invoice-requirements-australia/index.html': 'Tax invoice requirements Australia: a checklist for trades', + 'blog/overdue-invoice-reminders/index.html': 'Overdue invoice reminders: what to send and when', + 'blog/subcontractor-agreement-template-australia/index.html': 'Subcontractor agreement template Australia: what to include', +}; +for (const [file, heading] of Object.entries(sentenceCaseTitles)) { + const html = read(join(dist, file)); + if (!html.includes(`${heading} | The Digital Kitbag`)) { + throw new Error(`Meta title not sentence case on ${file}`); + } + if (!html.includes(`

${heading}

`)) { + throw new Error(`H1 not sentence case on ${file}`); + } + if (!html.includes(`property="og:title" content="${heading} | The Digital Kitbag"`)) { + throw new Error(`og:title not sentence case on ${file}`); + } +} + +const nsw = read(join(dist, 'blog/subcontractor-insurance-requirements-nsw/index.html')); +if (!hasText(nsw, "An employer can be exempt only if it meets all of these: it pays $7,500 or less in wages in a financial year, it doesn't employ an apprentice or trainee, and it isn't a member of a group of related businesses.")) { + throw new Error('NSW $7,500 exemption wording missing'); +} +if (!hasText(nsw, "icare's wages manual says a director is a working director if they do work in the day-to-day running of the business and receive any form of payment. So a one-person company paying its working director may need a policy, unless it meets the exemption above.")) { + throw new Error('NSW working-director wording missing'); +} +if (!nsw.includes('https://www.icare.nsw.gov.au/workers-compensation/employers/who-needs-a-policy')) { + throw new Error('NSW who-needs-a-policy link was not updated'); +} +if (!nsw.includes('https://www.icare.nsw.gov.au/workers-compensation/employers/classifying-your-workers')) { + throw new Error('NSW classifying-your-workers link was not updated'); +} +if (nsw.includes('who-needs-workers-insurance')) { + throw new Error('NSW article still has a redirected icare URL'); +} + +const tpar = read(join(dist, 'blog/tpar-building-and-construction/index.html')); +if (!hasText(tpar, 'In a March 2026 update, it said it had issued just over $5 million in TPAR penalties in the previous year.')) { + throw new Error('TPAR penalties wording missing'); +} +if (!tpar.includes('withhold the top rate of tax')) { + throw new Error('TPAR top-rate-of-tax wording missing'); +} +if (!tpar.includes('https://www.ato.gov.au/forms-and-instructions/statement-by-supplier-not-quoting-an-abn')) { + throw new Error('TPAR 47% no-ABN link missing'); +} +if (tpar.includes('issued just over $5 million in penalties last year')) { + throw new Error('Old TPAR penalties sentence still present'); +} + +const downloads = [ + { + file: 'downloads/TDK-Charge-Out-Rate-Check.xlsx', + bytes: 21291, + typeHint: 'TDK-Charge-Out-Rate-Check.xlsx', + }, + { + file: 'downloads/TDK-BAS-Quarter-Checklist.pdf', + bytes: 267652, + typeHint: 'TDK-BAS-Quarter-Checklist.pdf', + }, +]; +for (const item of downloads) { + const path = join(dist, item.file); + if (!existsSync(path)) throw new Error(`Missing ${item.file}`); + const size = statSync(path).size; + if (size !== item.bytes) throw new Error(`${item.file} is ${size} bytes, expected ${item.bytes}`); +} +const headers = read(join(dist, '_headers')); +if (!headers.includes('/downloads/*') || !headers.includes('X-Robots-Tag: noindex')) { + throw new Error('Download files must be noindexed in _headers'); +} +if (sitemap0.includes('/downloads/')) { + throw new Error('Lead-magnet files must not appear in the sitemap'); +} + +const chargeThanks = read(join(dist, 'subscribed/charge-out-rate-check/index.html')); +if (!chargeThanks.includes('href="/downloads/TDK-Charge-Out-Rate-Check.xlsx"')) { + throw new Error('Charge-out thank-you page is missing the Excel download button'); +} +if (!chargeThanks.includes('Download the Excel file (.xlsx)')) { + throw new Error('Charge-out thank-you page is missing the download button label'); +} +if (!chargeThanks.includes('Upload it to Google Drive, open it with Google Sheets, then go to File') || !chargeThanks.includes('Locale and choose Australia')) { + throw new Error('Charge-out thank-you page is missing the Google Sheets locale line'); +} +if (!chargeThanks.includes('href="/tools/rate-calculator/"')) { + throw new Error('Charge-out thank-you page should keep a secondary link to the calculator'); +} +if (chargeThanks.includes('docs.google.com') || /make a copy/i.test(chargeThanks)) { + throw new Error('Charge-out thank-you page must not offer a Google Sheets make-a-copy link'); +} + +const basThanks = read(join(dist, 'subscribed/bas-quarter-checklist/index.html')); +if (!basThanks.includes('href="/downloads/TDK-BAS-Quarter-Checklist.pdf"')) { + throw new Error('BAS thank-you page is missing the PDF download button'); +} +if (!basThanks.includes('Download the PDF')) { + throw new Error('BAS thank-you page is missing the download button label'); +} + +const homeForm = read(join(dist, 'index.html')); +if (!homeForm.includes('Get a free charge-out rate check you can keep')) { + throw new Error('Home form is missing the Form A heading'); +} +if (!hasText(homeForm, 'an Excel file (.xlsx). Using Google Sheets?') || !hasText(homeForm, 'Locale and choose Australia')) { + throw new Error('Home form is missing the Form A Excel-only bullet'); +} +if (!homeForm.includes('name="consent_version" value="lm-charge-out-2026-11-18"')) { + throw new Error('Home form should use consent version lm-charge-out-2026-11-18'); +} + +const basProduct = read(join(dist, 'products/bas-gst-workbook/index.html')); +if (!basProduct.includes('Get the free BAS quarter checklist')) { + throw new Error('BAS product form is missing the Form B heading'); +} +if (!basProduct.includes('You get a printable PDF.')) { + throw new Error('BAS product form is missing the Form B PDF bullet'); +} +if (!basProduct.includes('name="tag" value="lm-bas-checklist"')) { + throw new Error('BAS product form should be tagged lm-bas-checklist'); +} +if (!basProduct.includes('name="consent_version" value="lm-bas-checklist-2026-11-18"')) { + throw new Error('BAS product form should use consent version lm-bas-checklist-2026-11-18'); +} +if (basProduct.includes('bundle-waitlist') || homeForm.includes('bundle-waitlist')) { + throw new Error('No bundle-waitlist form should be on the site'); +} + +const navSources = ['index.html', 'about/index.html', 'products/index.html'].map((file) => read(join(dist, file))).join('\n'); +if (navSources.includes('href="/downloads/')) { + throw new Error('Lead-magnet files must not be linked from public nav or home/about/product index'); } // Articles show the disclaimer exactly once. diff --git a/src/components/SignupForm.astro b/src/components/SignupForm.astro --- a/src/components/SignupForm.astro +++ b/src/components/SignupForm.astro @@ -6,6 +6,7 @@ id?: string; /** Overrides the heading stored with the consent version. */ heading?: string; + /** Extra line under the official subhead, if a placement needs one. */ text?: string; /** Source tag. Decides the consent wording and the thank-you page. */ tag?: LiveTag; @@ -28,6 +29,16 @@ diff --git a/src/styles/global.css b/src/styles/global.css --- a/src/styles/global.css +++ b/src/styles/global.css @@ -526,6 +526,13 @@ gap: 0.7rem; } +.signup-points { + margin: 0; + padding-left: 1.2rem; + display: grid; + gap: 0.35rem; +} + .signup form, .calc form { display: grid;