Content Lake (Datastore)

The Vision Plugin

Sanity Studio Update: Save Vision Query Results, Custom Components with Intent Handling, and bugfixes

v3.42.0

Install or upgrade Sanity Studio

To initiate a new Sanity Studio project or upgrade an existing one, please refer to our comprehensive guide on Installing and Upgrading Sanity Studio.

If you are updating from a version earlier than 3.37.0, you should also check out this article to ensure your dependencies are up to date.

✨ Highlights

Save Vision Query Results

You can now conveniently save the results of your Sanity Vision queries as JSON or CSV files. Simply run your query and click on the new "save result as" buttons in the bottom right corner.

Custom Components with Intent Handling in Structure Builder

Custom components included in the Structure Builder (like S.component(MyCustomComponent)) can now handle intents. This is especially useful for routing to custom components from global search results or other links. You can achieve this by using the canHandleIntent parameter.

S.listItem()
  .id('translate')
  .title('Translate Test')
  .child(S.component(TranslateExample).id('example')
    .canHandleIntent((intent, params, context) =>  {
      console.log(intent, params, context)
      return true
    }
  ))

🐛 Notable Bugfixes

  • Fixes an issue where Boolean inputs were not always clearly indicated as read-only and disabled.
  • Makes the search/filter in the document "Inspect" dialog case-insensitive.
  • Prevents inputs within the Portable Text Editor from calling element.onFocus() on any opened block or inline-object, thus avoiding unintended modal closures.
  • Prevents extra work on preview prepare functions, ensuring better performance.
  • Fixes miscellaneous bugs and performance issues with Portable Text Editor's block extras and highlight rendering. For example, pointer events are now correctly disabled to avoid unnecessary cursor changes or rendering thrashes.
  • Fixes an issue where the document history panel would appear to load indefinitely

New Help & Resources menu, Vision update

v3.14.0

Installation and upgrading

To initiate a new Studio without installing the CLI globally:

npm create sanity@latest

To upgrade a v3 Studio, run this command in its folder:

npm install sanity@latest

✨ Highlights

Support for Perspectives in Vision

Illustrative

Coinciding with today's studio release, we're bringing support for trying out Perspectives in the vision plugin.

With Perspectives, you can add a single parameter to fetch a either the latest draft (previewDrafts) or latest published (published) version of a document.

To learn more about Perspectives, read our announcement post or our documentation.

New Help & Resources menu

We've consolidated some helpful resources to customize the Studio experience, learn more about our latest updates, and connect with our team. You can also compare your current Studio version to the latest version available.

Shows the new menu item described in the text

New GROQ functions and versioning

v2021-03-25

This release targeting v2021-03-25 and v2021-10-21 of the Content Lake brings several new function namespaces to GROQ, as well as introduces the first formalized version of the GROQ language specification.

New GROQ functions

There are three new namespaces for functions added to the specification, which have been implemented across all GROQ tooling. These are:

array:: functions: Perform array operations on lists, such as removing all null values, building text strings from a list of names, or generating a list of all unique document _types.

  • array::compact(<array>) - removes all null values from an array
  • array::join(<array>, <token>) - concatenates all array elements into one string, separated by a specified token.
  • array::unique(<array>) - removes duplicate values from an array (this works for values that can be compared for equality, specifically numbers, strings, booleans, and null, and will not work for values that are arrays or objects)

math:: functions: Run common mathematical operators on numeric values. For example, you can add the prices across multiple products or return the maximum discount available within a cart of products.

  • math::avg(<array-of-numbers>) - calculates the average value (arithmetic mean) of an array of numbers.
  • math::max(<array-of-numbers>) - returns the largest numeric value of an array of numbers.
  • math::min(<array-of-numbers>) - returns the smallest numeric value of an array of numbers.
  • math::sum(<array-of-numbers>) - calculates the sum of an array of numbers.

string:: functions: Manipulate text or validate that information matches a given prefix. For example, get a list of the articles that start with “How to” or split a comma-separated string of author names into an array.

  • string::split(<string>, <delimiter-token>) - turns a string into an array of substrings based on a delimiting token.
  • string::startsWith(<string>, <string-pattern>) - checks if a prefix string exactly matches the start of another string.

To learn all about the new GROQ functions, read the developer update accompanying this release, and visit our documentation.

GROQ1.revision1

With this release, we are also pleased to announce the formal language specification of GROQ, as well as a new versioning scheme. Taking inspiration from other well-known language specs, like HTML and SQL, we settled on the following format:

GROQ-<major version #>.revision<#>

The current version of the specification is GROQ-1.revision1. This version does not include any breaking changes. To learn more about the history and future of the GROQ language, read the blog post from Co-founder and CTO Simen Svale Skogsrud: Content is Queryable: (Re)Introducing GROQ.