refactor: refactor og-related components

This commit is contained in:
jinhojang6 2023-08-30 21:37:08 +09:00
parent c151be526c
commit 7eff12b7d8
5 changed files with 10 additions and 8 deletions

View File

@ -39,6 +39,7 @@ export default function SEO({
image?.alt && ogSearchParams.set('alt', image?.alt || '')
contentType && ogSearchParams.set('contentType', contentType)
date && ogSearchParams.set('date', date || '')
pagePath && ogSearchParams.set('pagePath', pagePath || '')
const ogUrl = `${imageUrl}?${ogSearchParams.toString()}`
@ -62,11 +63,7 @@ export default function SEO({
<meta name="twitter:card" content="summary_large_image" />
<meta name="twitter:url" content={pageURL ?? `${SITE_URL}${pagePath}`} />
<meta name="twitter:site" content="@TWITTERHANDLE" />
{image ? (
<meta name="twitter:image" content={image.url} />
) : (
<meta property="twitter:image" content={imageUrl} />
)}
<meta property="twitter:image" content={ogUrl} />
<link rel="canonical" href={`${SITE_URL}${pagePath}`} />
</Head>
)

View File

@ -11,6 +11,7 @@ const NotFoundPage = () => {
description={'Description'}
imageUrl={undefined}
tags={[]}
pagePath={`/404`}
/>
<NotFound />
</>

View File

@ -32,6 +32,7 @@ const Page: CustomNextPage<PageProps> = ({
'Logos online publishing and blogging platform for writers and readers.'
}
title={`${data.page.title} - Logos Press Engine`}
pagePath={`/${data.page.slug}`}
/>
<StaticPage data={data} />
</>

View File

@ -21,10 +21,12 @@ export default async function handler(request: NextRequest) {
).then((res) => res.arrayBuffer())
const searchParams = new URL(href).searchParams
const title = searchParams.get('title') || 'LOGOS→PRESS ENGINE'
const contentType = searchParams.get('contentType')
const title =
contentType == null ? 'LOGOS→PRESS ENGINE' : searchParams.get('title')
const image = searchParams.get('image') || ''
const alt = searchParams.get('alt') || ''
const contentType = searchParams.get('contentType')
const pagePath = searchParams.get('pagePath') || '/'
const date = searchParams.get('date')
const imgSrc = image
@ -120,7 +122,7 @@ export default async function handler(request: NextRequest) {
fontFamily: 'Inter',
}}
>
<p>{contentType ?? '/'}</p>
<p>{contentType ?? pagePath}</p>
{date && <p></p>}
{date && <p>{`${day} ${month} ${year}`}</p>}
</div>

View File

@ -90,6 +90,7 @@ export default function SearchPage({ topics, shows }: SearchPageProps) {
'Logos online publishing and blogging platform for writers and readers.'
}
title={'Logos Press Engine'}
pagePath={`/search`}
/>
<SearchBox
tags={topics}