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

UsePrismicSeoMeta #222

Open
luca-smartpricing opened this issue Oct 8, 2024 · 0 comments
Open

UsePrismicSeoMeta #222

luca-smartpricing opened this issue Oct 8, 2024 · 0 comments
Labels
enhancement New feature or request

Comments

@luca-smartpricing
Copy link

Is your feature request related to a problem? Please describe.

No, but Prismic come with an auto-generated SEO metadata tabs for page types. So, why don't create a SEO compostable that get data from useAsyncData and safely inject in useSeoMeta()?

In the slicemachine page snippet your code is:

useHead({
  title: page.value?.data.meta_title,
  meta: [
    {
      name: 'description',
      content: page.value?.data.meta_description,
    },
  ],
})

but you don't use meta_image and the correct compostable: useSeoMeta.
Having a pre made compostable wrapper would be very handy.

Something like this:

export default function ({
  metatitle,
  metadescription,
  socialtitle,
  socialdescription,
  socialimage,
}: {
  metatitle: KeyTextField
  metadescription: KeyTextField
  socialtitle: KeyTextField
  socialdescription: KeyTextField
  socialimage: LinkToMediaField
}) {
  useSeoMeta({
    title: isFilled.keyText(metatitle) ? metatitle : undefined,
    description: isFilled.keyText(metadescription)
      ? metadescription
      : undefined,
    ogTitle: isFilled.keyText(socialtitle) ? socialtitle : undefined,
    ogDescription: isFilled.keyText(socialdescription)
      ? socialdescription
      : undefined,
    twitterTitle: isFilled.keyText(socialtitle) ? socialtitle : undefined,
    twitterDescription: isFilled.keyText(socialdescription)
      ? socialdescription
      : undefined,
  })
}
@luca-smartpricing luca-smartpricing added the enhancement New feature or request label Oct 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant