2.6 KiB
2.6 KiB
Implementer — F-015 SEO core: structured data, sitemap, redirects
Summary
Implemented SEO core for the storefront catalog and added the missing public brand listing needed by sitemap generation.
Backend changes
- Added
BrandRepository.list()andListBrandsuse case. - Added public
GET /brandsroute returning{ items: [...] }in stablename ASC, id ASCorder. - The endpoint is read-only and public, matching existing public
/marca/:slugbehavior.
Storefront SEO changes
- Added
project/storefront/src/lib/seo/json-ld.tsx:- Organization JSON-LD.
- Product JSON-LD.
- BreadcrumbList JSON-LD.
- Safe JSON-LD script rendering with
<escaped.
- Added Organization JSON-LD and root canonical/OpenGraph metadata in
layout.tsx. - Added Product + Breadcrumb JSON-LD to
/productos/[slug]. - Added Breadcrumb JSON-LD to
/categoria/[slug]and/marca/[slug]. - Added
sitemap.xmlmetadata route:- Static public routes:
/,/products/search. - Active products through
searchProducts()pagination; backend search enforcesactiveOnly = true, excluding draft content. - Category URLs from flattened
listCategoryTree(). - Brand URLs from new
listBrands(). - API failures degrade to static URLs instead of failing the build.
- Static public routes:
- Added
robots.txtmetadata route allowing public crawl, disallowing/api/, and pointing to sitemap. - Added redirect store and proxy:
project/storefront/src/lib/seo/redirects.tsdefinesRedirectRepositoryand env-backed parser.project/storefront/src/proxy.tsreturns HTTP 301 for configured same-origin local path redirects.REDIRECTS_JSONaccepts an array like[{ "from": "/old", "to": "/new" }].- Parser rejects external URLs, protocol-relative URLs and self-redirects.
Documentation
- Updated
project/README.mdwith:- Public
GET /brandsroute. - JSON-LD coverage.
sitemap.xml/robots.txtbehavior.REDIRECTS_JSONredirect format.
- Public
Evidence
cd project/storefront && npm run lint— PASS.cd project/storefront && npm run typecheck— PASS.cd project/storefront && npm run build— PASS. Build output includes/robots.txt,/sitemap.xml, and Proxy.cd project && npm run lint— PASS.cd project && npm run typecheck— PASS.cd project && npm test— PASS: 17 passed, 7 skipped; 64 assertions passed, 33 skipped../scripts/verify.sh— PASS.
Notes
- No new dependency was added.
- No hreflang or external SEO tooling integration was added, per scope.
- Google/Lighthouse online validators were not available in this environment; validation is structural plus Next build/typecheck evidence.