Skip to content

Embed each compound's calculator on its record, and link both ways - #92

Merged
fosterwei merged 1 commit into
mainfrom
feat/compound-calculator-section
Oct 12, 2026
Merged

fosterwei merged 1 commit into
mainfrom
feat/compound-calculator-section

Conversation

@fosterwei

Copy link
Copy Markdown
Owner

Every compound that has a calculator page now carries the calculator on its own record, with a link to the full page and a card in Related records. The calculator page already linked back, so the pair is joined in both directions.

Where it sits

Directly under "dosage chart: studies versus what circulates" on all 19 qualifying records. A reader who has just seen which figures were studied and which merely circulate is one scroll from working out what a vial yields.

What doses did studies use?
BPC-157 dosage chart: studies versus what circulates
BPC-157 dosage calculator          <- new, H2, in the table of contents
What side effects have been reported?

The block renders only for a record that qualifies for a calculator page, by the same rule that decides whether that page exists. Fifteen compounds get neither.

One component, not two copies

Calculators.astro gains id, heading and headingLevel props so the same component sits inside a compound page under that page's H2 with its tool heading demoted to H3. No duplicate H2, no second copy of the markup, and the arithmetic keeps exactly one implementation and one test suite.

Tests

Now cover every compound that has a calculator page: the link, the section, the output element, and the embedded script computing the known case. 55 assertions, up from 36.

Injected fault Caught
Link to the calculator page removed yes
Calculator section cut out yes
Script broken so it computes nothing yes

Worth recording: my first attempt at the section-cut fault used a regex that never matched, so the test passed because the injection had failed, not because the test worked. Redone by index. A test that passes for the wrong reason looks identical to one that works.

Gates

Content validation (59 records), registry check, 36 drafter tests, 55 calculator tests, loop gate 47/47, all eight link rules including no duplicate H2.

🤖 Generated with Claude Code

Every compound that has a calculator page now carries the calculator on
its own record too, directly under the dosage chart, with a link to the
full page and a card in Related records. The calculator page already
linked back, so the pair is now joined in both directions and neither is
an orphan.

Placement is deliberate. The outline on all 19 qualifying records puts
the calculator immediately after "dosage chart: studies versus what
circulates", so a reader who has just seen which figures were studied
and which merely circulate is one scroll from working out what a vial
yields, rather than finding the tool in a different section.

The block renders only for a record that qualifies for a calculator
page, by the same rule that decides whether that page exists: finished,
reviewed, and carrying at least two distinct published dose figures.
Fifteen compounds get neither, which is the point.

Calculators.astro gains id, heading and headingLevel props so the one
component can sit inside a compound page under that page's own H2 with
its tool heading demoted to H3, instead of producing two H2s or a copy of
the markup. The arithmetic still has exactly one implementation and one
test suite.

The tests now check every compound that has a calculator page: a link to
it, a calculator section, an output element, and the embedded script
computing the known case. 55 assertions, up from 36. Verified by
removing the link, cutting the section, and breaking the script on a
built page; each exits 1. The first attempt at the section cut used a
regex that never matched, so that fault was not exercised until the cut
was done by index. Worth recording because a test that passed only
because the injection failed would have looked identical to a test that
works.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@fosterwei
fosterwei merged commit b5e320f into main Oct 12, 2026
3 checks passed

This branch was successfully deployed

1 active deployment
Preview — d541ed8c Deployed Oct 12, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant