Repository navigation
6.3.0
Feature release for moxon API: a new endpoint, GET /v6/badge, draws a customizable pill badge as an SVG image, ready to be dropped in a README or a web page with a plain <img>. Nothing else changes: the other endpoints, v4 and v5 behave exactly as in 6.2.0.
Badge
GET /v6/badge?label={text}— only the label is required. The response is a standaloneimage/svg+xmlpicture with a rounded gradient background, an optional icon before the label and another after it, and it is sent withCache-Control: public, max-age=86400and aContent-Security-Policy: default-src 'none'header. Onv4andv5it answers the usual404(Endpoint not available in v4.).- Colors —
startandendset the gradient (#2d333bby default,enddefaults tostart),inkthe text and icon color (#ffffff), andborderadds a 1 px outline. Colors are hex values with or without the#, in theff6600orf60form. - Icons —
iconandtrailpick one of 105 bundled Lucide icons, such asrocket,tag,github,shield-checkorarrow-right, plus a filleddiscordlogo. An unknown name is refused withUnknown icon "name". - Two parts — add a
messageto get a two-part badge like the ones of shields.io: the label on the left withstart,endandink, the message on the right withmessageStart(#0969da),messageEndandmessageInk. The title and the accessible name readlabel: message. - Shape —
sizeisxs,sm(default),mdorlg, from16to28px tall.radiusgoes from0for square corners up to the full pill, which is the default, andangle(0to360, the CSS convention:90runs left to right,180top to bottom,135is the default corner-to-corner gradient) turns the gradient.lift(0to10) adds transparent space under the badge, to sit it higher next to text withalign="absmiddle". - Font —
fontissans(default),seriformono, andweightisbold(default) ornormal. The text is measured with the metrics of DejaVu and the badge is drawn with the first matching font installed on the viewer's system, so another family only changes the letter spacing slightly. - Limits and errors — a label or a message holds at most
64characters. Control, invisible and bidirectional characters are refused, accents are composed, and runs of spaces collapse into one.lift,radiusandangletake a plain decimal number with at most two decimals (0x5,1e1or an empty value are refused). Every invalid value answers400with a message that names it, such asInvalid size (use xs, sm, md or lg).
Package
- Icons and licences — the bundled icons come from Lucide 0.562.0 (ISC licence, with portions under the MIT licence of Feather), and their notices are kept in the source. The width tables used to measure the text are plain numeric metrics read from DejaVu.
badgeexport — the function behind the route is also exported from@moxon/apiand@moxon/api/v6. It takes an options object (labeland the parameters above, withlift,radiusandangleas numbers) and returns{ contentType, body }, or throws anErrorwith the message of the400.@moxon/api/v4and@moxon/api/v5do not have it.