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

View File

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

View File

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

View File

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

View File

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