Zum Inhalt springen
Kitbay
Skill

Format numbers

MITAktualisiert am 11. Nov. 202655.770GitHub-Sterne

A short contributor skill in the Ghost repository that applies whenever a TSX file is edited.

Was der Skill vermittelt

A short contributor skill in the Ghost repository that applies whenever a TSX file is edited. Every number shown to users must go through the formatNumber helper from Ghost's Shade design-system utilities: member, visitor and subscriber counts, email opens, clicks and bounces, post views and link clicks, and revenue after converting cents to dollars. Percentages such as open rates use a separate percentage helper, and compact forms like 1.2M use an abbreviation helper. The skill lists what to avoid: calling toLocaleString directly, building a number formatter by hand, showing raw numbers, or inserting thousands separators with a regular expression.

Funktionen

  • Format displayed numbers with Shade's helper
  • Convert revenue from cents before formatting
  • Use percentage and abbreviation helpers
  • Avoid ad hoc number formatting