{"query":"*[\n  _type == \"post\" \u0026\u0026\n  count(authors) \u003e 1 \u0026\u0026\n  authors[1]-\u003ename match \"Espen\"\n]","result":[{"seo":{"_type":"seo-tools","focus_keyword":"initial values"},"_type":"post","_updatedAt":"2026-04-15T12:44:55Z","text":[{"_type":"block","children":[{"_type":"span","marks":[],"text":"With the newest version of Sanity Studio, you can now set ","_key":"c0d3550da7d50"},{"text":"initial values","_key":"c0d3550da7d51","_type":"span","marks":["em"]},{"_key":"c0d3550da7d52","_type":"span","marks":[],"text":" for all your document types. It’s a great way to save your editors time and effort spent on repetitive tasks. Initial Values lets you do things like:"}],"markDefs":[],"style":"normal","_key":"c0d3550da7d5"},{"_key":"cf12ec4f17c0","_type":"block","children":[{"text":"Start a new blog post with the current time as the publish date.","_key":"cf12ec4f17c00","_type":"span","marks":[]}],"level":1,"listItem":"bullet","markDefs":[],"style":"normal"},{"style":"normal","_key":"42b9495513e8","_type":"block","children":[{"_key":"42b9495513e80","_type":"span","marks":[],"text":"Make sure that a certain category is set for all new projects in a portfolio."}],"level":1,"listItem":"bullet","markDefs":[]},{"_type":"block","children":[{"text":"Record your geolocation when you create a new report for your scientific intranet.","_key":"4bb69759135e0","_type":"span","marks":[]}],"level":1,"listItem":"bullet","markDefs":[],"style":"normal","_key":"4bb69759135e"},{"listItem":"bullet","markDefs":[],"style":"normal","_key":"c904efe06d1d","_type":"block","children":[{"_key":"c904efe06d1d0","_type":"span","marks":[],"text":"Create a selection of product types to choose from, with different currencies and shipment methods predefined for your e-commerce platform."}],"level":1},{"_key":"dddfff6187ef","_type":"block","children":[{"marks":[],"text":"Pretty much set any initial value for any field to anything you would want it to be.","_key":"dddfff6187ef0","_type":"span"}],"level":1,"listItem":"bullet","markDefs":[],"style":"normal"},{"_key":"fe738a4f22f4","_type":"block","children":[{"text":"To try it out Initial Values, upgrade your Sanity Studio by running this command in the studio folder:","_key":"fe738a4f22f40","_type":"span","marks":[]}],"markDefs":[],"style":"normal"},{"language":"sh","_key":"ea986e6e1f44","_type":"code","code":"\u003e sanity upgrade"},{"_key":"d582ba60ca47","_type":"block","children":[{"marks":[],"text":"Now you can explore the ","_key":"d582ba60ca470","_type":"span"},{"_type":"span","marks":["84ce2d622b43"],"text":"documentation","_key":"d582ba60ca471"},{"_key":"d582ba60ca472","_type":"span","marks":[],"text":" and the new "},{"marks":["9457dff579d6"],"text":"guide","_key":"d582ba60ca473","_type":"span"},{"text":" to learn how to get started.","_key":"d582ba60ca474","_type":"span","marks":[]}],"markDefs":[{"_ref":"ac9c28a6-0b53-4815-90f4-37cf0a691fe6","_type":"internalLink","_key":"84ce2d622b43"},{"_key":"9457dff579d6","_type":"link","href":"https://www.sanity.io/guides/getting-started-with-initial-values-for-new-documents"}],"style":"normal"},{"_key":"bb1dbfda1feb","_type":"muxVideo","asset":{"_ref":"ddb431ec-df5f-4417-9b38-060e8a680d08"}},{"_key":"c53fa660e1da","_type":"block","children":[{"marks":["em"],"text":"Video: How to set the initial value for a new project document.","_key":"c53fa660e1da0","_type":"span"}],"markDefs":[],"style":"normal"},{"style":"normal","_key":"223b5c2953dd","_type":"block","children":[{"_key":"223b5c2953dd0","_type":"span","marks":[],"text":"This has been a feature we have been looking forward to shipping for quite a while. We hope it will give you the flexibility you need and perhaps some new ideas to make your editor’s day even better. If you come up with something unexpected or extra super useful, we would love to hear about it, either in our "},{"_key":"223b5c2953dd1","_type":"span","marks":["56cd99b48fed"],"text":"community slack"},{"text":", or on ","_key":"223b5c2953dd2","_type":"span","marks":[]},{"_key":"223b5c2953dd3","_type":"span","marks":["4c900857f1fe"],"text":"Twitter"},{"_key":"223b5c2953dd4","_type":"span","marks":[],"text":"."}],"markDefs":[{"href":"https://slack.sanity.io","_key":"56cd99b48fed","_type":"link"},{"_key":"4c900857f1fe","_type":"link","href":"https://twitter.com/sanity_io"}]},{"style":"h2","_key":"49f76dfd6740","_type":"block","children":[{"text":"How to Initial Values: short version","_key":"49f76dfd67400","_type":"span","marks":[]}],"markDefs":[]},{"children":[{"_type":"span","marks":[],"text":"You can get started with initial values by adding a simple configuration key in your schemas. It can take a simple object using the field names as keys with the initial values. You can also return a function if you want to calculate the initial values with JavaScript. To set the initial value for a post document with a categories array, you can do like this:","_key":"6422113584a20"}],"markDefs":[],"style":"normal","_key":"6422113584a2","_type":"block"},{"_key":"afad3a60d386","_type":"code","code":"export default {\n  name: 'post',\n  type: 'document',\n  title: 'Post',\n  initialValue: {\n    categories: ['All']\n  },\n  fields: [\n    // ... all the fields\n  ]\n}","language":"javascript"},{"style":"normal","_key":"f636c372c2b0","_type":"block","children":[{"text":"We thought it might be useful to let you return a promise too. For those times you want to get your initial values from other documents, or an external API. Initial values from promises open  some pretty powerful workflows. For example, if you want to automatically put the persons in your dataset in a list of members in a new project, you can use the Studio’s client and GROQ to fetch them, and project the data structure you need for those array items:","_key":"f636c372c2b00","_type":"span","marks":[]}],"markDefs":[]},{"code":"import client from 'part:@sanity/base/client'\n\nexport default {\n  name: 'project',\n  type: 'document',\n  title: 'Project',\n  initialValue: async () =\u003e ({\n    members: await client.fetch(`//groq\n      *[_type == \"person\"]{\n        \"_type\": \"projectMember\",\n        \"person\": {\n          \"_ref\": _id,\n          \"_type\": \"reference\"\n        }\n      }\n    `)\n  }),\n  fields: [ \n    //... all the fields\n  ]\n}","language":"javascript","_key":"38e581fe9c88","_type":"code"},{"markDefs":[],"style":"normal","_key":"c2954d430839","_type":"block","children":[{"_type":"span","marks":[],"text":"Here's a video of how that works in practice, also showing how you can extend the GROQ filter if you want more specific results:","_key":"c2954d4308390"}]},{"_type":"muxVideo","asset":{"_ref":"91d62d75-e814-41fe-88fa-e0026a9da1c1"},"_key":"9638f47c2cfa"},{"_type":"block","children":[{"marks":[],"text":"Turn it up to 11 with Initial Value Templates","_key":"6bc0b94725400","_type":"span"}],"markDefs":[],"style":"h2","_key":"6bc0b9472540"},{"children":[{"text":"With the Initial Value Templates Builder, you can make sets of configurations that your editors can choose from. Let's say your company uses Sanity for a list of employees with different roles. A basic way to use templates is to iterate over these roles, and generate different templates for the different roles:","_key":"d8aa63be4f040","_type":"span","marks":[]}],"markDefs":[],"style":"normal","_key":"d8aa63be4f04","_type":"block"},{"code":"import T from '@sanity/base/initial-value-template-builder'\n\nconst roles = [\n  {name: 'developer', title: 'Developer'},\n  {name: 'designer', title: 'Designer'},\n  {name: 'admin', title: 'Administrator'},\n  {name: 'manager', title: 'Manager'}\n]\n\nexport default [\n  ...T.defaults(),\n  ...roles.map(role =\u003e \n    T.template({\n      id: `personRole-${role.name}`,\n      title: role.title,\n      schemaType: 'person',\n      value: {\n        role: role.name\n      }\n    })\n  )\n]","language":"javascript","_key":"dc4ea4ce74be","_type":"code"},{"markDefs":[],"style":"normal","_key":"3ef61d551980","_type":"block","children":[{"_type":"span","marks":[],"text":"This configuration will then add these choices to the “New document” menu:","_key":"3ef61d5519800"}]},{"alt":"The new document selection pane","asset":{"_ref":"image-facbba70e5ba2641df741ebbffab60264dbda7f6-906x418-png","_type":"reference"},"version":"0.143.0","_key":"c1d832346da2","_type":"ui.screenshot"},{"_key":"1b7bd78c4e6c","_type":"block","children":[{"_type":"span","marks":[],"text":"We have just scratched the surface of what Initial Values can do in this blog post, ","_key":"1b7bd78c4e6c0"},{"_key":"1b7bd78c4e6c1","_type":"span","marks":["ea1b6f3bd5b4"],"text":"explore the documentation"},{"_key":"1b7bd78c4e6c2","_type":"span","marks":[],"text":" to learn about more advanced use cases."}],"markDefs":[{"_ref":"ac9c28a6-0b53-4815-90f4-37cf0a691fe6","_type":"internalLink","_key":"ea1b6f3bd5b4"}],"style":"normal"}],"publishedAt":"2019-10-24T10:00:00.000Z","authors":[{"_key":"91cc213c881b","_ref":"e170fd49-3b9c-4297-a6d9-db0dfaf083d1","_type":"reference"},{"_key":"60e95bfadfd0","_ref":"e46348b4-caa3-4cd8-ba90-bc01a69acd55","_type":"reference"},{"_type":"reference","_key":"bd3ce40cdd16","_ref":"baa74566-9d7c-4714-949f-8e3b77b6a387"}],"categories":["product"],"image":{"asset":{"_type":"reference","_ref":"image-dd933468000cf322ac6b066f19f584488b24872c-5760x3840-png"},"caption":"Cookie cutter on a green background","_type":"image"},"shortTitle":"Initial Values for Sanity Studio","title":"Boost editor workflows with our new Initial Values","websiteUrl":"https://www.sanity.io/blog/initial-values-for-sanity-studio","_rev":"OJtucO0XrfiEcQXE6kJNV6","description":[{"_type":"block","children":[{"_type":"span","marks":[],"text":"Give your editors a head start with Initial Values for Sanity Studio. Prefill fields with minimal configuration, create multiple templates for quick document creation, fetch content from external APIs and put it in new documents.","_key":"ae46a0e9891b0"}],"markDefs":[],"style":"normal","_key":"ae46a0e9891b"}],"_createdAt":"2019-10-19T20:54:41Z","slug":{"_type":"slug","current":"initial-values-for-sanity-studio"},"_id":"531ed0fc-6022-4e57-a0ea-a577303eb5fd"},{"slug":{"_type":"slug","current":"introducing-the-sanity-source-plugin-for-gridsome"},"_updatedAt":"2026-04-15T12:44:55Z","description":[{"markDefs":[],"style":"normal","_key":"74f04f70520f","_type":"block","children":[{"_key":"74f04f70520f0","_type":"span","marks":[],"text":"With our new source plugin for the Vue.js based static site generator Gridsome, you can now build fast by default websites powered by structured content. The plugin gives you fast and frugal builds. With "},{"_key":"74f04f70520f1","_type":"span","marks":["code"],"text":"watchMode"},{"text":" you get low latency real-time content previews while you develop, without having to save or publish.","_key":"74f04f70520f2","_type":"span","marks":[]}]}],"_createdAt":"2019-08-29T15:57:43Z","video":{"_type":"file"},"authors":[{"_key":"0607c82a442b","_ref":"14165126-a0fd-4e5e-96af-686d36f408e0","_type":"reference"},{"_key":"dc5f08bf5bf9","_ref":"e46348b4-caa3-4cd8-ba90-bc01a69acd55","_type":"reference"},{"_ref":"baa74566-9d7c-4714-949f-8e3b77b6a387","_type":"reference","_key":"a9fb70c75616"}],"text":[{"markDefs":[{"_type":"link","href":"https://gridsome.org/plugins/gridsome-source-sanity","_key":"65916dec73de"}],"style":"normal","_key":"0eb160a4cf80","_type":"block","children":[{"_key":"0eb160a4cf800","_type":"span","marks":[],"text":"With "},{"marks":["65916dec73de"],"text":"Sanity’s new source plugin for Gridsome","_key":"0eb160a4cf801","_type":"span"},{"marks":[],"text":", you can now build fast by default websites using structured content with the Vue.js based static site generator. It gives you fast and frugal builds, and ","_key":"0eb160a4cf802","_type":"span"},{"_type":"span","marks":["code"],"text":"watchMode","_key":"0eb160a4cf803"},{"_key":"0eb160a4cf804","_type":"span","marks":[],"text":" gives you low latency real-time content preview while you develop, without having to save or publish. Using Sanity’s GraphQL schema definitons, the plugins prevents builds from breaking even though there's no content for certain types. With Portable Text you can provide a intuitive rich text editor while using Vue-components to render all aspects of your rich text and block content. No more "},{"_type":"span","marks":["code"],"text":"v-html","_key":"0eb160a4cf805"},{"_type":"span","marks":[],"text":"!","_key":"0eb160a4cf806"}]},{"linkText":"Launch the Gridsome Starter","url":"https://www.sanity.io/create?template=sanity-io%2Fsanity-template-gridsome-blog","_key":"d29edd8ba4e5","_type":"callToAction"},{"_key":"5dbf484b5219","_type":"block","children":[{"marks":[],"text":"Gridsome is a static site generator for Vue.js. It lets you create highly performing websites with prerendered markup, which is good for SEO and the overall user experience. Building with Gridsome gives you a lot of convenient easy-to-configure features such as taxonomy pages and effortless pagination.","_key":"5dbf484b52190","_type":"span"}],"markDefs":[],"style":"normal"},{"_type":"block","children":[{"marks":[],"text":"We retrofitted Gridsome’s offical blog starter and put it on ","_key":"d2aabe8683750","_type":"span"},{"marks":["9a5335f10e39"],"text":"sanity.io/create","_key":"d2aabe8683751","_type":"span"},{"_key":"d2aabe8683752","_type":"span","marks":[],"text":". You'll be up and running in minutes with all the code in your GitHub and with Sanity Studio and the Gridsome frontend deployed on Netlify."}],"markDefs":[{"href":"https://sanity.io/create?template=sanity-io/sanity-template-gridsome-blog","_key":"9a5335f10e39","_type":"link"}],"style":"normal","_key":"d2aabe868375"},{"_key":"3e0177e62d76","_type":"block","children":[{"_type":"span","marks":[],"text":"If you already have a Gridsome project, you install the plugin from npm (","_key":"3e0177e62d760"},{"marks":["code"],"text":"$ npm i gridsome-source-sanity","_key":"3e0177e62d761","_type":"span"},{"text":"), add your Sanity project’s ","_key":"3e0177e62d762","_type":"span","marks":[]},{"_key":"3e0177e62d763","_type":"span","marks":["em"],"text":"ID"},{"_type":"span","marks":[],"text":" with the name of the ","_key":"3e0177e62d764"},{"_key":"3e0177e62d765","_type":"span","marks":["em"],"text":"dataset"},{"_key":"3e0177e62d766","_type":"span","marks":[],"text":" where your content is, make sure that you have deployed your project’s GraphQL API ("},{"_key":"3e0177e62d767","_type":"span","marks":["code"],"text":"$ sanity graphql deploy"},{"_type":"span","marks":[],"text":") and that’s it. Your content from Sanity.io will now be available via Gridsome's templating GraphQL API.","_key":"3e0177e62d768"}],"markDefs":[],"style":"normal"},{"children":[{"_key":"a73f6245e4cc0","_type":"span","marks":[],"text":"Watch the video from our online meetup where we had Gridsome’s co-founder Tommy Vedvik on. We also did a live demo of the real-time watch mode. "}],"markDefs":[],"style":"normal","_key":"a73f6245e4cc","_type":"block"},{"publishDate":"2019-06-12","url":"https://youtu.be/8w1ladpsUTI","_key":"0c622ab5b510","_type":"youtube"},{"_key":"29bebdba1828","_type":"block","children":[{"_type":"span","marks":[],"text":"How the plugin works","_key":"29bebdba18280"}],"markDefs":[],"style":"h2"},{"markDefs":[],"style":"normal","_key":"3bd7d68542bc","_type":"block","children":[{"text":"While most source plugins either connect to a REST or GraphQL endpoint, potentially firing a lot of requests on each build, Sanity’s source plugin for Gridsome will do primarily two things:","_key":"3bd7d68542bc0","_type":"span","marks":[]}]},{"children":[{"_key":"41bfc376a5b10","_type":"span","marks":[],"text":"Fetch a GraphQL SDL schema in order to map types correctly."}],"level":1,"listItem":"number","markDefs":[],"style":"normal","_key":"41bfc376a5b1","_type":"block"},{"markDefs":[],"style":"normal","_key":"deb4b4ad6e22","_type":"block","children":[{"text":"Stream ","_key":"deb4b4ad6e220","_type":"span","marks":[]},{"marks":["em"],"text":"all","_key":"deb4b4ad6e221","_type":"span"},{"text":" your available documents from the export API point in one go.","_key":"deb4b4ad6e222","_type":"span","marks":[]}],"level":1,"listItem":"number"},{"_type":"block","children":[{"_type":"span","marks":[],"text":"In order words, building a Gridsome site of any size with Sanity takes two API requests and is therefore very fast -","_key":"24932a0034800"},{"text":" certainly among the fastest ways to build with an API-based CMS","_key":"24932a0034801","_type":"span","marks":["em"]},{"_type":"span","marks":[],"text":". We fetch the GraphQL schema to avoid the type inference that may struggle with polymorphic arrays (read: block content with many different types), and to prevent type inference to break your site if some content is suddenly missing. This is also why you need to redeploy Sanity’s GraphQL API when you change your content schemas in the studio.","_key":"24932a0034802"}],"markDefs":[],"style":"normal","_key":"24932a003480"},{"style":"normal","_key":"adcaaca6c9fe","_type":"block","children":[{"text":"If you enable ","_key":"adcaaca6c9fe0","_type":"span","marks":[]},{"marks":["code"],"text":"watchMode","_key":"adcaaca6c9fe1","_type":"span"},{"_type":"span","marks":[],"text":" and ","_key":"adcaaca6c9fe2"},{"marks":["code"],"text":"overlayDrafts","_key":"adcaaca6c9fe3","_type":"span"},{"_key":"adcaaca6c9fe4","_type":"span","marks":[],"text":" in development mode, we'll actually do a third request to set up a listener. This will now subscribe to updates done within your Sanity dataset and update the internal nodes in the Gridsome API. This means that you'll get low latency level real-time updates in your frontend while you're building without having to publish content."}],"markDefs":[]},{"_key":"43f85cbfac90","_type":"muxVideo"},{"style":"normal","_key":"6dbc48acaa38","_type":"block","children":[{"marks":[],"text":"This is really convenient, and, let us be honest, we think it's really cool.","_key":"6dbc48acaa380","_type":"span"}],"markDefs":[]},{"_key":"05ba1d2fe22e","_type":"block","children":[{"_key":"05ba1d2fe22e0","_type":"span","marks":["em"],"text":"We would also like to show our gratitude to the Gridsome creators and founders "},{"_key":"05ba1d2fe22e1","_type":"span","marks":["em","cfab72c8bb88"],"text":"Tommy"},{"_key":"05ba1d2fe22e2","_type":"span","marks":["em"],"text":" and "},{"_key":"05ba1d2fe22e3","_type":"span","marks":["em","b2d267c89e6f"],"text":"Hans-Jørgen Vedvik"},{"_key":"05ba1d2fe22e4","_type":"span","marks":["em"],"text":" who have been excellent in taking feedback, fixing bugs, and providing what we needed to make this happen."}],"markDefs":[{"_key":"cfab72c8bb88","_type":"link","href":"https://twitter.com/tommyvedvik"},{"href":"https://twitter.com/hjvedvik","_key":"b2d267c89e6f","_type":"link"}],"style":"normal"}],"shortTitle":"Sanity source plugin for Gridsome","_type":"post","publishedAt":"2019-09-17T22:00:00.000Z","image":{"asset":{"_type":"reference","_ref":"image-004f6a03d373557e665aab1d339bffac64fd645c-2400x1800-png"},"_type":"image","alt":"The blog starter for Gridsome"},"editorial":{"status":"ready","_type":"editorial","assignedTo":[{"_ref":"baa74566-9d7c-4714-949f-8e3b77b6a387","_type":"reference","_key":"b881e230c305"}]},"seo":{"_type":"seo-tools","focus_synonyms":["Gridsome",""]},"title":"Introducing the Sanity source plugin for Gridsome","websiteUrl":"https://www.sanity.io/blog/introducing-the-sanity-source-plugin-for-gridsome","categories":["product"],"includeInSitemap":true,"_id":"973691f0-d744-4f96-9b65-3fe08454d50f","_rev":"OJtucO0XrfiEcQXE6kJNV6"},{"slug":{"_type":"slug","current":"say-hi-to-our-new-asset-utilities-library"},"_id":"df2c4d87-ff50-4451-b783-4b72125eaf78","description":[{"_key":"783ab53a41ac","_type":"block","children":[{"_type":"span","marks":[],"text":"The new library of asset utilities makes it even more convenient to build with images and files from Sanity.io","_key":"783ab53a41ac0"}],"markDefs":[],"style":"normal"}],"title":"Say hi to our new asset utilities library!","_type":"post","text":[{"_type":"block","children":[{"text":"Sanity.io comes with a capable asset pipeline CDN. Upload a large resolution image, and request the size, crop, format, and quality you need. It will be delivered from the edge network, ensuring performance and efficiency for your application. Now we have published ","_key":"07de193caacc0","_type":"span","marks":[]},{"_type":"span","marks":["02abeb63c9f6"],"text":"a library","_key":"07de193caacc1"},{"_key":"07de193caacc2","_type":"span","marks":[],"text":" with a bunch of utility functions that is useful when building with assets from Sanity."}],"markDefs":[{"_key":"02abeb63c9f6","_type":"link","href":"https://www.npmjs.com/package/@sanity/asset-utils"}],"style":"normal","_key":"07de193caacc"},{"_key":"4a4edff2d1ee","_type":"block","children":[{"_key":"4a4edff2d1ee0","_type":"span","marks":[],"text":"It‘s perhaps not breaking news as far as product releases go. But we think the asset-utils provides some developer experience convenience and wanted to let you know about it. It’s also an example of our continued work to provide those who work with TypeScript, with the types and interfaces they need in their projects."}],"markDefs":[],"style":"normal"},{"_key":"5ebd7a47be3a","_type":"block","children":[{"text":"You add the asset utilities to your project using ","_key":"5ebd7a47be3a0","_type":"span","marks":[]},{"_key":"5ebd7a47be3a1","_type":"span","marks":["e690fec34d6b"],"text":"npm"},{"_type":"span","marks":[],"text":" or ","_key":"5ebd7a47be3a2"},{"text":"yarn","_key":"5ebd7a47be3a3","_type":"span","marks":["6961f7819b93"]},{"marks":[],"text":":","_key":"5ebd7a47be3a4","_type":"span"}],"markDefs":[{"_key":"e690fec34d6b","_type":"link","href":"https://www.npmjs.com/"},{"_key":"6961f7819b93","_type":"link","href":"https://yarnpkg.com/"}],"style":"normal"},{"code":"npm i @sanity/asset-utils\n# or\nyarn add @sanity/asset-utils","language":"text","_key":"8d05e2765635","_type":"code"},{"children":[{"marks":[],"text":"Since we wrote asset-utils in TypeScript with ","_key":"ecd751e0b79d0","_type":"span"},{"text":"TSDoc-annotations","_key":"ecd751e0b79d1","_type":"span","marks":["97a6c91100f7"]},{"_type":"span","marks":[],"text":", we could generate some comprehensive reference documentation for it as well. You can ","_key":"ecd751e0b79d2"},{"_key":"ecd751e0b79d3","_type":"span","marks":["2838832a55ff"],"text":"explore it on GitHub"},{"_type":"span","marks":[],"text":", and it should appear as helpful tool-tips and auto-complete suggestions if you are using ","_key":"ecd751e0b79d4"},{"text":"VS Code","_key":"ecd751e0b79d5","_type":"span","marks":["0f6bc5ee2a59"]},{"_key":"ecd751e0b79d6","_type":"span","marks":[],"text":" and other capable code editors."}],"markDefs":[{"_key":"97a6c91100f7","_type":"link","href":"https://microsoft.github.io/tsdoc/"},{"_type":"link","href":"https://sanity-io.github.io/asset-utils","_key":"2838832a55ff"},{"_type":"link","href":"https://code.visualstudio.com/","_key":"0f6bc5ee2a59"}],"style":"normal","_key":"ecd751e0b79d","_type":"block"},{"_key":"06794a1bee82","_type":"image","alt":"A code editor showing auto-complete for functions with documentation tooltip","asset":{"_ref":"image-4416cdc81444abcb3884f0aac6ff203a939e31d2-906x465-png","_type":"reference"},"caption":"Auto-complete and inline documentation in VS Code"},{"_key":"7c26de5bfbe7","_type":"block","children":[{"_key":"7c26de5bfbe70","_type":"span","marks":[],"text":"With the asset-utils library, you will be able to generate file URLs from its asset id and the project configuration that you have in your project. It‘s focused around taking the least information possible, and make the most useful thing out of it:"}],"markDefs":[],"style":"normal"},{"_key":"40ad9c0dc021","_type":"usageExample","example":{"language":"javascript","_type":"code","code":"import { getFile } from \"@sanity/asset-utils\";\nimport { client } from \"./client\";\n\nconst doc = {\n  _createdAt: \"2019-03-07T08:07:57Z\",\n  _id: \"mFXWUiXzYAP1MwiPjbWVJu\",\n  _rev: \"CbupMhrv0BU2npu4xq78VL\",\n  _type: \"podcast\",\n  _updatedAt: \"2019-08-23T07:40:10Z\",\n  description: \"The story behind GROQ\",\n  fileAsset: {\n    _type: \"file\",\n    asset: {\n      _ref: \"file-d19e06dcf4aff5a3eafd9d7b58c8703ea6e6b433-m4a\",\n      _type: \"reference\"\n    }\n  },\n  title: \"How GROQ became GROQ\"\n};\nconst file = getFile(doc.fileAsset, client.config());\nconsole.log(file)\n"},"inputLabel":"Build a file object from the asset id","output":{"language":"json","_type":"code","code":"{\n  \"asset\": {\n    \"_id\": \"file-d19e06dcf4aff5a3eafd9d7b58c8703ea6e6b433-m4a\",\n    \"_type\": \"sanity.fileAsset\",\n    \"assetId\": \"d19e06dcf4aff5a3eafd9d7b58c8703ea6e6b433\",\n    \"extension\": \"m4a\",\n    \"metadata\": {},\n    \"url\": \"https://cdn.sanity.io/files/zt0rapzo/production/d19e06dcf4aff5a3eafd9d7b58c8703ea6e6b433.m4a\",\n    \"path\": \"files/zt0rapzo/production/d19e06dcf4aff5a3eafd9d7b58c8703ea6e6b433.m4a\"\n  }\n}"},"outputLabel":"Outputs a file object with useful information"},{"children":[{"marks":[],"text":"If you want to learn more about Sanity’s asset pipeline, you can go to ","_key":"2fce9e3014100","_type":"span"},{"_type":"span","marks":["c1c965cbb1dd"],"text":"the post we published in CSS-tricks","_key":"2fce9e3014101"},{"marks":[],"text":" a while back, and ","_key":"2fce9e3014102","_type":"span"},{"_key":"2fce9e3014103","_type":"span","marks":["41030d04b8fd"],"text":"the documentation pages"},{"_key":"2fce9e3014104","_type":"span","marks":[],"text":"."}],"markDefs":[{"_type":"link","href":"https://css-tricks.com/five-interesting-ways-to-use-sanity-io-for-image-art-direction/","_key":"c1c965cbb1dd"},{"href":"https://www.sanity.io/docs/asset-pipeline","_key":"41030d04b8fd","_type":"link"}],"style":"normal","_key":"2fce9e301410","_type":"block"},{"_key":"2e64f9aad9b1","_type":"block","children":[{"marks":[],"text":"\nWe hope you find it helpful, and if it has been, do tell us all about it over at ","_key":"2e64f9aad9b10","_type":"span"},{"_type":"span","marks":["3e23d0d5921e"],"text":"the #i-made-this channel in our community slack","_key":"2e64f9aad9b11"},{"_key":"2e64f9aad9b12","_type":"span","marks":[],"text":"."}],"markDefs":[{"_key":"3e23d0d5921e","_type":"link","href":"https://slack.sanity.io"}],"style":"normal"}],"_createdAt":"2020-05-02T07:26:52Z","_rev":"OJtucO0XrfiEcQXE6kJNV6","categories":["product"],"publishedAt":"2020-05-02T04:00:00.000Z","websiteUrl":"https://www.sanity.io/blog/say-hi-to-our-new-asset-utilities-library","image":{"asset":{"_type":"reference","_ref":"image-711ab62f0947873e855e9d73b4d52cf221ad5342-3600x2700-png"},"_type":"image","alt":"New asset utilities library for Sanity.io"},"shortTitle":"Say hi to our new asset utilities library!","_updatedAt":"2026-04-15T12:44:55Z","authors":[{"_key":"b946a3e83884","_ref":"14165126-a0fd-4e5e-96af-686d36f408e0","_type":"reference"},{"_type":"reference","_key":"3e14f25e1567","_ref":"e46348b4-caa3-4cd8-ba90-bc01a69acd55"}]}],"ms":349}