Skip to content

Commit 91a099a

Browse files
authored
feat: add a page for preview save the date from directus (#69)
1 parent f7c5ca8 commit 91a099a

File tree

5 files changed

+426
-32
lines changed

5 files changed

+426
-32
lines changed

app/src/components/DirectusImage.tsx

+11
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,17 @@ const imageLoader: ImageLoader = ({ src, width, quality }) => {
66
return `${PUBLIC_DIRECTUS_URL}/assets/${src}?width=${width}`;
77
};
88

9+
export function directusImageUrl(
10+
img: string | components["schemas"]["Files"] | null
11+
) {
12+
return img
13+
? imageLoader({
14+
src: typeof img === "string" ? img : img.filename_disk || "",
15+
width: 1920,
16+
})
17+
: "";
18+
}
19+
920
/**
1021
* Display an Image fetched from the Directus instance
1122
* @param img unique public identifier of the image .

app/src/components/SocialsList.tsx

+35-31
Original file line numberDiff line numberDiff line change
@@ -14,38 +14,42 @@ export default function SocialsList(props: {
1414
return (
1515
<div className={styles.socialsList}>
1616
<div className={styles.list}>
17-
{props.socials.map((s) => {
18-
const content = (
19-
<DirectusImage
20-
sizes="4rem"
21-
img={s.logo}
22-
name={s.media_name}
23-
className={`${styles.social} ${props.light ? styles.light : ""}`}
24-
/>
25-
);
26-
27-
if (/^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$/.test(s.link || "")) {
28-
return (
29-
<a
30-
href={`mailto:${s.link}`}
31-
id={s.id?.toString()}
32-
key={s.id?.toString()}
33-
>
34-
{content}
35-
</a>
36-
);
37-
} else {
38-
return (
39-
<Link
40-
href={s.link || ""}
41-
id={s.id?.toString()}
42-
key={s.id?.toString()}
43-
>
44-
{content}
45-
</Link>
17+
{props.socials
18+
.filter((s) => s)
19+
.map((s) => {
20+
const content = (
21+
<DirectusImage
22+
sizes="4rem"
23+
img={s.logo}
24+
name={s.media_name}
25+
className={`${styles.social} ${
26+
props.light ? styles.light : ""
27+
}`}
28+
/>
4629
);
47-
}
48-
})}
30+
31+
if (/^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$/.test(s.link || "")) {
32+
return (
33+
<a
34+
href={`mailto:${s.link}`}
35+
id={s.id?.toString()}
36+
key={s.id?.toString()}
37+
>
38+
{content}
39+
</a>
40+
);
41+
} else {
42+
return (
43+
<Link
44+
href={s.link || ""}
45+
id={s.id?.toString()}
46+
key={s.id?.toString()}
47+
>
48+
{content}
49+
</Link>
50+
);
51+
}
52+
})}
4953
</div>
5054
</div>
5155
);

0 commit comments

Comments
 (0)