Skip to content

(demo-store): Refactor Seo and implement ld+json structured data [Fixed]#660

Merged
juanpprieto merged 8 commits into
2023-01from
@juanpprieto/seo-jsonld-backup
Mar 7, 2023
Merged

(demo-store): Refactor Seo and implement ld+json structured data [Fixed]#660
juanpprieto merged 8 commits into
2023-01from
@juanpprieto/seo-jsonld-backup

Conversation

@juanpprieto
Copy link
Copy Markdown
Contributor

@juanpprieto juanpprieto commented Mar 7, 2023

Replaces the prev approved PR #651

WHY are these changes introduced?

Improve the demo store Seo implementation by ensuring all routes include seo meta and structured ld+json data.

Closes first task of https://github.com/orgs/Shopify/projects/5093?pane=issue&itemId=22169300

WHAT is this pull request doing?

  • Adds a new lib utility seoPayload to help manage seo and ld+json payloads in a centralized location ~/libs/seo.server.ts
  • Consolidates seo config strategy to use loader(s).seo return instead of handle.seo
  • Adds a reference structured data implementation to all applicable routes.

seoPayload helper

// ~/libs/seo.server.ts
export const seoPayload = {
  article,
  blog,
  collection,
  home,
  listCollections,
  page,
  policies,
  policy,
  product,
  root,
};

Example implementation product route

// ~/routes/products/$productHandle.tsx
import {seoPayload} from '~/libs/seo.server';

export async function loader({request}) {
  // ... 
  const seo = seoPayload.product({
    product,
    selectedVariant,
    url: request.url,
  });
  return {product, seo}
}

similar helper for all other routes...

// ~/routes/collections/$collectionHandle.tsx
import {seoPayload} from '~/libs/seo.server';

export async function loader({request}) {
  // ... 
  const seo = seoPayload.collection({collection, url: request.url})
  return {collection, seo}
}

Replaces #651

HOW to test your changes?

  • Navigate all routes and inspect the <head> tag for title and seo meta tags as well as ld+json <script/> tags.

Checklist

  • I've read the Contributing Guidelines
  • I've considered possible cross-platform impacts (Mac, Linux, Windows)
  • I've added a changeset if this PR contains user-facing or noteworthy changes
  • I've added tests to cover my changes
  • I've added or updated the documentation

juanpprieto and others added 7 commits March 6, 2023 21:00
Co-authored-by: Matt Seccafien <matt.seccafien@shopify.com>
Co-authored-by: Matt Seccafien <matt.seccafien@shopify.com>
* Fix bug in create CLI using `--install-deps` flag

* Use flags to camel case util

* Add tests for init

---------

Co-authored-by: Matt Seccafien <462077+cartogram@users.noreply.github.com>
Co-authored-by: Matt Seccafien <462077+cartogram@users.noreply.github.com>
Co-authored-by: Matt Seccafien <462077+cartogram@users.noreply.github.com>
fix search products count
@juanpprieto juanpprieto force-pushed the @juanpprieto/seo-jsonld-backup branch from 9aca06f to 3a53aea Compare March 7, 2023 23:35
@juanpprieto juanpprieto merged commit f77b1fa into 2023-01 Mar 7, 2023
@juanpprieto juanpprieto deleted the @juanpprieto/seo-jsonld-backup branch March 7, 2023 23:49
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