-
Notifications
You must be signed in to change notification settings - Fork 63
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: next seo poc #2619
base: main
Are you sure you want to change the base?
feat: next seo poc #2619
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -1,4 +1,4 @@ | ||||||
import type { GetStaticProps } from 'next' | ||||||
import type { GetServerSideProps } from 'next' | ||||||
import { NextSeo } from 'next-seo' | ||||||
import { useRouter } from 'next/router' | ||||||
import { useMemo } from 'react' | ||||||
|
@@ -26,6 +26,7 @@ import { getPage, SearchContentType } from 'src/server/cms' | |||||
type Props = { | ||||||
page: SearchContentType | ||||||
globalSections: GlobalSectionsData | ||||||
searchTerm: string | ||||||
} | ||||||
|
||||||
export interface SearchPageContextType { | ||||||
|
@@ -54,13 +55,13 @@ const useSearchParams = ({ | |||||
}, [asPath, defaultSort]) | ||||||
} | ||||||
|
||||||
function Page({ page: searchContentType, globalSections }: Props) { | ||||||
function Page({ page: searchContentType, globalSections, searchTerm }: Props) { | ||||||
const { settings } = searchContentType | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Risk: Affected versions of next are vulnerable to Acceptance of Extraneous Untrusted Data With Trusted Data / Authorization Bypass Through User-Controlled Key. Fix: Upgrade this library to at least version 13.5.7 at faststore/yarn.lock:13689. Reference(s): GHSA-gp8f-8m3g-qvj9, CVE-2024-46982 💬 To ignore this, reply with: |
||||||
const applySearchState = useApplySearchState() | ||||||
const searchParams = useSearchParams({ | ||||||
sort: settings?.productGallery?.sortBySelection as SearchState['sort'], | ||||||
}) | ||||||
|
||||||
console.log({ searchTerm }) | ||||||
const title = 'Search Results' | ||||||
const { description, titleTemplate } = storeConfig.seo | ||||||
const itemsPerPage = settings?.productGallery?.itemsPerPage ?? ITEMS_PER_PAGE | ||||||
|
@@ -78,8 +79,8 @@ function Page({ page: searchContentType, globalSections }: Props) { | |||||
{/* SEO */} | ||||||
<NextSeo | ||||||
noindex | ||||||
title={title} | ||||||
description={description} | ||||||
title={`${searchTerm}`} | ||||||
description={`${searchTerm}: em promoção que você procura? Na Americanas você encontra as melhores ofertas de produtos com entrega rápida. Vem!`} | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
titleTemplate={titleTemplate} | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. dúvida, esse conteúdo aqui o merchant consegue customizar no repositorio dele sem reescrever toda a pagina? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Em teoria sim, mas preciso validar. Pretendo mudar isso no código antes de mergear. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. acho que aqui podemos fazer algo similar ao que o NextSeo faz com title e titleTemplate para tornar dinâmico, mas adaptando para description (e criando um desciptionTemplate) com replace. templateDescription.replace(/%s/g, () => updatedDescription); |
||||||
openGraph={{ | ||||||
type: 'website', | ||||||
|
@@ -114,11 +115,14 @@ function Page({ page: searchContentType, globalSections }: Props) { | |||||
) | ||||||
} | ||||||
|
||||||
export const getStaticProps: GetStaticProps< | ||||||
export const getServerSideProps: GetServerSideProps< | ||||||
Props, | ||||||
Record<string, string>, | ||||||
Locator | ||||||
> = async ({ previewData }) => { | ||||||
> = async (context) => { | ||||||
const { previewData, query } = context | ||||||
|
||||||
const searchTerm = query.q as string | ||||||
const globalSections = await getGlobalSectionsData(previewData) | ||||||
|
||||||
if (storeConfig.cms.data) { | ||||||
|
@@ -133,7 +137,7 @@ export const getStaticProps: GetStaticProps< | |||||
}) | ||||||
|
||||||
return { | ||||||
props: { page: pageData, globalSections }, | ||||||
props: { page: pageData, globalSections, searchTerm }, | ||||||
} | ||||||
} | ||||||
} | ||||||
|
@@ -147,6 +151,7 @@ export const getStaticProps: GetStaticProps< | |||||
props: { | ||||||
page, | ||||||
globalSections, | ||||||
searchTerm, | ||||||
}, | ||||||
} | ||||||
} | ||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
question: should it be optional? or receive a default value in line 58?