From 12d92285020574a4eebd622be7d86ee5f383a7ad Mon Sep 17 00:00:00 2001 From: DrMint <29893320+DrMint@users.noreply.github.com> Date: Tue, 11 Jun 2024 21:53:53 +0200 Subject: [PATCH] Add support for other attribute types in generic previews --- src/components/Previews/GenericPreview.astro | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/src/components/Previews/GenericPreview.astro b/src/components/Previews/GenericPreview.astro index 7ae7aa8..682b486 100644 --- a/src/components/Previews/GenericPreview.astro +++ b/src/components/Previews/GenericPreview.astro @@ -64,13 +64,20 @@ for (const attribute of attributes) { clippedAttributes.push(attribute); } else { metaLength += getLocalizedMatch(attribute.translations).name.length; - if (attribute.type === AttributeTypes.Tags) { - metaLength += attribute.value - .map(({ translations }) => getLocalizedMatch(translations).name) - .join(", ").length; - metaLength += clippedAttributes.push(attribute); + switch (attribute.type) { + case AttributeTypes.Number: + metaLength += attribute.value.toString().length; + break; + case AttributeTypes.Text: + metaLength += attribute.value.length; + break; + case AttributeTypes.Tags: + metaLength += attribute.value + .map(({ translations }) => getLocalizedMatch(translations).name) + .join(", ").length; + break; } - // TODO: Handle other attribute types + metaLength += clippedAttributes.push(attribute); } metaLength += 8; }