Skip to content

Commit 8a6ab9c

Browse files
committed
feat: add channels banner
1 parent dddb471 commit 8a6ab9c

File tree

3 files changed

+77
-8
lines changed

3 files changed

+77
-8
lines changed

src/components/ChannelsList.tsx

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import DirectusImage from "./DirectusImage";
2+
import { useTranslationTable } from "@/locales";
3+
import styles from "@/styles/ChannelsList.module.scss";
4+
import { DirectusFile } from "@directus/sdk";
5+
6+
function Channel({ file }: { file: DirectusFile }) {
7+
const tt = useTranslationTable();
8+
9+
return (
10+
<a className={styles.channel} href={file.location || ""} target="_blank">
11+
<DirectusImage
12+
className={styles.image}
13+
name={file.title || tt.join_our_channels}
14+
// @ts-expect-error
15+
img={file}
16+
cover
17+
/>
18+
<p>{file.title || tt.join_our_channels}</p>
19+
</a>
20+
);
21+
}
22+
23+
export default function ChannelsList(props: { channels: DirectusFile[] }) {
24+
return (
25+
<div className={styles.list}>
26+
{props.channels
27+
.sort((a, b) => a.title?.localeCompare(b.title || "") || -1)
28+
.map((c) => (
29+
<Channel file={c} key={c.id} />
30+
))}
31+
</div>
32+
);
33+
}

src/pages/index.tsx

+20-8
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import Decoration from "@/assets/decoration.svg";
33
import PreviewImage from "@/assets/galleryPreview.png";
44
import AssociationDescription from "@/components/AssociationDescription";
55
import Button from "@/components/Button";
6+
import ChannelsList from "@/components/ChannelsList";
67
import DirectusImage from "@/components/DirectusImage";
78
import Gallery from "@/components/Gallery";
89
import MembersList from "@/components/MembersList";
@@ -16,11 +17,7 @@ import {
1617
getDirectusImageUrl,
1718
populateLayoutProps,
1819
} from "@/directus";
19-
import {
20-
getTranslation,
21-
queryTranslations,
22-
useTranslationTable,
23-
} from "@/locales";
20+
import { getTranslation, useTranslationTable } from "@/locales";
2421
import styles from "@/styles/Homepage.module.scss";
2522
import {
2623
Association,
@@ -77,6 +74,8 @@ export default function Home(
7774

7875
<PartnersList id="partners" partners={props.partners} background={true} />
7976

77+
<ChannelsList channels={props.association.channels} />
78+
8079
<div className={styles.associationDesciption}>
8180
<div className={styles.center}>
8281
<AssociationDescription
@@ -111,11 +110,24 @@ export const getServerSideProps: GetServerSideProps<
111110
gallery: any[];
112111
} & LayoutProps
113112
> = populateLayoutProps(async (_) => {
113+
var association = await directus().request(
114+
readSingleton("association", {
115+
fields: [
116+
"*",
117+
// @ts-expect-error
118+
{ translations: ["*"] },
119+
// @ts-expect-error
120+
{ channels: ["*", { directus_files_id: ["*"] }] },
121+
],
122+
})
123+
);
124+
125+
// @ts-expect-error
126+
association.channels = association.channels.map((c) => c.directus_files_id);
127+
114128
return {
115129
props: {
116-
association: await directus().request(
117-
readSingleton("association", queryTranslations as any)
118-
),
130+
association,
119131
partners: (await directus()
120132
.request(
121133
readItems("association_partners", {

src/styles/ChannelsList.module.scss

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
.image {
2+
width: 6rem;
3+
height: 6rem;
4+
clip-path: circle();
5+
}
6+
7+
.channel {
8+
max-width: 6rem;
9+
}
10+
11+
.list {
12+
padding: 1rem;
13+
14+
display: flex;
15+
gap: 2rem;
16+
17+
p {
18+
margin: 0.5rem 0 0 0;
19+
font-weight: 400;
20+
21+
color: #eee;
22+
text-align: center;
23+
}
24+
}

0 commit comments

Comments
 (0)