File tree Expand file tree Collapse file tree
apps/sanity/schema/components
packages/shared/src/components Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -28,10 +28,9 @@ export default defineField({
2828 title : 'Tags' ,
2929 description : 'Plain text labels displayed in the animated slider.' ,
3030 hidden : ( { parent } ) => parent ?. tagsAsLinks === true ,
31- validation : Rule => Rule . custom ( ( value , context ) => {
31+ validation : Rule => Rule . custom ( ( _ , context ) => {
3232 const tagsAsLinks = ( context . parent as { tagsAsLinks ?: boolean } ) ?. tagsAsLinks ;
3333 if ( tagsAsLinks ) return true ;
34- if ( ! value || value . length < 3 ) return 'Add at least 3 tags' ;
3534 return true ;
3635 } ) ,
3736 } ) ,
@@ -41,10 +40,9 @@ export default defineField({
4140 title : 'Tags' ,
4241 description : 'Tags displayed in the animated slider. Each tag can optionally link to an internal page.' ,
4342 hidden : ( { parent } ) => parent ?. tagsAsLinks !== true ,
44- validation : Rule => Rule . custom ( ( value , context ) => {
43+ validation : Rule => Rule . custom ( ( _ , context ) => {
4544 const tagsAsLinks = ( context . parent as { tagsAsLinks ?: boolean } ) ?. tagsAsLinks ;
4645 if ( ! tagsAsLinks ) return true ;
47- if ( ! value || value . length < 3 ) return 'Add at least 3 tags' ;
4846 return true ;
4947 } ) ,
5048 of : [
Original file line number Diff line number Diff line change @@ -105,8 +105,14 @@ const {
105105 video,
106106} = Astro .props
107107
108- // Compute tags data for rendering (normalize both formats)
109- const tagsData = tagsAsLinks && linkedTags ? linkedTags : (tags ?.map ((tag ) => ({ name: tag , slug: undefined })) ?? [])
108+ // Compute tags data for rendering (normalize both formats) and drop empty items.
109+ const tagsData = (tagsAsLinks
110+ ? (linkedTags ?? [])
111+ .map ((tag ) => ({ name: tag .name ?.trim () ?? ' ' , slug: tag .slug }))
112+ .filter ((tag ) => tag .name .length > 0 )
113+ : (tags ?? [])
114+ .map ((tag ) => ({ name: tag ?.trim () ?? ' ' , slug: undefined }))
115+ .filter ((tag ) => tag .name .length > 0 ))
110116
111117const reviewUrl = _scrollToSectionId ?? googleData .url
112118
You can’t perform that action at this time.
0 commit comments