A Snippet to Display Your Universe Package Version in a Badge

We often see various badges displaying different project statuses. If you’ve published your package on Typst Universe, you might want to showcase a nice badge in your project’s README that displays your package version. The following code snippet can help you achieve this:

<a href="https://typst.app/universe/package/{package-name}">
    <img src="https://img.shields.io/badge/dynamic/xml?url=https%3A%2F%2Ftypst.app%2Funiverse%2Fpackage%2F{package-name}&query=%2Fhtml%2Fbody%2Fdiv%2Fmain%2Fdiv%5B2%5D%2Faside%2Fsection%5B2%5D%2Fdl%2Fdd%5B3%5D&logo=typst&label=Universe&color=%23239DAE" />
</a>

Usage is straightforward:

  1. Copy the code above
  2. Replace {package-name} with your package name (note that it needs to be replaced in two places)
  3. Insert the modified code into your README.md file

For example, as my latest developing package name is “rexllent”, the final result will look like this:

Now you can add such a badge to your GitHub README too!

6 Likes

It works but I don’t see the Typst logo rendered in the badge :thinking:

   pigmentpedia icon

Testing w/ GitHub logo:

Thanks for sharing!

I’ve been using this for ages:

Typst Package

  • It displays a little Typst logo
  • When clicked it links to the newest Universe page of the package.
  • But here’s the trick: It retrieves the version from the GitHub repository by reading the typst.toml. Notably, I’m not using the main branch anymore like I used to but always the newest release tag. Although I need to update the number every release it has the advantage that in the universe, it always shows the right version in the readme. Otherwise, the readmes of older versions all show the same (new) version in the badge.

EDIT interestingly, the Logo disappears in this Forum. It is still visible in the preview while I edit the post but no longer when it’s posted. I guess that is the same that happened to your posts before …

This probably has to do with the way the forum processes images and other data. The original link is replaced with a local copy of that image, and as a result, it’s unable to be dynamically updated; which explains why I didn’t see the version updated from 0.3.0 to 0.3.1 for my package.

This is what I see when I go to edit my post:

<img src="upload://zzbPSemw7JE6uGSjq55k6WLEag9.svg">

and the system message at the time shows

downloaded local copies of images

Still not sure why the Typst logo wasn’t included :thinking:

None of them shows anything

yes but only here on the forum, it seems. On GitHub and the Typst Universe they work just fine.

1 Like