Refactor code structure for improved readability and maintainability

This commit is contained in:
Marco Pedone 2025-10-07 18:07:57 +02:00
parent 5c3a13bea9
commit 39074b58e4
3 changed files with 52 additions and 23 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 79 KiB

View file

@ -1,5 +1,6 @@
import { ArrowRight, Telescope } from "lucide-react";
import type { NextPage } from "next";
import Head from "next/head";
import Link from "next/link";
import { AccordionComp } from "~/components/accordionComp";
import { CodiceBox } from "~/components/codiceRicerca";
@ -7,13 +8,34 @@ import { PricingChoice } from "~/components/prezzi";
import { HeroSvg, LogoSvg } from "~/components/svgs";
import { Button } from "~/components/ui/button";
import { Card, CardContent, CardHeader, CardTitle } from "~/components/ui/card";
import { env } from "~/env.mjs";
import type { LangDict } from "~/i18n/locales";
import { useTranslation } from "~/providers/I18nProvider";
const Home: NextPage = () => {
const { t } = useTranslation();
const description =
"Infoalloggi.it - Trova il tuo alloggio ideale in modo semplice e veloce. Annunci di case, appartamenti e stanze in affitto per studenti, lavoratori e famiglie. Scopri ora gli annunci!";
return (
<main>
<Head>
<meta content={description} property="description" />
<meta content={env.NEXT_PUBLIC_BASE_URL} property="og:url" />
<meta content="website" property="og:type" />
<meta content="Infoalloggi.it" property="og:title" />
<meta content={description} property="og:description" />
<meta
content={`${env.NEXT_PUBLIC_BASE_URL}/og.jpg`}
property="og:image"
/>
<meta content="1200" property="og:image:width" />
<meta content="630" property="og:image:height" />
<meta
content={`${env.NEXT_PUBLIC_BASE_URL}/Infoalloggi.png`}
property="og:logo"
/>
<meta content="Infoalloggi.it" property="og:site_name" />
</Head>
<div className="mx-5 mt-0 mb-12 sm:mt-[2rem]">
<main className="mx-auto mb-4 max-w-7xl space-y-5 lg:mb-20">
<div className="flex flex-col items-center justify-center lg:flex-row lg:justify-around">
@ -37,6 +59,7 @@ const Home: NextPage = () => {
<PricingChoice />
</div>
</div>
</main>
);
};

View file

@ -94,17 +94,23 @@ export const getAnnunciMetaByCod = async ({ cod }: { cod: string }) => {
try {
const annuncio = await db
.selectFrom("annunci")
.select(["titolo_it", "desc_it", "og_url"])
.select(["titolo_it", "desc_it", "og_url", "url_immagini"])
.where("annunci.web", "=", true)
.where("codice", "=", cod)
.executeTakeFirst();
if (!annuncio) {
return null;
}
const ogImage =
annuncio.url_immagini &&
annuncio.url_immagini.length > 0 &&
annuncio.url_immagini[0]
? annuncio.url_immagini[0]
: annuncio.og_url || "";
return {
description: annuncio.desc_it || "",
ogImage: annuncio.og_url || "",
ogImage,
ogUrl: `${env.NEXT_PUBLIC_BASE_URL}/annuncio/${cod}`,
title: annuncio.titolo_it || "",
};