Refactor getAnnunciMetaByCod to remove unused url_immagini and simplify ogImage handling
This commit is contained in:
parent
7bfef22f80
commit
0744d032a3
1 changed files with 3 additions and 6 deletions
|
|
@ -1,6 +1,6 @@
|
|||
import type { Annunci, AnnunciId } from "~/schemas/public/Annunci";
|
||||
import { TRPCError } from "@trpc/server";
|
||||
import { createSrc, createSrcset } from "~/server/services/imageServer";
|
||||
import { createSrcset } from "~/server/services/imageServer";
|
||||
import { AnnuncioObjectWithImages } from "~/server/services/annunci.service";
|
||||
import { zAnnuncioId } from "~/server/utils/zod_types";
|
||||
import { z } from "zod/v4";
|
||||
|
|
@ -93,7 +93,7 @@ export const getAnnunciMetaByCod = async ({ cod }: { cod: string }) => {
|
|||
try {
|
||||
const annuncio = await db
|
||||
.selectFrom("annunci")
|
||||
.select(["titolo_it", "desc_it", "url_immagini", "og_url"])
|
||||
.select(["titolo_it", "desc_it", "og_url"])
|
||||
.where("annunci.web", "=", true)
|
||||
.where("codice", "=", cod)
|
||||
.executeTakeFirst();
|
||||
|
|
@ -105,10 +105,7 @@ export const getAnnunciMetaByCod = async ({ cod }: { cod: string }) => {
|
|||
}
|
||||
|
||||
return {
|
||||
ogImage:
|
||||
annuncio.url_immagini && annuncio.url_immagini[0]
|
||||
? createSrc(annuncio.url_immagini[0])
|
||||
: annuncio.og_url || "",
|
||||
ogImage: annuncio.og_url || "",
|
||||
title: annuncio.titolo_it || "",
|
||||
description: annuncio.desc_it || "",
|
||||
ogUrl: env.NEXT_PUBLIC_BASE_URL + "/annuncio/" + cod,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue