Unlock seamless workflows and faster delivery with our latest releases - Join the deep dive

Issue with Tags plugin installation and usage in Sanity.io Studio

7 replies
Last updated: Oct 14, 2022
I’m using the Tags plugin and having issues when trying to install and run the studio. Wondering if anyone else is having this issue or understands how to utilize an appropriate loader. Thanks!

Error in ./node_modules/@floating-ui/dom/dist/floating-ui.dom.esm.js

Module parse failed: Unexpected token (306:11)
You may need an appropriate loader to handle this file type.
Oct 13, 2022, 3:31 PM
Hey
user B
! What method did you use for installing the plugin? Can you share examples of where you're using it in your code?
Oct 13, 2022, 5:56 PM
Hi
user M
thanks! I used the docs for install (so “sanity install tags” within the studio) and then I’m using the tag within a document schema which I then query. I suspect it has to do with the npm install but I’ve gone through and still can’t quite track the culprit. I do know that when I remove the plugin everything is working fine though so I suppose it might be that floating-ui dependency?

project.js document schema

import { ComponentIcon } from '@sanity/icons'
import sanityClient from 'part:@sanity/base/client'

const client = sanityClient.withConfig({ apiVersion: '2021-03-25' })

import {
  orderRankField,
  orderRankOrdering,
} from '@sanity/orderable-document-list';

import { getIcon } from './project-filter'

export default {
  name: 'project',
  title: 'Project',
  type: 'document',
  icon: ComponentIcon,
  orderings: [orderRankOrdering],
  groups: [
    {
      name: 'gallery',
      title: 'Gallery'
    },
    {
      name: 'seo',
      title: 'SEO'
    }
  ],
  fields: [
    orderRankField({ type: 'project' }),
    // Title
    {
      name: 'title',
      title: 'Title',
      type: 'string',
      validation: Rule => Rule.required()
    },
    // Slug
    {
      name: 'slug',
      type: 'slug',
      options: {
        source: async doc => {
          if (!doc.client) {
            return doc.title;
          }
          const clientTitle = await client.fetch(`*[_id == "${doc.client._ref}"][0].title`)
          return `${clientTitle}-${doc.title}`;
        }
      }
    },
    // Year
    {
      name: 'year',
      title: 'Year',
      type: 'date',
      options: {
        dateFormat: 'YYYY',
        calendarTodayLabel: 'Today'
      }
    },
    // Project Type
    {
      title: 'Project Type',
      name: 'projectType',
      type: 'string',
      options: {
        layout: 'radio',
        list: [
          { title: 'Client', value: 'client' },
          { title: 'Personal', value: 'personal' },
        ]
      }
    },
    {
      name: 'client',
      type: 'reference',
      title: 'Client',
      to: [{type: 'client' }],
      hidden: ({document}) => document?.projectType != 'client'
    },
    // Tags
    {
      name: 'myTags',
      title: 'Tags',
      type: 'tags',
      options: {
        includeFromRelated: 'myTags'
      }
    },
    // Gallery
    {
      name: 'gallery',
      title: 'Gallery',
      type: 'gallery',
      group: 'gallery'
    },
    // SEO
    {
      title: 'SEO / Share Settings',
      name: 'seo',
      type: 'seo',
      group: 'seo'
    }
  ],
  preview: {
    select: {
      seoImage: 'seo.image',
      images: 'gallery.images',
      image: 'gallery.images.0',
      title: 'title',
      client: 'client.title',
      year: 'year'
    },
    prepare(selection) {
      const { seoImage, title, client, images, image, year } = selection

      return {
        media: image,
        title: title,
        subtitle: `${client ? client : ''}`
      }
    }
  }
}
Oct 13, 2022, 6:34 PM
I resolved with this: https://github.com/sanity-io/sanity/issues/2092#issuecomment-1017433178 Not sure if that’s the best thing to do, but it worked.
Oct 13, 2022, 7:12 PM
Glad you got it sorted out!
Oct 13, 2022, 9:16 PM
got bit by this today,
user B
should we open an issue on the plugin author repo?
workaround didn’t work for me
Oct 14, 2022, 3:07 AM
user D
Hi! Was your issue with the Tag plugin specifically as well?
Oct 14, 2022, 9:47 AM
Hi 🙂 Indeed it was
I wasn’t successful in using the workaround so I just removed the plugin. It’s a shame bc I really quite liked it but oh well
Oct 14, 2022, 11:52 PM

Sanity– build remarkable experiences at scale

Sanity is a modern headless CMS that treats content as data to power your digital business. Free to get started, and pay-as-you-go on all plans.

Was this answer helpful?