added avatar to landing page
continuous-integration/drone/push Build is passing Details

pull/1/head
Guus van Meerveld 2 months ago
parent 946bc5f6e6
commit a48039a480

Before

Width:  |  Height:  |  Size: 31 KiB

After

Width:  |  Height:  |  Size: 31 KiB

@ -12,7 +12,10 @@ import { FiGithub, FiMail, FiLinkedin } from "react-icons/fi";
import HeaderProps from "@models/header";
export const Header: Component<{ header: HeaderProps }> = ({ header }) => {
export const Header: Component<{ header: HeaderProps; avatar: string }> = ({
header,
avatar
}) => {
const socials = useMemo(
() => [
{
@ -36,35 +39,38 @@ export const Header: Component<{ header: HeaderProps }> = ({ header }) => {
return (
<div className="container mx-auto flex items-center min-h-screen">
<div>
{header.avatar !== undefined && (
<Image
src={header.avatar}
width={300}
alt={`A picture of ${header.fullName}`}
/>
)}
<div className="flex items-center">
<Image
isBlurred
src={avatar}
width={300}
alt={`A picture of ${header.fullName}`}
/>
<h1 className="text-4xl">{header.fullName}</h1>
<Spacer y={4} />
<Spacer x={8} />
<h2 className="text-2xl">{header.description}</h2>
<Spacer y={4} />
<div>
<h1 className="text-4xl">{header.fullName}</h1>
<Spacer y={4} />
{socials.map((social) => (
<Link href={social.link} key={social.name.toLowerCase()}>
<Tooltip showArrow content={social.name}>
<Button
className="text-2xl mr-4"
color="primary"
isIconOnly
aria-label={social.name}
>
{social.icon}
</Button>
</Tooltip>
</Link>
))}
<h2 className="text-2xl">{header.description}</h2>
<Spacer y={4} />
{socials.map((social) => (
<Link href={social.link} key={social.name.toLowerCase()}>
<Tooltip showArrow content={social.name}>
<Button
className="text-2xl mr-4"
color="primary"
isIconOnly
aria-label={social.name}
>
{social.icon}
</Button>
</Tooltip>
</Link>
))}
</div>
</div>
</div>
);

@ -1,22 +1,17 @@
import { Footer } from "../Footer";
import { Header } from "./Header";
import Landing from "@models/landing";
import { dataDirLocation } from "@utils/constants";
import { readLandingJson } from "@utils/landing";
const getLanding = async (): Promise<Landing> => {
// Any error will get handled by the `error.tsx` file.
return await readLandingJson(dataDirLocation);
};
import { readAvatarFile, readLandingJson } from "@utils/landing";
export default async function Page() {
const landing = await getLanding();
// Any error will get handled by the `error.tsx` file.
const landing = await readLandingJson(dataDirLocation);
const avatar = await readAvatarFile(dataDirLocation);
return (
<>
<Header header={landing.header} />
<Header header={landing.header} avatar={avatar} />
<Footer />
</>
);

@ -3,7 +3,6 @@ import z from "zod";
export const HeaderPropsModel = z.object({
fullName: z.string(),
name: z.string(),
avatar: z.string().optional(),
description: z.string(),
contact: z.object({
email: z.string().email(),

@ -1 +1,3 @@
export const dataDirLocation = process.env.DATA_DIR ?? "/app/data";
export const avatarFileFormat = process.env.AVATAR_FILE_FORMAT ?? "jpg";

@ -1,6 +1,8 @@
import { readJson } from "fs-extra";
import { readFile, readJson } from "fs-extra";
import path from "path";
import { avatarFileFormat } from "./constants";
import Landing, { LandingModel } from "@models/landing";
import exists from "@utils/fileExists";
@ -28,4 +30,17 @@ export const readLandingJson = async (
return landingResult.data;
};
// const readPfpFile = async (location: string): Promise<> => {};
export const readAvatarFile = async (
dataDirLocation: string
): Promise<string> => {
const avatarFileLocation = path.join(
dataDirLocation,
`avatar.${avatarFileFormat}`
);
const imageData = await readFile(avatarFileLocation);
const base64Image = Buffer.from(imageData).toString("base64");
return `data:image/${avatarFileFormat};base64,${base64Image}`;
};

Loading…
Cancel
Save