githubnpmshields.io

With shields.io, how to set specific version of badge?


I want to know how to set specific version in shields.io.

I'm working on README.MD in GitHub, and making my own README.md template. I want to set specific version of next-js badge, for example like below:

npm

But now I only have latest version. In shields.io, is there an option for scoping or tag? I could not find how to set version. What is the valid text for the scope of below picture? For example, I want to set 8.x.x version not 9.x.x.

enter image description here


Solution

  • Actually, the NPM (scoped) badge will inject the latest version of your npm package automatically from the NPM servers/registeries. So you just have to fill necessary data, which is scope name (if you are using one) and the package name; it will convert to something like this @somescope/some package name, and it will search through the NPM for the latest public version of it.

    But if you intend to create badges for your project dependencies (Shiels.io will make a peer connection for checking them and will update them whenever they get updated), you have to use the Platform & Version Support dependencies, which will give you the ability to inject live versions of your dependencies from the GitHub repo. So, for instance, if your package.json exists in your master repo, you can use GitHub package.json dependency version (prod); then you just need to fill your GitHub username, your desired repo, and package name in your package.json.

    So let's say I want to get my react version from React-Telegram-DK-Test repo that exist under my username. I can simply do it like below:

    enter image description here

    If, in any case, your project was in the private repo or not in GitHub at all, you just have to create your badge manually and update it whenever the dependency version gets updated. It is available in the Your badge section.

    So you can make a static version like this:

    enter image description here

    The result will be available under generated URL like this:

    badge