modrinth / labrinth

Our Rust-based backend utilizing the actix-web framework to serve Modrinth's API.

Home Page:https://modrinth.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Perma-link for project icons

isXander opened this issue · comments

Is your suggested enhancement related to a problem? Please describe.

Currently, the only way to get the icon for a project is

  • Requesting the route /project/{id}
  • Parsing the JSON
  • Getting the icon url from the json object
  • Requesting the icon url

This is a lot of steps, and prevents from placing icons on custom pages through stuff like markdown images and <img> tags. The only way you can do this is reference the CDN link that may change when the icon is changed.

Describe the solution you'd like

A perma-link route that returns the image directly, for example, /project/{id|slug}/icon, which will fetch the current CDN link and either redirect or return it directly.

This reduces load on the database (i think), since you are using less queries.

Describe alternatives you've considered

Dynamically fetching the CDN link through the existing project route or using the static CDN link is doable, but will need to be updated every time a project updates.

Additional context

No response