From ca9ab591cdd5b1595de926d9bedf376b583bb7b0 Mon Sep 17 00:00:00 2001 From: Alessandro Rabitti Date: Mon, 6 May 2024 11:39:50 +0200 Subject: [PATCH] Added intro text and quote in home page --- app/app.module.css | 12 ++++++++++++ app/page.tsx | 18 +++++++++++++++++- src/api/quote/index.ts | 13 +++++++++++++ src/types/quote.d.ts | 4 ++++ 4 files changed, 46 insertions(+), 1 deletion(-) create mode 100644 app/app.module.css create mode 100644 src/api/quote/index.ts create mode 100644 src/types/quote.d.ts diff --git a/app/app.module.css b/app/app.module.css new file mode 100644 index 0000000..febcf53 --- /dev/null +++ b/app/app.module.css @@ -0,0 +1,12 @@ +.uaapp_quote { + margin: 20px 0; + text-align: right; +} + +.uaapp_quote q { + font-style: italic; +} + +.uaapp_quote footer { + font-size: smaller; +} diff --git a/app/page.tsx b/app/page.tsx index e85a161..48ab9d6 100644 --- a/app/page.tsx +++ b/app/page.tsx @@ -1,11 +1,27 @@ +import { getRandomQuote } from '../src/api/quote' import { HeroImage } from '../src/views/hero-image' +import styles from './app.module.css' + +export const dynamic = 'force-dynamic' + +export default async function AppPage() { + const quote = await getRandomQuote() -export default function RootPage() { return ( <>

unknown art

+

+ unknown art is where you can, hopefully, get in contact with persons, + lovers, thinkers, minds or artists, all over the beautiful world. +

+ + +
+ {quote.message} +
{quote.author}
+
) } diff --git a/src/api/quote/index.ts b/src/api/quote/index.ts new file mode 100644 index 0000000..ecc847b --- /dev/null +++ b/src/api/quote/index.ts @@ -0,0 +1,13 @@ +import { Quote } from '../../../src/types/quote' +import clientPromise from '../../config/mongodb' + +export const getRandomQuote = async (): Promise => { + const mongoClient = await clientPromise + const data = await mongoClient + .db('ua-db') + .collection('ua-quotes') + .aggregate([{ $sample: { size: 1 } }]) + .toArray() + + return JSON.parse(JSON.stringify(data[0])) +} diff --git a/src/types/quote.d.ts b/src/types/quote.d.ts new file mode 100644 index 0000000..08d2bd7 --- /dev/null +++ b/src/types/quote.d.ts @@ -0,0 +1,4 @@ +export type Quote = { + message: string + author: string +}