by cuu508 · 7y ago · 0 comments
The template: https://raw.githubusercontent.com/healthchecks/healthchecks/...
And the function for rendering the template: https://github.com/healthchecks/healthchecks/blob/master/hc/...
One funky thing there is the measurement of text width. The width of the badge depends of the width of the text you put into it. I simply measured the width of each individual alphabet letter, and use that to calculate the width of a string. It's not super accurate, but works fine in practice. It was a fun weekend project.
You can also opt to use precise text width measurements (important for Arabic, Chinese, etc.) but then you have to have the font file available on your system.