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

When publishing without hero, add warning to add seo image when using campain #2443 #2445

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions sanityv3/schemas/documents/page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,23 @@ export default {
type: 'imageWithAlt',
description: 'You can override the hero image as the SoMe image by uploading another image here.',
fieldset: 'metadata',
validation: (Rule: any) =>
Rule.custom((value: any, context: any) => {
const isCampaign = context.document.isCampaign
const heroImage = context.document.heroImage

if (isCampaign && !heroImage && !value) {
return 'Please add an image to Open Graph Image when not using a header image'
}

return true
}).warning(),
},
...sharedHeroFields,
{
title: 'Is Campain',
title: 'Is Campaign',
name: 'isCampaign',
description: 'Set this to true if the page should be treated as campaign. the header title h1 will be hidden.',
description: 'Set this to true if the page should be treated as a campaign. The header title h1 will be hidden.',
type: 'boolean',
},
{
Expand Down
Loading