From 0cf71b4d954c987c6d4e8f475cea82dde1404dab Mon Sep 17 00:00:00 2001
From: DrMint <29893320+DrMint@users.noreply.github.com>
Date: Sat, 13 Jul 2024 11:06:41 +0200
Subject: [PATCH] Added missing search preview types
---
.../Previews/ChronologyEventPreview.astro | 48 +++
src/components/Previews/FolderPreview.astro | 56 ++++
src/components/Previews/GenericPreview.astro | 18 +-
src/components/Previews/RecorderPreview.astro | 36 +++
src/i18n/wordings-keys.ts | 5 +-
src/pages/[locale]/index.astro | 5 +-
src/pages/[locale]/search/index.astro | 9 +
src/shared/meilisearch/meilisearch-sdk.ts | 9 +-
src/shared/openExchange/rates.json | 292 +++++++++---------
9 files changed, 320 insertions(+), 158 deletions(-)
create mode 100644 src/components/Previews/ChronologyEventPreview.astro
create mode 100644 src/components/Previews/FolderPreview.astro
create mode 100644 src/components/Previews/RecorderPreview.astro
diff --git a/src/components/Previews/ChronologyEventPreview.astro b/src/components/Previews/ChronologyEventPreview.astro
new file mode 100644
index 0000000..b578938
--- /dev/null
+++ b/src/components/Previews/ChronologyEventPreview.astro
@@ -0,0 +1,48 @@
+---
+import GenericPreview from "components/Previews/GenericPreview.astro";
+import { getI18n } from "src/i18n/i18n";
+import type { EndpointChronologyEvent } from "src/shared/payload/payload-sdk";
+import { formatRichTextToString, formatTimelineDateToId } from "src/utils/format";
+
+interface Props {
+ event: EndpointChronologyEvent["events"][number];
+ date: EndpointChronologyEvent["date"];
+}
+
+const { getLocalizedUrl, getLocalizedMatch, t, formatTimelineDate } = await getI18n(
+ Astro.locals.currentLocale
+);
+
+const {
+ date,
+ event: { translations },
+} = Astro.props;
+
+const { title, description, language } = getLocalizedMatch(translations);
+
+const getTruncatedText = () => {
+ const getTextContent = () => {
+ if (title) return title;
+ if (description) return formatRichTextToString(description);
+ return "";
+ };
+
+ const text = getTextContent();
+ const limit = 45;
+ const truncationMark = "...";
+ if (text.length < limit) return text;
+ return text.substring(0, limit - truncationMark.length) + truncationMark;
+};
+---
+
+{/* ------------------------------------------- HTML ------------------------------------------- */}
+
+