Open aaadotpm opened 3 years ago
@s-g-k - does https://github.com/rosnovsky/sanity-plugin-autocomplete-tags/pull/13 solve your need?
I have the same issue as @s-g-k . I may be wrong but #13 doesn't seem to resolve our issue.
In my case I have project
object with a nested mainImage
object. And the tags are on the mainImage
.
sanity-plugin-autocomplete-tags
is not able to find the tags on mainImage
since it looks only on project
documents.
documents/project.js
export default {
name: 'project',
type: 'document',
title: 'Project',
fields: [
{
name: 'title',
type: 'string',
title: 'Title'
},
{
name: 'mainImage',
type: 'mainImage',
title: 'Main image'
}
}
objects/mainImage.js
export default {
name: 'mainImage',
type: 'image',
title: 'Image',
options: {
hotspot: true,
accept: 'image/*'
},
validation: Rule => Rule.required().error('A main image is required!'),
fields: [
{
name: 'description',
type: 'string',
title: 'Descritpion',
description: 'La description aide à optimiser le SEO',
options: {
isHighlighted: true
},
validation: Rule => Rule.error('You have to fill out the description text.').required()
},
{
name: 'tags',
title: 'Tags',
type: 'tags',
options: {
isHighlighted: true
}
}
],
preview: {
select: {
imageUrl: 'asset.url',
title: 'caption'
}
}
}
I think the plugin should recognize the type of document on which it is set so it will query sanity api on the right document and not on the parent document.
In my case, the parent document is project
and mainImage
is an object nested inside the project
document.
Thank you for this. I'll take a look over the weekend. I think I made it work with nested objects initially, but there were some quirks to work out
So sorry that this "over the weekend" turned into "by the end of this year", but I finally got some time to work on this, and hopefully will have this working, well, by the end of this year :)
Great work on this plugin, thank you!
Is your feature request related to a problem? Please describe. I'm trying to use the tags field inside an object (which will be included in several documents). Unfortunately, the plugin does not register the tags made inside for instance
metadata.tags
for reuse.Describe the solution you'd like I would like to be able to define an option of where the plugin looks for the
tags
field so that I can get autocomplete inside objects.This would also allow (although I don't have an example use case) for different sets of tags based on their document path/or field name.
For instance:
options: { tagsPath: 'metadata.tags' }
oroptions: { tagsPath: 'metadata.keywords' }
Describe alternatives you've considered Having only the tags field on the root document (this works, but is not particularly elegant)
Happy to discuss, and or contribute to this (with guidance)!