Structured Content 2022: Join our conference to explore fresh perspectives on content and digital experiences →

Unknown type: svgUploadPreview. Valid types are: page, goal, array...

4 replies
Last updated: Oct 19, 2020

Hi all!I’m trying to install an svg inline field on Sanity Studio with

sanity-plugin-inline-svg
(https://npm.io/package/sanity-plugin-inline-svg ) but I’m getting this error :
goal documentfields<unnamed_type_@_index_0> svgUploadPreview
ERROR
Unknown type: svgUploadPreview. Valid types are: page, goal, array, block, boolean, datetime, date, document, email, file, geopoint, image, number, object, reference, slug, string, telephone, text and url
I did implement it like this in
schemas/goal.js
:
import { GiArcheryTarget as icon } from 'react-icons/gi';
import svgUploadPreview from 'sanity-plugin-inline-svg';

export default {
  name: 'goal',
  title: 'Objectifs',
  type: 'document',
  icon,
  fields: [
    {
      name: 'svgUpload',
      title: 'Icône',
      type: 'svgUploadPreview',
    },
    {
      name: 'title',
      title: 'Titre',
      type: 'string',
    },
    {
      name: 'list',
      title: 'Liste de capacités',
      type: 'array',
      of: [{ type: 'string' }],
    },
  ],
};
My
schemas/schema.js
file is like this :
import createSchema from 'part:@sanity/base/schema-creator';
import schemaTypes from 'all:part:@sanity/base/schema-type';

import page from './page';
import goal from './goal';

export default createSchema({
  name: 'default',
  types: schemaTypes.concat([page, goal]),
});
Before that, I did a

sanity install sanity-plugin-inline-svg
in my sanity folder and restart it after that.

I don’t understant what I did wrong. Thanks for any help on this
🙂

Oct 19, 2020, 1:47 PM

According to the README, you must import into your schema.js file:

import svgUploadPreview from 'sanity-plugin-inline-svg';

Oct 19, 2020, 1:52 PM

(and I believe it implicitly asks you to also make

svgUploadPreview
part of your schema types)

Oct 19, 2020, 1:55 PM

Ah ok ! thanks a lot Erlend ! it works !I did it like this in my

schema.js
file indeed :
import createSchema from 'part:@sanity/base/schema-creator';
import schemaTypes from 'all:part:@sanity/base/schema-type';
import svgUploadPreview from 'sanity-plugin-inline-svg';

import page from './page';
import goal from './goal';

export default createSchema({
  name: 'default',
  types: schemaTypes.concat([page, goal, svgUploadPreview]),
});

Oct 19, 2020, 1:58 PM

great 😄

Oct 19, 2020, 1:58 PM

Sanity.io: Get the most out of your content

Sanity.io is a platform to build websites and applications. It comes with great APIs that let you treat content like data. Give your team exactly what they need to edit and publish their content with the customizable Sanity Studio. Get real-time collaboration out of the box. Sanity.io comes with a hosted datastore for JSON documents, query languages like GROQ and GraphQL, CDNs, on-demand asset transformations, presentation agnostic rich text, plugins, and much more.

Don't compromise on developer experience. Join thousands of developers and trusted companies and power your content with Sanity.io. Free to get started, pay-as-you-go on all plans.