-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d732ce2
commit 0fc83c8
Showing
9 changed files
with
69 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import { defineField } from 'sanity'; | ||
import { toPlainText } from '../../utils/to-plain-text'; | ||
|
||
const name = 'Faq'; | ||
const title = 'Sekcja FAQ'; | ||
const icon = () => '❓'; | ||
|
||
export default defineField({ | ||
name, | ||
type: 'object', | ||
title, | ||
icon, | ||
fields: [ | ||
defineField({ | ||
name: 'heading', | ||
type: 'Heading', | ||
title: 'Heading', | ||
validation: Rule => Rule.required(), | ||
}), | ||
defineField({ | ||
name: 'items', | ||
type: 'array', | ||
title: 'Items', | ||
of: [ | ||
defineField({ | ||
name: 'item', | ||
type: 'reference', | ||
to: [{ type: 'Faq_Collection' }], | ||
options: { | ||
filter: ({ parent }) => { | ||
const selectedIds = (parent as { _ref?: string }[])?.filter(item => item._ref).map(item => item._ref) || []; | ||
if (selectedIds.length > 0) { | ||
return { | ||
filter: '!(_id in $selectedIds)', | ||
params: { selectedIds } | ||
} | ||
} | ||
return {} | ||
} | ||
} | ||
}), | ||
], | ||
validation: Rule => Rule.required().unique(), | ||
}), | ||
defineField({ | ||
name: 'img', | ||
type: 'image', | ||
title: 'Image', | ||
validation: Rule => Rule.required(), | ||
}), | ||
], | ||
preview: { | ||
select: { | ||
heading: 'heading', | ||
media: 'img', | ||
}, | ||
prepare: ({ heading, media }) => ({ | ||
title: title, | ||
subtitle: toPlainText(heading), | ||
media: media || icon, | ||
}), | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters