feat(og): Standardize OG images across all subpages with logo and background
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
import { ImageResponse } from 'next/og';
|
import { ImageResponse } from 'next/og';
|
||||||
import { getPageBySlug } from '@/lib/pages';
|
import { getPageBySlug } from '@/lib/pages';
|
||||||
import { OGImageTemplate } from '@/components/OGImageTemplate';
|
import { OGImageTemplate } from '@/components/OGImageTemplate';
|
||||||
import { getOgFonts, OG_IMAGE_SIZE } from '@/lib/og-helper';
|
import { getOgFonts, getOgBackground, getOgLogo, OG_IMAGE_SIZE } from '@/lib/og-helper';
|
||||||
|
|
||||||
export const size = OG_IMAGE_SIZE;
|
export const size = OG_IMAGE_SIZE;
|
||||||
export const contentType = 'image/png';
|
export const contentType = 'image/png';
|
||||||
@@ -20,12 +20,16 @@ export default async function Image({
|
|||||||
}
|
}
|
||||||
|
|
||||||
const fonts = await getOgFonts();
|
const fonts = await getOgFonts();
|
||||||
|
const bg = getOgBackground();
|
||||||
|
const logo = getOgLogo();
|
||||||
|
|
||||||
return new ImageResponse(
|
return new ImageResponse(
|
||||||
<OGImageTemplate
|
<OGImageTemplate
|
||||||
title={pageData.frontmatter.title}
|
title="Die Experten für Kabelnetzbau"
|
||||||
description={pageData.frontmatter.excerpt}
|
description={`${pageData.frontmatter.title}`}
|
||||||
label="Information"
|
label="Information"
|
||||||
|
image={bg}
|
||||||
|
logo={logo}
|
||||||
/>,
|
/>,
|
||||||
{
|
{
|
||||||
...OG_IMAGE_SIZE,
|
...OG_IMAGE_SIZE,
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { ImageResponse } from 'next/og';
|
import { ImageResponse } from 'next/og';
|
||||||
import { getPostBySlug } from '@/lib/blog';
|
import { getPostBySlug } from '@/lib/blog';
|
||||||
import { OGImageTemplate } from '@/components/OGImageTemplate';
|
import { OGImageTemplate } from '@/components/OGImageTemplate';
|
||||||
import { getOgFonts, OG_IMAGE_SIZE } from '@/lib/og-helper';
|
import { getOgFonts, getOgBackground, getOgLogo, OG_IMAGE_SIZE } from '@/lib/og-helper';
|
||||||
import { SITE_URL } from '@/lib/schema';
|
import { SITE_URL } from '@/lib/schema';
|
||||||
|
|
||||||
export const size = OG_IMAGE_SIZE;
|
export const size = OG_IMAGE_SIZE;
|
||||||
@@ -52,13 +52,16 @@ export default async function Image({
|
|||||||
if (featuredImage) {
|
if (featuredImage) {
|
||||||
base64Image = await fetchImageAsBase64(featuredImage);
|
base64Image = await fetchImageAsBase64(featuredImage);
|
||||||
}
|
}
|
||||||
|
const bg = getOgBackground();
|
||||||
|
const logo = getOgLogo();
|
||||||
|
|
||||||
return new ImageResponse(
|
return new ImageResponse(
|
||||||
<OGImageTemplate
|
<OGImageTemplate
|
||||||
title={post.frontmatter.title}
|
title="Die Experten für Kabelnetzbau"
|
||||||
description={post.frontmatter.excerpt}
|
description={`${post.frontmatter.title}`}
|
||||||
label={post.frontmatter.category || 'Blog'}
|
label={post.frontmatter.category || 'Blog'}
|
||||||
image={base64Image || featuredImage}
|
image={base64Image || featuredImage || bg}
|
||||||
|
logo={logo}
|
||||||
/>,
|
/>,
|
||||||
{
|
{
|
||||||
...OG_IMAGE_SIZE,
|
...OG_IMAGE_SIZE,
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { ImageResponse } from 'next/og';
|
import { ImageResponse } from 'next/og';
|
||||||
import { getTranslations } from 'next-intl/server';
|
import { getTranslations } from 'next-intl/server';
|
||||||
import { OGImageTemplate } from '@/components/OGImageTemplate';
|
import { OGImageTemplate } from '@/components/OGImageTemplate';
|
||||||
import { getOgFonts, OG_IMAGE_SIZE } from '@/lib/og-helper';
|
import { getOgFonts, getOgBackground, getOgLogo, OG_IMAGE_SIZE } from '@/lib/og-helper';
|
||||||
|
|
||||||
export const size = OG_IMAGE_SIZE;
|
export const size = OG_IMAGE_SIZE;
|
||||||
export const contentType = 'image/png';
|
export const contentType = 'image/png';
|
||||||
@@ -11,9 +11,17 @@ export default async function Image({ params }: { params: Promise<{ locale: stri
|
|||||||
const { locale } = await params;
|
const { locale } = await params;
|
||||||
const t = await getTranslations({ locale, namespace: 'Blog.meta' });
|
const t = await getTranslations({ locale, namespace: 'Blog.meta' });
|
||||||
const fonts = await getOgFonts();
|
const fonts = await getOgFonts();
|
||||||
|
const bg = getOgBackground();
|
||||||
|
const logo = getOgLogo();
|
||||||
|
|
||||||
return new ImageResponse(
|
return new ImageResponse(
|
||||||
<OGImageTemplate title={t('title')} description={t('description')} label="Blog" />,
|
<OGImageTemplate
|
||||||
|
title="Die Experten für Kabelnetzbau"
|
||||||
|
description={t('title')}
|
||||||
|
label="Blog"
|
||||||
|
image={bg}
|
||||||
|
logo={logo}
|
||||||
|
/>,
|
||||||
{
|
{
|
||||||
...OG_IMAGE_SIZE,
|
...OG_IMAGE_SIZE,
|
||||||
fonts,
|
fonts,
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { ImageResponse } from 'next/og';
|
import { ImageResponse } from 'next/og';
|
||||||
import { getTranslations } from 'next-intl/server';
|
import { getTranslations } from 'next-intl/server';
|
||||||
import { OGImageTemplate } from '@/components/OGImageTemplate';
|
import { OGImageTemplate } from '@/components/OGImageTemplate';
|
||||||
import { getOgFonts, OG_IMAGE_SIZE } from '@/lib/og-helper';
|
import { getOgFonts, getOgBackground, getOgLogo, OG_IMAGE_SIZE } from '@/lib/og-helper';
|
||||||
|
|
||||||
export const size = OG_IMAGE_SIZE;
|
export const size = OG_IMAGE_SIZE;
|
||||||
export const contentType = 'image/png';
|
export const contentType = 'image/png';
|
||||||
@@ -11,12 +11,22 @@ export default async function Image({ params }: { params: Promise<{ locale: stri
|
|||||||
const { locale } = await params;
|
const { locale } = await params;
|
||||||
const t = await getTranslations({ locale, namespace: 'Contact' });
|
const t = await getTranslations({ locale, namespace: 'Contact' });
|
||||||
const fonts = await getOgFonts();
|
const fonts = await getOgFonts();
|
||||||
|
const bg = getOgBackground();
|
||||||
|
const logo = getOgLogo();
|
||||||
|
|
||||||
const title = t('meta.title') || t('title');
|
let title = t('meta.title') || t('title');
|
||||||
const description = t('meta.description') || t('subtitle');
|
if (title.startsWith('E-TIB GmbH | ')) {
|
||||||
|
title = title.substring('E-TIB GmbH | '.length);
|
||||||
|
}
|
||||||
|
|
||||||
return new ImageResponse(
|
return new ImageResponse(
|
||||||
<OGImageTemplate title={title} description={description} label="Contact" />,
|
<OGImageTemplate
|
||||||
|
title="Die Experten für Kabelnetzbau"
|
||||||
|
description={title}
|
||||||
|
label="Contact"
|
||||||
|
image={bg}
|
||||||
|
logo={logo}
|
||||||
|
/>,
|
||||||
{
|
{
|
||||||
...OG_IMAGE_SIZE,
|
...OG_IMAGE_SIZE,
|
||||||
fonts,
|
fonts,
|
||||||
|
|||||||
@@ -11,13 +11,9 @@ export default async function Image({ params }: { params: Promise<{ locale: stri
|
|||||||
const { locale } = await params;
|
const { locale } = await params;
|
||||||
const t = await getTranslations({ locale, namespace: 'Index.meta' });
|
const t = await getTranslations({ locale, namespace: 'Index.meta' });
|
||||||
|
|
||||||
let title = t('title');
|
let pageTitle = t('title');
|
||||||
if (title.startsWith('E-TIB GmbH | ')) {
|
if (pageTitle.startsWith('E-TIB GmbH | ')) {
|
||||||
title = title.substring('E-TIB GmbH | '.length);
|
pageTitle = pageTitle.substring('E-TIB GmbH | '.length);
|
||||||
}
|
|
||||||
let description = t('description');
|
|
||||||
if (description.length > 160) {
|
|
||||||
description = description.substring(0, 160) + '...';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const fonts = await getOgFonts();
|
const fonts = await getOgFonts();
|
||||||
@@ -26,8 +22,8 @@ export default async function Image({ params }: { params: Promise<{ locale: stri
|
|||||||
|
|
||||||
return new ImageResponse(
|
return new ImageResponse(
|
||||||
<OGImageTemplate
|
<OGImageTemplate
|
||||||
title={title}
|
title="Die Experten für Kabelnetzbau"
|
||||||
description={description}
|
description={pageTitle}
|
||||||
label="Kabelnetzbau & Infrastruktur"
|
label="Kabelnetzbau & Infrastruktur"
|
||||||
image={bg}
|
image={bg}
|
||||||
logo={logo}
|
logo={logo}
|
||||||
|
|||||||
@@ -120,12 +120,12 @@ export function OGImageTemplate({
|
|||||||
{/* Title */}
|
{/* Title */}
|
||||||
<div
|
<div
|
||||||
style={{
|
style={{
|
||||||
fontSize: title.length > 35 ? '64px' : '76px',
|
fontSize: '72px',
|
||||||
fontWeight: 700,
|
fontWeight: 700,
|
||||||
color: 'white',
|
color: 'white',
|
||||||
lineHeight: '1.1',
|
lineHeight: '1.1',
|
||||||
maxWidth: '900px',
|
maxWidth: '900px',
|
||||||
marginBottom: '32px',
|
marginBottom: '24px',
|
||||||
display: 'flex',
|
display: 'flex',
|
||||||
letterSpacing: '-0.02em',
|
letterSpacing: '-0.02em',
|
||||||
}}
|
}}
|
||||||
@@ -137,11 +137,14 @@ export function OGImageTemplate({
|
|||||||
{description && (
|
{description && (
|
||||||
<div
|
<div
|
||||||
style={{
|
style={{
|
||||||
fontSize: '32px',
|
fontSize: '36px',
|
||||||
color: 'rgba(255,255,255,0.8)',
|
color: 'rgba(255,255,255,0.85)',
|
||||||
maxWidth: '850px',
|
maxWidth: '850px',
|
||||||
lineHeight: '1.45',
|
lineHeight: '1.4',
|
||||||
display: 'flex',
|
display: '-webkit-box',
|
||||||
|
WebkitLineClamp: 3,
|
||||||
|
WebkitBoxOrient: 'vertical',
|
||||||
|
overflow: 'hidden',
|
||||||
fontWeight: 400,
|
fontWeight: 400,
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
|
|||||||
Reference in New Issue
Block a user