Skip to content
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

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft

feat: next seo poc #2619

wants to merge 2 commits into from

Conversation

pedromtec
Copy link
Contributor

@pedromtec pedromtec commented Jan 21, 2025

(Don't merge!)

What's the purpose of this pull request?

This POC is an alternative to indexing search pages using server side rendering. As the search page is dynamic and we need to set the title and description based on the search term, we chose to use server side rendering as it is the most suitable for this type of situation.

Nextjs reference:

Like SSG, Server-Side Rendering (SSR) is pre-rendered, which also makes it great for SEO. Instead of being generated at build time, as in SSG, SSR's HTML is generated at request time. This is great for when you have pages that are very dynamic.
https://nextjs.org/learn-pages-router/seo/rendering-and-ranking/rendering-strategies

How it works?

We use the getServerSideProps function instead of getStaticProps. We added a cache header to the response so that it is possible to cache the return in a CDN.

How to test it?

Click on: https://sfj-bed88fe--starter.preview.vtex.app/s?q=headphone
Check if the following tags were added in the document response:

<title>headphone | FastStore</title>
<meta name="description" content="headphone: em promoção que você procura? Na {Loja} você encontra as melhores ofertas de produtos com entrega rápida. Vem!"/>

Copy link

vercel bot commented Jan 21, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Skipped Deployment
Name Status Preview Updated (UTC)
faststore-site ⬜️ Ignored (Inspect) Visit Preview Jan 23, 2025 0:06am

@@ -54,13 +55,13 @@ const useSearchParams = ({
}, [asPath, defaultSort])
}

function Page({ page: searchContentType, globalSections }: Props) {
function Page({ page: searchContentType, globalSections, searchTerm }: Props) {

Choose a reason for hiding this comment

The 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:
/fp <comment> for false positive
/ar <comment> for acceptable risk
/other <comment> for all other reasons
Alternatively, triage in Semgrep AppSec Platform to ignore the finding created by ssc-adb055b9-fed0-4d70-a57d-eb9825b09449.

Copy link

codesandbox-ci bot commented Jan 21, 2025

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

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!`}
Copy link
Member

Choose a reason for hiding this comment

The 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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The 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.

@@ -143,10 +148,16 @@ export const getStaticProps: GetStaticProps<
contentType: 'search',
})

res.setHeader(
'Cache-Control',
'public, s-maxage=300, stale-while-revalidate=31536000'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

acredito que devemos passar a adicionar tbm o stale-if-error=31536000 ou seja se tentar revalidar e der erro também servimos do stale ao inves de mostrar o erro

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants