Skip to content

Commit

Permalink
fix: Improve og images (#21)
Browse files Browse the repository at this point in the history
* Improve og images

* Adjust disable comment
  • Loading branch information
soniaklimas authored Oct 22, 2024
1 parent 9016a06 commit bd5861b
Show file tree
Hide file tree
Showing 7 changed files with 61 additions and 87 deletions.
6 changes: 4 additions & 2 deletions apps/storefront/messages/en-GB.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{
"home": {
"title": "Homepage",
"description": "Nimara's headless architecture, built on Saleor, provides a flexible, cost-effective solution for online businesses. It’s ready to deploy with minimal setup, supports seamless integration of new providers, and features an intuitive UI for easy storefront customization and management."
"description": "Nimara's headless architecture, built on Saleor, provides a flexible, cost-effective solution for online businesses. It’s ready to deploy with minimal setup, supports seamless integration of new providers, and features an intuitive UI for easy storefront customization and management.",
"homepage-preview": "Homepage preview"
},
"locale": {
"region": "Region",
Expand Down Expand Up @@ -35,7 +36,8 @@
"sort-by": "Sort by",
"all-products-link": "All products link",
"open-search": "Open search",
"search-label": "Search"
"search-label": "Search",
"search-preview": "Search preview"
},
"common": {
"checkout": "Checkout",
Expand Down
Binary file added apps/storefront/public/og-hp.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
74 changes: 0 additions & 74 deletions apps/storefront/src/app/[locale]/(main)/opengraph-image.tsx

This file was deleted.

10 changes: 10 additions & 0 deletions apps/storefront/src/app/[locale]/(main)/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,16 @@ export async function generateMetadata(_params: {
return {
title: t("title"),
description: t("description"),
openGraph: {
images: [
{
url: "/og-hp.png",
width: 1200,
height: 630,
alt: t("homepage-preview"),
},
],
},
};
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { ImageResponse } from "next/og";

import { ReactComponent as NimaraLogo } from "@/assets/nimara-logo.svg";
import { CACHE_TTL } from "@/config";
import { clientEnvs } from "@/envs/client";
import { getCurrentRegion } from "@/regions/server";
Expand Down Expand Up @@ -47,16 +48,40 @@ export default async function Image({

return new ImageResponse(
(
<div tw="flex w-full h-full items-center justify-center bg-neutral-100">
<div style={{ display: "flex" }}>
<div
<div
tw="flex w-full h-full"
style={{
display: "flex",
width: "100%",
height: "100%",
}}
>
<div
style={{
width: "50%",
display: "flex",
alignItems: "center",
justifyContent: "center",
}}
>
<NimaraLogo width={276} height={56} />
</div>
<div
style={{
width: "50%",
display: "flex",
alignItems: "center",
justifyContent: "center",
}}
>
{/* eslint-disable-next-line @next/next/no-img-element */}
<img
src={data?.product?.images[0]?.url}
alt={data?.product?.name}
style={{
backgroundImage: `url(${data?.product?.images[0]?.url})`,
height: "630px",
width: "630px",
backgroundRepeat: "no-repeat",
backgroundPosition: "center",
backgroundSize: "contain",
maxWidth: "100%",
maxHeight: "100%",
objectFit: "contain",
}}
/>
</div>
Expand Down
10 changes: 10 additions & 0 deletions apps/storefront/src/app/[locale]/(main)/search/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,16 @@ export async function generateMetadata({ searchParams }: PageProps) {
title: searchParams.q
? t("search-for", { query: searchParams.q })
: t("search-results"),
openGraph: {
images: [
{
url: "/og-hp.png",
width: 1200,
height: 630,
alt: t("search-preview"),
},
],
},
};
}

Expand Down
5 changes: 3 additions & 2 deletions packages/codegen/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14838,7 +14838,7 @@ export type MutationTransactionCreateArgs = {


export type MutationTransactionEventReportArgs = {
amount: Scalars['PositiveDecimal']['input'];
amount?: InputMaybe<Scalars['PositiveDecimal']['input']>;
availableActions?: InputMaybe<Array<TransactionActionEnum>>;
externalUrl?: InputMaybe<Scalars['String']['input']>;
id?: InputMaybe<Scalars['ID']['input']>;
Expand Down Expand Up @@ -28600,7 +28600,8 @@ export type TransactionEventReportErrorCode =
| 'GRAPHQL_ERROR'
| 'INCORRECT_DETAILS'
| 'INVALID'
| 'NOT_FOUND';
| 'NOT_FOUND'
| 'REQUIRED';

/**
* Represents possible event types.
Expand Down

0 comments on commit bd5861b

Please sign in to comment.