|
1 | 1 | --- |
2 | | -import BaseLayout from "@/layouts/Base"; |
| 2 | +import "@/assets/styles/glossary/glossary.css"; |
3 | 3 | import BackButton from "@/components/BackButton.astro"; |
4 | 4 | import LetterCard from "@/components/LetterCard.astro"; |
5 | | -import "@/assets/styles/glossary/glossary.css"; |
6 | 5 | import glossaryData from "@/data/glossary.json"; |
| 6 | +import BaseLayout from "@/layouts/Base"; |
| 7 | +import { getFlagEmoji } from "@/utils"; |
7 | 8 |
|
8 | | -const pageTitle = glossaryData.flags.title; |
9 | | -const flagsData = glossaryData.flags.data; |
10 | | -
|
11 | | -const getFlagEmoji = (countryCode: string = "IN") => { |
12 | | - const codePoints = countryCode |
13 | | - .toUpperCase() |
14 | | - .split("") |
15 | | - .map((char) => 127397 + char.charCodeAt(0)); |
16 | | - return String.fromCodePoint(...codePoints); |
17 | | -}; |
| 9 | +const { |
| 10 | + flags: { title, data } |
| 11 | +} = glossaryData; |
18 | 12 |
|
| 13 | +const flagsData = data.map((entry) => ({ ...entry, letter: getFlagEmoji(entry.countryCode) })); |
19 | 14 | --- |
20 | 15 |
|
21 | | -<BaseLayout meta={{ title: pageTitle }}> |
22 | | - <BackButton href="/Glossary" /> |
23 | | - <article class="container__page"> |
| 16 | +<BaseLayout meta={{ title }}> |
| 17 | + <BackButton href="/glossary" /> |
| 18 | + <div class="container__page"> |
24 | 19 | <div class="page__header"> |
25 | | - <h1 class="page__title">{pageTitle}</h1> |
26 | | - <button id="flip-all-button-page" class="btn__flip__all">Flip All Cards</button> |
| 20 | + <h1 class="page__title">{title}</h1> |
| 21 | + <button id="flip-all-button" class="btn__flip__all">Flip All Cards</button> |
27 | 22 | </div> |
28 | 23 |
|
29 | 24 | <div class="container__glossary"> |
30 | 25 | <div class="glossary__grid"> |
31 | | - { |
32 | | - flagsData.map((entry) => ( |
33 | | - <LetterCard |
34 | | - item={{ |
35 | | - ...entry, |
36 | | - letter: getFlagEmoji(entry.countryCode), |
37 | | - text: entry.text, |
38 | | - description: entry.description, |
39 | | - }} |
40 | | - category="flags" |
41 | | - /> |
42 | | - )) |
43 | | - } |
| 26 | + {flagsData.map((entry) => <LetterCard item={entry} category="flags" class="flag" />)} |
44 | 27 | </div> |
45 | 28 | </div> |
| 29 | + </div> |
46 | 30 | </BaseLayout> |
0 commit comments