Unknown type: svgUploadPreview. Valid types are: page, goal, array...
4 replies
Last updated: Oct 19, 2020
B
Hi all!I’m trying to install an svg inline field on Sanity Studio with
I did implement it like this in
My
Before that, I did a
in my sanity folder and restart it after that.
I don’t understant what I did wrong. Thanks for any help on this
🙂
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
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' }], }, ], };
schemas/schema.jsfile 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]), });
sanity install sanity-plugin-inline-svg
I don’t understant what I did wrong. Thanks for any help on this
🙂
Oct 19, 2020, 1:47 PM
C
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
C
(and I believe it implicitly asks you to also make
svgUploadPreviewpart of your schema types)
Oct 19, 2020, 1:55 PM
B
Ah ok ! thanks a lot Erlend ! it works !I did it like this in my
schema.jsfile 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
B
great 😄
Oct 19, 2020, 1:58 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.