diff options
| author | Joe Carstairs <65492573+Sycamost@users.noreply.github.com> | 2023-10-13 21:26:13 +0100 |
|---|---|---|
| committer | Joe Carstairs <65492573+Sycamost@users.noreply.github.com> | 2023-10-13 21:26:13 +0100 |
| commit | 796fdeed465f8a4f9d4aaaaf9ddf448f91e901e6 (patch) | |
| tree | 689207e496fc25b7cb1d33004194bb9f9a14d102 /src | |
| parent | 8b2d91cb1cdff722bb4913c8f023c6cd16801e5c (diff) | |
Pulls out CommitteeList component
Diffstat (limited to 'src')
| -rw-r--r-- | src/components/CommitteeList/CommitteeList.astro | 8 | ||||
| -rw-r--r-- | src/components/CommitteeList/CommitteeListItem.astro | 39 | ||||
| -rw-r--r-- | src/pages/[locale]/index.astro | 26 |
3 files changed, 49 insertions, 24 deletions
diff --git a/src/components/CommitteeList/CommitteeList.astro b/src/components/CommitteeList/CommitteeList.astro new file mode 100644 index 0000000..f576c9a --- /dev/null +++ b/src/components/CommitteeList/CommitteeList.astro @@ -0,0 +1,8 @@ +--- +import committee from '$data/committee'; +import CommitteeListItem from './CommitteeListItem.astro'; +--- + +<ul> + {committee.map((committeeMember) => <CommitteeListItem committeeMember={committeeMember} />)} +</ul> diff --git a/src/components/CommitteeList/CommitteeListItem.astro b/src/components/CommitteeList/CommitteeListItem.astro new file mode 100644 index 0000000..d026047 --- /dev/null +++ b/src/components/CommitteeList/CommitteeListItem.astro @@ -0,0 +1,39 @@ +--- +import CommitteeRole from '$enums/CommitteeRole'; +import tRole from '$i18n/translations/enums/committeeRole'; +import translate from '$i18n/translate'; +import type { CommitteeMember } from '$types/CommitteeMember'; +import type Locale from '$types/Locale'; + +interface Props { + committeeMember: CommitteeMember; +} + +const { committeeMember } = Astro.props; + +const locale = Astro.params.locale as Locale; + +const t = translate(locale); +--- + +<li class="committee__member"> + { + committeeMember.img && ( + <img class="committee__member__img" src={committeeMember.img.src} alt="" /> + ) + } + <div class="committee__member__text"> + <h4> + {committeeMember.name} + { + committeeMember.roles.length > 0 && ( + <span class="font-weight-lighter"> + |{' '} + {committeeMember.roles.map((role) => t(tRole, { key: CommitteeRole[role] })).join(', ')} + </span> + ) + } + </h4> + {committeeMember.bio && <p set:html={committeeMember.bio[locale]} />} + </div> +</li> diff --git a/src/pages/[locale]/index.astro b/src/pages/[locale]/index.astro index 653c637..c67ded0 100644 --- a/src/pages/[locale]/index.astro +++ b/src/pages/[locale]/index.astro @@ -3,14 +3,12 @@ import Page from '$layouts/Page.astro'; import localeStaticPaths from '$lib/localeStaticPaths'; import translate from '$i18n/translate'; import tPage from '$i18n/translations/pages/home'; -import tRole from '$i18n/translations/enums/committeeRole'; import type Locale from '$types/Locale'; import { getMostRecentNewsItem } from '$lib/newsUtils'; import contactDetails from '$data/contactDetails'; import NewsIndex from '$components/NewsIndex/NewsIndex.astro'; -import committee from '$data/committee'; import Button from '$components/Button.astro'; -import CommitteeRole from '$enums/CommitteeRole'; +import CommitteeList from '$components/CommitteeList/CommitteeList.astro'; export async function getStaticPaths() { return localeStaticPaths; @@ -46,27 +44,7 @@ const mostRecentNewsItem = await getMostRecentNewsItem(locale); <p set:html={t(tPage, { key: 'about-us-para-3' })} /> <h3 set:html={t(tPage, { key: 'meet-the-commattee' })} /> <p class="italic">{t(tPage, { key: 'mair-commattee-details-soon' })}</p> - <ul> - { - committee.map((member) => ( - <li class="committee__member"> - {member.img && <img class="committee__member__img" src={member.img.src} alt="" />} - <div class="committee__member__text"> - <h4> - {member.name} - {member.roles.length > 0 && ( - <span class="font-weight-lighter"> - |{' '} - {member.roles.map((role) => t(tRole, { key: CommitteeRole[role] })).join(', ')} - </span> - )} - </h4> - {member.bio && <p set:html={member.bio[locale]} />} - </div> - </li> - )) - } - </ul> + <CommitteeList /> </section> <section> |
