created server side code for landing page
continuous-integration/drone/push Build is failing
Details
continuous-integration/drone/push Build is failing
Details
parent
d7553617b8
commit
7c458c179f
@ -0,0 +1,15 @@
|
||||
import Landing from "@models/landing";
|
||||
|
||||
import { readLandingJson } from "@utils/landing";
|
||||
|
||||
const getLanding = async (): Promise<Landing> => {
|
||||
return await readLandingJson();
|
||||
};
|
||||
|
||||
export default async function Page() {
|
||||
const landing = await getLanding();
|
||||
|
||||
return <div>{/* <Button color="primary">Click me</Button> */}</div>;
|
||||
}
|
||||
|
||||
export const revalidate = 3600;
|
@ -0,0 +1,30 @@
|
||||
"use client";
|
||||
|
||||
import { Link, Spacer } from "@nextui-org/react";
|
||||
|
||||
// Error components must be Client Components
|
||||
import { useEffect } from "react";
|
||||
|
||||
export default function Error({
|
||||
error,
|
||||
reset
|
||||
}: {
|
||||
error: Error & { digest?: string };
|
||||
reset: () => void;
|
||||
}) {
|
||||
useEffect(() => {
|
||||
console.error(error);
|
||||
}, [error]);
|
||||
|
||||
return (
|
||||
<div className="container min-h-screen text-center">
|
||||
<p className="text-3xl">Something went loading the page!</p>
|
||||
<p className="text-xl">{error.toString()}</p>
|
||||
<div>
|
||||
<Link href="#" onClick={() => reset()}>
|
||||
Try again
|
||||
</Link>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
@ -1,11 +0,0 @@
|
||||
"use client";
|
||||
|
||||
import { Button } from "@nextui-org/react";
|
||||
|
||||
export default function Page() {
|
||||
return (
|
||||
<div>
|
||||
<Button color="primary">Click me</Button>
|
||||
</div>
|
||||
);
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
import z from "zod";
|
||||
|
||||
import { OwnerModel } from "./owner";
|
||||
|
||||
export const LandingModel = z.object({
|
||||
owner: OwnerModel
|
||||
});
|
||||
|
||||
export type Landing = z.infer<typeof LandingModel>;
|
||||
|
||||
export default Landing;
|
@ -0,0 +1,17 @@
|
||||
import z from "zod";
|
||||
|
||||
export const OwnerModel = z.object({
|
||||
fullName: z.string(),
|
||||
name: z.string(),
|
||||
description: z.string(),
|
||||
avatar: z.string().optional(),
|
||||
contact: z.object({
|
||||
email: z.string().email(),
|
||||
linkedin: z.string().url(),
|
||||
git: z.string().url()
|
||||
})
|
||||
});
|
||||
|
||||
export type Owner = z.infer<typeof OwnerModel>;
|
||||
|
||||
export default Owner;
|
@ -1,3 +1,25 @@
|
||||
@tailwind base;
|
||||
@tailwind components;
|
||||
@tailwind utilities;
|
||||
|
||||
.container {
|
||||
display: flex;
|
||||
min-width: 100%;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
|
||||
@media screen and (width >=600px) {
|
||||
padding-right: 1rem;
|
||||
padding-left: 1rem;
|
||||
}
|
||||
|
||||
@media screen and (width >=800px) {
|
||||
padding-right: 4rem;
|
||||
padding-left: 4rem;
|
||||
}
|
||||
|
||||
@media screen and (width >=1200px) {
|
||||
padding-right: 16rem;
|
||||
padding-left: 16rem;
|
||||
}
|
||||
}
|
@ -0,0 +1,2 @@
|
||||
export const landingJsonLocation =
|
||||
process.env.LANDING_JSON_LOCATION ?? "/app/landing.json";
|
@ -0,0 +1,9 @@
|
||||
import { stat } from "fs-extra";
|
||||
|
||||
const fileExists = async (fileName: string): Promise<boolean> => {
|
||||
return await stat(fileName)
|
||||
.then(() => true)
|
||||
.catch(() => false);
|
||||
};
|
||||
|
||||
export default fileExists;
|
@ -0,0 +1,25 @@
|
||||
import { readJson } from "fs-extra";
|
||||
|
||||
import Landing, { LandingModel } from "@models/landing";
|
||||
|
||||
import { landingJsonLocation } from "@utils/constants";
|
||||
import exists from "@utils/fileExists";
|
||||
|
||||
export const readLandingJson = async (): Promise<Landing> => {
|
||||
const location = landingJsonLocation;
|
||||
|
||||
const fileExists = await exists(location);
|
||||
|
||||
if (!fileExists) {
|
||||
throw new Error(`Could not find landing json file at: ${location}`);
|
||||
}
|
||||
|
||||
const rawJson: unknown = await readJson(location);
|
||||
|
||||
const landingResult = LandingModel.safeParse(rawJson);
|
||||
|
||||
if (!landingResult.success)
|
||||
throw new Error(`Failed to parse landing json: ${landingResult.error}`);
|
||||
|
||||
return landingResult.data;
|
||||
};
|
Loading…
Reference in new issue