From 4abe70e10e5e7f760ee228cb3eeda08df048a066 Mon Sep 17 00:00:00 2001 From: Archicratia Date: Wed, 25 Mar 2026 15:30:51 +0100 Subject: [PATCH] refactor(glossaire): extract entry relations rendering --- src/components/GlossaryRelationCards.astro | 32 ++++++++++++++++++++++ src/pages/glossaire/[...slug].astro | 24 ++-------------- 2 files changed, 34 insertions(+), 22 deletions(-) create mode 100644 src/components/GlossaryRelationCards.astro diff --git a/src/components/GlossaryRelationCards.astro b/src/components/GlossaryRelationCards.astro new file mode 100644 index 0000000..0f800ea --- /dev/null +++ b/src/components/GlossaryRelationCards.astro @@ -0,0 +1,32 @@ +--- +import type { GlossaryRelationBlock } from "../lib/glossary"; +import { hrefOfGlossaryEntry } from "../lib/glossary"; + +interface Props { + relationBlocks: GlossaryRelationBlock[]; +} + +const { relationBlocks = [] } = Astro.props; +--- + +{relationBlocks.length > 0 && ( +
+

Relations conceptuelles

+ +
+ {relationBlocks.map((block) => ( +
+

{block.title}

+
    + {block.items.map((item) => ( +
  • + {item.data.term} + — {item.data.definitionShort} +
  • + ))} +
+
+ ))} +
+
+)} diff --git a/src/pages/glossaire/[...slug].astro b/src/pages/glossaire/[...slug].astro index 489496d..4f86787 100644 --- a/src/pages/glossaire/[...slug].astro +++ b/src/pages/glossaire/[...slug].astro @@ -1,13 +1,13 @@ --- import GlossaryLayout from "../../layouts/GlossaryLayout.astro"; import GlossaryAside from "../../components/GlossaryAside.astro"; +import GlossaryRelationCards from "../../components/GlossaryRelationCards.astro"; import { getCollection, render } from "astro:content"; import { getDisplayDomain, getDisplayFamily, getDisplayLevel, getRelationBlocks, - hrefOfGlossaryEntry, normalizeGlossarySlug, } from "../../lib/glossary"; @@ -133,27 +133,7 @@ const hasScholarlyMeta = - {relationBlocks.length > 0 && ( -
-

Relations conceptuelles

- -
- {relationBlocks.map((block) => ( -
-

{block.title}

-
    - {block.items.map((item) => ( -
  • - {item.data.term} - — {item.data.definitionShort} -
  • - ))} -
-
- ))} -
-
- )} +