refactor(glossaire): extract entry relations rendering
This commit is contained in:
32
src/components/GlossaryRelationCards.astro
Normal file
32
src/components/GlossaryRelationCards.astro
Normal file
@@ -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 && (
|
||||||
|
<section class="glossary-relations" aria-label="Relations conceptuelles">
|
||||||
|
<h2>Relations conceptuelles</h2>
|
||||||
|
|
||||||
|
<div class="glossary-relations-grid">
|
||||||
|
{relationBlocks.map((block) => (
|
||||||
|
<section class={`glossary-relations-card ${block.className}`}>
|
||||||
|
<h3>{block.title}</h3>
|
||||||
|
<ul>
|
||||||
|
{block.items.map((item) => (
|
||||||
|
<li>
|
||||||
|
<a href={hrefOfGlossaryEntry(item)}>{item.data.term}</a>
|
||||||
|
<span> — {item.data.definitionShort}</span>
|
||||||
|
</li>
|
||||||
|
))}
|
||||||
|
</ul>
|
||||||
|
</section>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
)}
|
||||||
@@ -1,13 +1,13 @@
|
|||||||
---
|
---
|
||||||
import GlossaryLayout from "../../layouts/GlossaryLayout.astro";
|
import GlossaryLayout from "../../layouts/GlossaryLayout.astro";
|
||||||
import GlossaryAside from "../../components/GlossaryAside.astro";
|
import GlossaryAside from "../../components/GlossaryAside.astro";
|
||||||
|
import GlossaryRelationCards from "../../components/GlossaryRelationCards.astro";
|
||||||
import { getCollection, render } from "astro:content";
|
import { getCollection, render } from "astro:content";
|
||||||
import {
|
import {
|
||||||
getDisplayDomain,
|
getDisplayDomain,
|
||||||
getDisplayFamily,
|
getDisplayFamily,
|
||||||
getDisplayLevel,
|
getDisplayLevel,
|
||||||
getRelationBlocks,
|
getRelationBlocks,
|
||||||
hrefOfGlossaryEntry,
|
|
||||||
normalizeGlossarySlug,
|
normalizeGlossarySlug,
|
||||||
} from "../../lib/glossary";
|
} from "../../lib/glossary";
|
||||||
|
|
||||||
@@ -133,27 +133,7 @@ const hasScholarlyMeta =
|
|||||||
<Content />
|
<Content />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{relationBlocks.length > 0 && (
|
<GlossaryRelationCards relationBlocks={relationBlocks} />
|
||||||
<section class="glossary-relations" aria-label="Relations conceptuelles">
|
|
||||||
<h2>Relations conceptuelles</h2>
|
|
||||||
|
|
||||||
<div class="glossary-relations-grid">
|
|
||||||
{relationBlocks.map((block) => (
|
|
||||||
<section class={`glossary-relations-card ${block.className}`}>
|
|
||||||
<h3>{block.title}</h3>
|
|
||||||
<ul>
|
|
||||||
{block.items.map((item) => (
|
|
||||||
<li>
|
|
||||||
<a href={hrefOfGlossaryEntry(item)}>{item.data.term}</a>
|
|
||||||
<span> — {item.data.definitionShort}</span>
|
|
||||||
</li>
|
|
||||||
))}
|
|
||||||
</ul>
|
|
||||||
</section>
|
|
||||||
))}
|
|
||||||
</div>
|
|
||||||
</section>
|
|
||||||
)}
|
|
||||||
</GlossaryLayout>
|
</GlossaryLayout>
|
||||||
|
|
||||||
<script is:inline>
|
<script is:inline>
|
||||||
|
|||||||
Reference in New Issue
Block a user