diff --git a/src/hexdoc/graphics/validators.py b/src/hexdoc/graphics/validators.py index f5a6642d..69ee336f 100644 --- a/src/hexdoc/graphics/validators.py +++ b/src/hexdoc/graphics/validators.py @@ -13,6 +13,7 @@ model_validator, ) from typing_extensions import TypeVar, override +from yarl import URL from hexdoc.core import ItemStack, Properties, ResourceLocation from hexdoc.minecraft.i18n import I18n, LocalizedStr @@ -59,6 +60,10 @@ def template(cls): def name(self): return self._name + @property + @abstractmethod + def first_url(self) -> URL: ... + @abstractmethod def _get_name(self, info: ValidationInfo) -> LocalizedStr: ... @@ -76,6 +81,11 @@ class URLImage(HexdocImage[_T_ResourceLocation], template_id="hexdoc:single"): url: PydanticURL pixelated: bool = True + @property + @override + def first_url(self): + return self.url + class TextureImage(URLImage[ResourceLocation], InlineModel): @override @@ -142,6 +152,11 @@ def _get_name(self, info: ValidationInfo): class CyclingImage(HexdocImage[_T_ResourceLocation], template_id="hexdoc:cycling"): images: list[HexdocImage] = Field(min_length=1) + @property + @override + def first_url(self): + return self.images[0].first_url + @override def _get_name(self, info: ValidationInfo): return self.images[0].name