Added generic image variant for og images and make meta description longer. (#5285)
* Added generic image variant for og images. * Made og and meta descriptions longer, removed difference between longer and shorter descriptions now we only have one variant. Co-authored-by: Hariom Balhara <[email protected]> Co-authored-by: Peer Richelsen <[email protected]>
This commit is contained in:
4 files changed
+62
-13
No files matched your search
@@ -4,6 +4,7 @@ import { NextSeo, NextSeoProps } from "next-seo";
|
||||
import {
|
||||
AppImageProps,
|
||||
constructAppImage,
|
||||
constructGenericImage,
|
||||
constructMeetingImage,
|
||||
MeetingImageProps,
|
||||
} from "@calcom/lib/OgImages";
|
||||
@@ -72,12 +73,11 @@ const buildSeoMeta = (pageProps: {
|
||||
|
||||
export const HeadSeo = (props: HeadSeoProps): JSX.Element => {
|
||||
const defaultUrl = getBrowserInfo()?.url;
|
||||
const image = getSeoImage("default");
|
||||
|
||||
const { title, description, siteName, canonical = defaultUrl, nextSeoProps = {}, app, meeting } = props;
|
||||
|
||||
const truncatedDescription = truncate(description, 24);
|
||||
const longerTruncatedDescriptionOnWords = truncateOnWord(description, 148);
|
||||
const image = getSeoImage("ogImage") + constructGenericImage({ title, description });
|
||||
const truncatedDescription = truncateOnWord(description, 158);
|
||||
|
||||
const pageTitle = title + " | Cal.com";
|
||||
let seoObject = buildSeoMeta({
|
||||
@@ -101,7 +101,7 @@ export const HeadSeo = (props: HeadSeoProps): JSX.Element => {
|
||||
|
||||
if (app) {
|
||||
const pageImage =
|
||||
getSeoImage("ogImage") + constructAppImage({ ...app, description: longerTruncatedDescriptionOnWords });
|
||||
getSeoImage("ogImage") + constructAppImage({ ...app, description: truncatedDescription });
|
||||
seoObject = buildSeoMeta({
|
||||
title: pageTitle,
|
||||
description: truncatedDescription,
|
||||
|
||||
@@ -3,7 +3,7 @@ import { NextApiRequest } from "next";
|
||||
import type { SatoriOptions } from "satori";
|
||||
import { z } from "zod";
|
||||
|
||||
import { Meeting, App } from "@calcom/lib/OgImages";
|
||||
import { Meeting, App, Generic } from "@calcom/lib/OgImages";
|
||||
|
||||
const calFont = fetch(new URL("../../../../public/fonts/cal.ttf", import.meta.url)).then((res) =>
|
||||
res.arrayBuffer()
|
||||
@@ -37,6 +37,12 @@ const appSchema = z.object({
|
||||
slug: z.string(),
|
||||
});
|
||||
|
||||
const genericSchema = z.object({
|
||||
imageType: z.literal("generic"),
|
||||
title: z.string(),
|
||||
description: z.string(),
|
||||
});
|
||||
|
||||
export default async function handler(req: NextApiRequest) {
|
||||
const { searchParams } = new URL(`${req.url}`);
|
||||
const imageType = searchParams.get("type");
|
||||
@@ -85,6 +91,17 @@ export default async function handler(req: NextApiRequest) {
|
||||
});
|
||||
return new ImageResponse(<App name={name} description={description} slug={slug} />, ogConfig);
|
||||
}
|
||||
|
||||
case "generic": {
|
||||
const { title, description } = genericSchema.parse({
|
||||
title: searchParams.get("title"),
|
||||
description: searchParams.get("description"),
|
||||
imageType,
|
||||
});
|
||||
|
||||
return new ImageResponse(<Generic title={title} description={description} />, ogConfig);
|
||||
}
|
||||
|
||||
default:
|
||||
return new Response("What you're looking for is not here..", { status: 404 });
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user