From 8c1365f00feb47f462941b83b580b609c7f0523c Mon Sep 17 00:00:00 2001 From: Innei Date: Tue, 24 Jun 2025 01:26:41 +0800 Subject: [PATCH] refactor: enhance Open Graph and Twitter meta tags in production handler - Updated the title in the document head to include the site configuration title for better SEO. - Modified Open Graph and Twitter meta tags to append the site configuration title to the photo ID, improving clarity and branding in social media shares. Signed-off-by: Innei --- apps/ssr/src/app/[photoId]/prod.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/apps/ssr/src/app/[photoId]/prod.ts b/apps/ssr/src/app/[photoId]/prod.ts index 0d7d7c06..2e3e34a5 100644 --- a/apps/ssr/src/app/[photoId]/prod.ts +++ b/apps/ssr/src/app/[photoId]/prod.ts @@ -1,5 +1,6 @@ import { photoLoader } from '@afilmory/data' import type { PhotoManifest } from '@afilmory/data/types' +import siteConfig from '@config' import { DOMParser } from 'linkedom' import type { NextRequest } from 'next/server' @@ -41,6 +42,7 @@ export const handler = async ( } } }) + document.head.title = `${photo.id} | ${siteConfig.title}` // Insert meta open graph tags and twitter meta tags createAndInsertOpenGraphMeta(document, photo, request) @@ -83,7 +85,7 @@ const createAndInsertOpenGraphMeta = ( const ogTags = { 'og:type': 'website', - 'og:title': photo.id, + 'og:title': `${photo.id} on ${siteConfig.title}`, 'og:description': photo.description || '', 'og:image': `${realOrigin}/og/${photo.id}`, 'og:url': `${realOrigin}/${photo.id}`, @@ -99,7 +101,7 @@ const createAndInsertOpenGraphMeta = ( // Twitter Card meta tags const twitterTags = { 'twitter:card': 'summary_large_image', - 'twitter:title': photo.id, + 'twitter:title': `${photo.id} on ${siteConfig.title}`, 'twitter:description': photo.description || '', 'twitter:image': `${realOrigin}/og/${photo.id}`, }