From 0dba94b72f9b617af5fe5f23106ac708020f89b3 Mon Sep 17 00:00:00 2001 From: Espen Hovlandsdal Date: Wed, 21 Dec 2022 07:05:16 -0800 Subject: [PATCH] chore: deprecate v2 modules (#3997) --- packages/@sanity/base/README.md | 6 + packages/@sanity/core/README.md | 6 + packages/@sanity/data-aspects/README.md | 7 +- packages/@sanity/default-layout/README.md | 14 +- packages/@sanity/default-login/README.md | 6 + packages/@sanity/desk-tool/README.md | 6 + packages/@sanity/field/README.md | 5 + packages/@sanity/form-builder/README.md | 77 +++++----- packages/@sanity/imagetool/README.md | 30 ++-- .../@sanity/initial-value-templates/README.md | 5 + packages/@sanity/plugin-loader/README.md | 7 + packages/@sanity/production-preview/README.md | 5 + packages/@sanity/react-hooks/README.md | 5 + packages/@sanity/resolver/README.md | 6 + packages/@sanity/server/README.md | 5 + packages/@sanity/state-router/README.md | 132 +++++++++++------- packages/@sanity/structure/README.md | 5 + packages/@sanity/studio-hints/README.md | 18 ++- .../@sanity/transaction-collator/README.md | 5 + .../@sanity/webpack-integration/README.md | 10 +- packages/@sanity/webpack-loader/README.md | 5 + 21 files changed, 253 insertions(+), 112 deletions(-) create mode 100644 packages/@sanity/initial-value-templates/README.md create mode 100644 packages/@sanity/production-preview/README.md create mode 100644 packages/@sanity/server/README.md create mode 100644 packages/@sanity/structure/README.md create mode 100644 packages/@sanity/transaction-collator/README.md create mode 100644 packages/@sanity/webpack-loader/README.md diff --git a/packages/@sanity/base/README.md b/packages/@sanity/base/README.md index 89727f60e84..1eb0a20f95c 100644 --- a/packages/@sanity/base/README.md +++ b/packages/@sanity/base/README.md @@ -1,3 +1,9 @@ +# ⚠️ THIS PACKAGE IS DEPRECATED + +> This package is part of Sanity Studio v2, which has been superseded by **Sanity Studio v3**, the current major version released on Dec 7th, 2022. This package is no longer used/needed for Sanity Studio in its current version and will be retired on Dec 7th, 2023. The core packages for Sanity Studio v2 will only receive critical bug fixes until this date. +> +> Please head over to [the documentation for Sanity Studio v3](https://www.sanity.io/docs/sanity-studio) to learn more. + # base Sanity plugin containing the base components and roles for a Sanity configuration diff --git a/packages/@sanity/core/README.md b/packages/@sanity/core/README.md index 5d042a715fe..695c589ed2f 100644 --- a/packages/@sanity/core/README.md +++ b/packages/@sanity/core/README.md @@ -1,3 +1,9 @@ +# ⚠️ THIS PACKAGE IS DEPRECATED + +> This package is part of Sanity Studio v2, which has been superseded by **Sanity Studio v3**, the current major version released on Dec 7th, 2022. This package is no longer used/needed for Sanity Studio in its current version and will be retired on Dec 7th, 2023. The core packages for Sanity Studio v2 will only receive critical bug fixes until this date. +> +> Please head over to [the documentation for Sanity Studio v3](https://www.sanity.io/docs/sanity-studio) to learn more. + # @sanity/core Sanity core bundle, containing required packages for the development and build process diff --git a/packages/@sanity/data-aspects/README.md b/packages/@sanity/data-aspects/README.md index fe5b365f81b..ea62a2ce0f7 100644 --- a/packages/@sanity/data-aspects/README.md +++ b/packages/@sanity/data-aspects/README.md @@ -1,3 +1,9 @@ +# ⚠️ THIS PACKAGE IS DEPRECATED + +> This package is part of Sanity Studio v2, which has been superseded by **Sanity Studio v3**, the current major version released on Dec 7th, 2022. This package is no longer used/needed for Sanity Studio in its current version and will be retired on Dec 7th, 2023. The core packages for Sanity Studio v2 will only receive critical bug fixes until this date. +> +> Please head over to [the documentation for Sanity Studio v3](https://www.sanity.io/docs/sanity-studio) to learn more. + # @sanity/data-aspects Sanity plugin which controls how your data is presented. @@ -6,7 +12,6 @@ Sanity plugin which controls how your data is presented. We'll re-design how control of data presentation is handed over to a sanity studio maintainer. Hang on for snake tornado. - ## Usage Ensure you have data-aspects as a plugin in you Sanity installation. Either: diff --git a/packages/@sanity/default-layout/README.md b/packages/@sanity/default-layout/README.md index 2461136baa9..8db772ec01c 100644 --- a/packages/@sanity/default-layout/README.md +++ b/packages/@sanity/default-layout/README.md @@ -1,5 +1,10 @@ -# default-layout +# ⚠️ THIS PACKAGE IS DEPRECATED + +> This package is part of Sanity Studio v2, which has been superseded by **Sanity Studio v3**, the current major version released on Dec 7th, 2022. This package is no longer used/needed for Sanity Studio in its current version and will be retired on Dec 7th, 2023. The core packages for Sanity Studio v2 will only receive critical bug fixes until this date. +> +> Please head over to [the documentation for Sanity Studio v3](https://www.sanity.io/docs/sanity-studio) to learn more. +# default-layout ## Sidecar @@ -9,13 +14,12 @@ The Sidecar will be enabled in a Studio if there is an implementations of the pa An implementation of `part:@sanity/default-layout/sidecar` _must_ export these: - - `SidecarToggleButton` React component. The button which will appear in the Navbar to toggle on/off the Sidecar - - `SidecarLayout` React component. The content of the Sidecar (once it appears) - - `isSidecarEnabled` Function. Call this to check if the Sidecar implementation is happy and good to go (typically, the sidecar impl. wants to verify if config is present) +- `SidecarToggleButton` React component. The button which will appear in the Navbar to toggle on/off the Sidecar +- `SidecarLayout` React component. The content of the Sidecar (once it appears) +- `isSidecarEnabled` Function. Call this to check if the Sidecar implementation is happy and good to go (typically, the sidecar impl. wants to verify if config is present) If you need inspiration, the `@sanity/studio-hints` package is an implementation of this part. - ### `part:@sanity/default-layout/sidecar-datastore` In addition, Sidecar relies on `part:@sanity/default-layout/sidecar-datastore`. This part already exists and shouldn't be overridden unless there's a good reason. This part exports: diff --git a/packages/@sanity/default-login/README.md b/packages/@sanity/default-login/README.md index 8295809f6ce..d8ea2494fdb 100644 --- a/packages/@sanity/default-login/README.md +++ b/packages/@sanity/default-login/README.md @@ -1,3 +1,9 @@ +# ⚠️ THIS PACKAGE IS DEPRECATED + +> This package is part of Sanity Studio v2, which has been superseded by **Sanity Studio v3**, the current major version released on Dec 7th, 2022. This package is no longer used/needed for Sanity Studio in its current version and will be retired on Dec 7th, 2023. The core packages for Sanity Studio v2 will only receive critical bug fixes until this date. +> +> Please head over to [the documentation for Sanity Studio v3](https://www.sanity.io/docs/sanity-studio) to learn more. + # @sanity/default-login Let a user log into Sanity, and get access to the child content. diff --git a/packages/@sanity/desk-tool/README.md b/packages/@sanity/desk-tool/README.md index 4df07a496f1..6c1ca0a84bc 100644 --- a/packages/@sanity/desk-tool/README.md +++ b/packages/@sanity/desk-tool/README.md @@ -1,3 +1,9 @@ +# ⚠️ THIS PACKAGE IS DEPRECATED + +> This package is part of Sanity Studio v2, which has been superseded by **Sanity Studio v3**, the current major version released on Dec 7th, 2022. This package is no longer used/needed for Sanity Studio in its current version and will be retired on Dec 7th, 2023. The core packages for Sanity Studio v2 will only receive critical bug fixes until this date. +> +> Please head over to [the documentation for Sanity Studio v3](https://www.sanity.io/docs/sanity-studio) to learn more. + # desk-tool Tool for managing all sorts of content in a structured manner diff --git a/packages/@sanity/field/README.md b/packages/@sanity/field/README.md index e69de29bb2d..384678bbe39 100644 --- a/packages/@sanity/field/README.md +++ b/packages/@sanity/field/README.md @@ -0,0 +1,5 @@ +# ⚠️ THIS PACKAGE IS DEPRECATED + +> This package is part of Sanity Studio v2, which has been superseded by **Sanity Studio v3**, the current major version released on Dec 7th, 2022. This package is no longer used/needed for Sanity Studio in its current version and will be retired on Dec 7th, 2023. The core packages for Sanity Studio v2 will only receive critical bug fixes until this date. +> +> Please head over to [the documentation for Sanity Studio v3](https://www.sanity.io/docs/sanity-studio) to learn more. diff --git a/packages/@sanity/form-builder/README.md b/packages/@sanity/form-builder/README.md index ea41907f3f9..801fb759ac0 100644 --- a/packages/@sanity/form-builder/README.md +++ b/packages/@sanity/form-builder/README.md @@ -1,3 +1,9 @@ +# ⚠️ THIS PACKAGE IS DEPRECATED + +> This package is part of Sanity Studio v2, which has been superseded by **Sanity Studio v3**, the current major version released on Dec 7th, 2022. This package is no longer used/needed for Sanity Studio in its current version and will be retired on Dec 7th, 2023. The core packages for Sanity Studio v2 will only receive critical bug fixes until this date. +> +> Please head over to [the documentation for Sanity Studio v3](https://www.sanity.io/docs/sanity-studio) to learn more. + # Form Builder ## Disclaimer: Work in progress @@ -11,14 +17,14 @@ Polymorphic arrays may only contain elements of one primitive type. Thus, this i ```json { "types": [ - { - "name": "myType", - "type": "array", - "of": [ - {"type": "string", "title": "Street"}, - {"type": "string", "title": "E-mail"} - ] - } + { + "name": "myType", + "type": "array", + "of": [ + {"type": "string", "title": "Street"}, + {"type": "string", "title": "E-mail"} + ] + } ] } ``` @@ -26,14 +32,15 @@ Polymorphic arrays may only contain elements of one primitive type. Thus, this i ## Terminology ### Type + Types are the building blocks for your schema. A type defines the structure and behavior of your data model. There is a distiction between _primitive types_ and _container types_. A container type is a type that contains data of other types, e.g. `array` or `object`. A primitive type only represents one simple value, like the number `3` or the string `foobar` - ### Field + If you define an object type, you must also define its fields. E.g. if you are defining a `person` type, it may look like this: ```json @@ -54,17 +61,19 @@ If you define an object type, you must also define its fields. E.g. if you are d ] } ``` + You cannot create an object type that has no fields. We haven't yet had the need for a `hash` type that can have arbitrary key => value pairs (where keys are strings and value can be anything), but will consider supporting it in the future. ## Input widgets All input fields must follow a simple convention based protocol. Every input field must: - - Accept a `value` prop which is the field's value - - Accept an `onChange` function as prop which is called whenever a value changes +- Accept a `value` prop which is the field's value +- Accept an `onChange` function as prop which is called whenever a value changes ## Schema + When writing a schema, `type` is implicitly `object`, unless otherwise specified. You're not allowed to set type: 'object' (redundant definition). Only built-in types can take options. Below, `email.placeholder` is an option to `string` and `versions.of` is an option to `list`. @@ -80,59 +89,57 @@ const schema = { name: 'email', type: 'string', title: 'E-mail address', - placeholder: 'murgh@example.com' + placeholder: 'murgh@example.com', }, { name: 'profilePicture', - type: 'image' - } - ] + type: 'image', + }, + ], }, { name: 'image', fields: [ { name: 'fullSizeUrl', - type: 'string' + type: 'string', }, { name: 'aspectRatio', - type: 'number' + type: 'number', }, { name: 'versions', type: 'list', - of: [{type: 'imageVersion'}] - } - ] + of: [{type: 'imageVersion'}], + }, + ], }, { name: 'imageVersion', fields: [ { name: 'width', - type: 'number' + type: 'number', }, { name: 'square', - type: 'boolean' + type: 'boolean', }, { name: 'url', - type: 'string' - } - ] - } - ] + type: 'string', + }, + ], + }, + ], } ``` - - - ## Considerations / todo - - Support for collaborative editing - - Powerful validation rules - - i18n - - List item edit modality - - Styling + +- Support for collaborative editing +- Powerful validation rules +- i18n +- List item edit modality +- Styling diff --git a/packages/@sanity/imagetool/README.md b/packages/@sanity/imagetool/README.md index 0d181642db2..44844462179 100644 --- a/packages/@sanity/imagetool/README.md +++ b/packages/@sanity/imagetool/README.md @@ -1,10 +1,15 @@ +# ⚠️ THIS PACKAGE IS DEPRECATED + +> This package is part of Sanity Studio v2, which has been superseded by **Sanity Studio v3**, the current major version released on Dec 7th, 2022. This package is no longer used/needed for Sanity Studio in its current version and will be retired on Dec 7th, 2023. The core packages for Sanity Studio v2 will only receive critical bug fixes until this date. +> +> Please head over to [the documentation for Sanity Studio v3](https://www.sanity.io/docs/sanity-studio) to learn more. + # The image tool used in sanity ## Getting started npm install --save @sanity/imagetool - ## Usage ### ImageTool widget @@ -20,18 +25,18 @@ class MyComponent extends React.Component { x: 0.4, y: 0.3, height: 0.6, - width: 0.4 + width: 0.4, }, crop: { left: 0.1, right: 0.2, top: 0.1, bottom: 0.21, - } - } + }, + }, } - handleImageToolchange = newValue => { + handleImageToolchange = (newValue) => { this.setState({value: newValue}) } @@ -52,14 +57,14 @@ class MyComponent extends React.Component { ### CSS style calculator ```js -import calculateStyles from "@sanity/imagetool/calculateStyles"; +import calculateStyles from '@sanity/imagetool/calculateStyles' const styles = calculateStyles({ hotspot: { x: 0.4, y: 0.3, height: 0.6, - width: 0.4 + width: 0.4, }, crop: { left: 0.1, @@ -68,12 +73,12 @@ const styles = calculateStyles({ bottom: 0.21, }, image: {height: 100, width: 125}, - container: {aspectRatio: 16/10}, + container: {aspectRatio: 16 / 10}, align: { x: 'left', - y: 'center' - } -}); + y: 'center', + }, +}) ``` returns an object with style objects that can be used with markup @@ -108,6 +113,7 @@ returns an object with style objects that can be used with markup ``` this can then be passed to jsx markup with the following structure: + ```jsx
@@ -118,4 +124,4 @@ this can then be passed to jsx markup with the following structure: />
-``` \ No newline at end of file +``` diff --git a/packages/@sanity/initial-value-templates/README.md b/packages/@sanity/initial-value-templates/README.md new file mode 100644 index 00000000000..384678bbe39 --- /dev/null +++ b/packages/@sanity/initial-value-templates/README.md @@ -0,0 +1,5 @@ +# ⚠️ THIS PACKAGE IS DEPRECATED + +> This package is part of Sanity Studio v2, which has been superseded by **Sanity Studio v3**, the current major version released on Dec 7th, 2022. This package is no longer used/needed for Sanity Studio in its current version and will be retired on Dec 7th, 2023. The core packages for Sanity Studio v2 will only receive critical bug fixes until this date. +> +> Please head over to [the documentation for Sanity Studio v3](https://www.sanity.io/docs/sanity-studio) to learn more. diff --git a/packages/@sanity/plugin-loader/README.md b/packages/@sanity/plugin-loader/README.md index c96e761af12..0767b2edfbf 100644 --- a/packages/@sanity/plugin-loader/README.md +++ b/packages/@sanity/plugin-loader/README.md @@ -1,2 +1,9 @@ +# ⚠️ THIS PACKAGE IS DEPRECATED + +> This package is part of Sanity Studio v2, which has been superseded by **Sanity Studio v3**, the current major version released on Dec 7th, 2022. This package is no longer used/needed for Sanity Studio in its current version and will be retired on Dec 7th, 2023. The core packages for Sanity Studio v2 will only receive critical bug fixes until this date. +> +> Please head over to [the documentation for Sanity Studio v3](https://www.sanity.io/docs/sanity-studio) to learn more. + # plugin-loader + Monkey-patches node's require algorithm to allow requiring of Sanity parts diff --git a/packages/@sanity/production-preview/README.md b/packages/@sanity/production-preview/README.md new file mode 100644 index 00000000000..384678bbe39 --- /dev/null +++ b/packages/@sanity/production-preview/README.md @@ -0,0 +1,5 @@ +# ⚠️ THIS PACKAGE IS DEPRECATED + +> This package is part of Sanity Studio v2, which has been superseded by **Sanity Studio v3**, the current major version released on Dec 7th, 2022. This package is no longer used/needed for Sanity Studio in its current version and will be retired on Dec 7th, 2023. The core packages for Sanity Studio v2 will only receive critical bug fixes until this date. +> +> Please head over to [the documentation for Sanity Studio v3](https://www.sanity.io/docs/sanity-studio) to learn more. diff --git a/packages/@sanity/react-hooks/README.md b/packages/@sanity/react-hooks/README.md index 4a3234e54f4..4cd72215a1f 100644 --- a/packages/@sanity/react-hooks/README.md +++ b/packages/@sanity/react-hooks/README.md @@ -1,2 +1,7 @@ +# ⚠️ THIS PACKAGE IS DEPRECATED + +> This package is part of Sanity Studio v2, which has been superseded by **Sanity Studio v3**, the current major version released on Dec 7th, 2022. This package is no longer used/needed for Sanity Studio in its current version and will be retired on Dec 7th, 2023. The core packages for Sanity Studio v2 will only receive critical bug fixes until this date. +> +> Please head over to [the documentation for Sanity Studio v3](https://www.sanity.io/docs/sanity-studio) to learn more. ## React hooks for Sanity Studio diff --git a/packages/@sanity/resolver/README.md b/packages/@sanity/resolver/README.md index 38b87f0c529..da804057282 100644 --- a/packages/@sanity/resolver/README.md +++ b/packages/@sanity/resolver/README.md @@ -1,3 +1,9 @@ +# ⚠️ THIS PACKAGE IS DEPRECATED + +> This package is part of Sanity Studio v2, which has been superseded by **Sanity Studio v3**, the current major version released on Dec 7th, 2022. This package is no longer used/needed for Sanity Studio in its current version and will be retired on Dec 7th, 2023. The core packages for Sanity Studio v2 will only receive critical bug fixes until this date. +> +> Please head over to [the documentation for Sanity Studio v3](https://www.sanity.io/docs/sanity-studio) to learn more. + # resolver Resolves parts and plugins from a Sanity configuration diff --git a/packages/@sanity/server/README.md b/packages/@sanity/server/README.md new file mode 100644 index 00000000000..384678bbe39 --- /dev/null +++ b/packages/@sanity/server/README.md @@ -0,0 +1,5 @@ +# ⚠️ THIS PACKAGE IS DEPRECATED + +> This package is part of Sanity Studio v2, which has been superseded by **Sanity Studio v3**, the current major version released on Dec 7th, 2022. This package is no longer used/needed for Sanity Studio in its current version and will be retired on Dec 7th, 2023. The core packages for Sanity Studio v2 will only receive critical bug fixes until this date. +> +> Please head over to [the documentation for Sanity Studio v3](https://www.sanity.io/docs/sanity-studio) to learn more. diff --git a/packages/@sanity/state-router/README.md b/packages/@sanity/state-router/README.md index 440b94aed63..83915ed85e0 100644 --- a/packages/@sanity/state-router/README.md +++ b/packages/@sanity/state-router/README.md @@ -1,21 +1,26 @@ +# ⚠️ THIS PACKAGE IS DEPRECATED + +> This package is part of Sanity Studio v2, which has been superseded by **Sanity Studio v3**, the current major version released on Dec 7th, 2022. This package is no longer used/needed for Sanity Studio in its current version and will be retired on Dec 7th, 2023. The core packages for Sanity Studio v2 will only receive critical bug fixes until this date. +> +> Please head over to [the documentation for Sanity Studio v3](https://www.sanity.io/docs/sanity-studio) to learn more. + ## @sanity/state-router ## Features + Based on a routing schema: + - A state object can be derived from the current pathname - A state object can be used to generate a path name ## API Usage Define the routes for your application and how they should map to application state + ```js import {route} from '@sanity/state-router' -const router = route('/', [ - route('/products/:productId'), - route('/users/:userId'), - route('/:page'), -]) +const router = route('/', [route('/products/:productId'), route('/users/:userId'), route('/:page')]) router.encode({}) // => '/' @@ -39,19 +44,17 @@ router.encode({page: 'about'}) router.decode('/about') // => {page: about} - ``` ## React usage + ### Setup routes and provider ```jsx import {route} from '@sanity/state-router' import {RouterProvider, withRouter} from '@sanity/state-router/components' -const router = route('/', [ - route('/bikes/:bikeId') -]) +const router = route('/', [route('/bikes/:bikeId')]) const history = createHistory() @@ -76,17 +79,18 @@ const App = withRouter(function App({router}) { }) function render(location) { - ReactDOM.render(( + ReactDOM.render( + router={router} + onNavigate={handleNavigate} + state={router.decode(location.pathname)} + > - - ), document.getElementById('container')) + , + document.getElementById('container') + ) } history.listen(() => render(document.location)) - ``` ## API @@ -94,6 +98,7 @@ history.listen(() => render(document.location)) - `route(path : string, ?options : Options, ?children : ) : Router` - `route.scope(name : string, path : string, ?options : Options, ?children : ) : Router` - `Router`: + - `encode(state : object) : string` - `decode(path : string) : object` - `isRoot(path : string) : boolean` @@ -106,6 +111,7 @@ history.listen(() => render(document.location)) Router | [Router] | ((state) => Router | [Router]) ``` - `Options`: + ``` { path?: string, @@ -118,17 +124,17 @@ history.listen(() => render(document.location)) - `children` can be either another router returned from another `route()-call`, an array of routers or a function that gets passed the matched parameters, and conditionally returns child routes ## Limitations -- Parameterized paths *only*. Each route must have at least one unique parameter. If not, there's no way of unambiguously resolve a path from an empty state. + +- Parameterized paths _only_. Each route must have at least one unique parameter. If not, there's no way of unambiguously resolve a path from an empty state. Consider the following routes: + ```js -const router = route('/', [ - route('/about'), - route('/contact') -]) +const router = route('/', [route('/about'), route('/contact')]) ``` What route should be resolved from an empty state? Since both `/about` and `/contact` above resolves to an empty state object, there's no way to encode an empty state unambiguously back to either of them. The solution to this would be to introduce the page name as a parameter instead: + ```js const router = route('/', route('/:page')) ``` @@ -136,36 +142,45 @@ const router = route('/', route('/:page')) Now, `/about` would resolve to the state `{page: 'about'}` which unambiguously can map back to `/page`, and an empty state can map to `/`. To figure out if you are on the index page, you can check for `state.page == null`, (and set the state.page to null to navigate back to the index) ### No query params + Query parameters doesn't work too well with router scopes as they operate in a global namespace. A possible workaround is to "fake" query params in a path segment using transforms: + ```js function decodeParams(pathsegment) { - return pathsegment.split(';') - .reduce((params, pair) => { - const [key, value] = pair.split('=') - params[key] = value - return params - }, {}) + return pathsegment.split(';').reduce((params, pair) => { + const [key, value] = pair.split('=') + params[key] = value + return params + }, {}) } function encodeParams(params) { return Object.keys(params) - .map(key => `${key}=${params[key]}`) + .map((key) => `${key}=${params[key]}`) .join(';') } -const router = route('/some/:section/:settings', { - transform: { - settings: { - toState: decodeParams, - toPath: encodeParams - } - } -}, route('/other/:page')) +const router = route( + '/some/:section/:settings', + { + transform: { + settings: { + toState: decodeParams, + toPath: encodeParams, + }, + }, + }, + route('/other/:page') +) ``` + This call... + ```js router.decode('/some/bar/width=full;view=details') ``` -...will return the following state + +...will return the following state + ```js { section: 'bar', @@ -175,46 +190,57 @@ router.decode('/some/bar/width=full;view=details') } } ``` + Conversely calling + ```js router.encode({ section: 'bar', settings: { width: 'full', view: 'details', - } + }, }) ``` + will return + ``` /some/bar/width=full;view=details ``` ## Scopes + A scope is a separate router state space, allowing different parts of an application to be completely agnostic about the overall routing schema is like. Let's illustrate: ```js import {route} from './src' function findAppByName(name) { - return name === 'pokemon' && { - name: 'pokemon', - router: route('/:section', route('/:pokemonName')) - } + return ( + name === 'pokemon' && { + name: 'pokemon', + router: route('/:section', route('/:pokemonName')), + } + ) } const router = route('/', [ route('/users/:username'), - route('/apps/:appName', params => { + route('/apps/:appName', (params) => { const app = findAppByName(params.appName) return app && route.scope(app.name, '/', app.router) - }) + }), ]) ``` + Decoding the following path... + ```js router.decode('/apps/pokemon/stats/bulbasaur') ``` + ...will give us the state: + ```js { appName: 'pokemon', @@ -227,22 +253,28 @@ router.decode('/apps/pokemon/stats/bulbasaur') ## Intents -An _intent_ is a kind of global route that can be used for dispatching user actions. The intent route can be mounted with +An _intent_ is a kind of global route that can be used for dispatching user actions. The intent route can be mounted with + ```js route.intents() ``` + Intent links bypasses scoping, and will always be mapped to the configured `basePath`. An intent consists of a name, e.g. `open` and a set of parameters, e.g. `{id: 'abc33'}` and the easiest way to make a link to an intent is using the `IntentLink` React component: ```jsx -Open document + + Open document + ``` + This will generate an `/open/id=abc33` depending on where the intent handler is mounted State router comes with a built in intent-route parser that decodes an intent route to route state. Full example: + ``` const router = route('/', [ route('/users/:username'), @@ -270,18 +302,16 @@ const router = route('/pages/:page') router.isNotFound('/some/invalid/path') // => true - ``` ## Base paths Using a base path is as simple as adding a toplevel route with no params: + ```js -const router = route('/some/basepath', [ - route('/:foo'), - route('/:bar') -]) +const router = route('/some/basepath', [route('/:foo'), route('/:bar')]) ``` + Any empty router state will resolve to `/some/basepath`. To check if you should redirect to the base path on app init, you can use the `router.isRoot(path)` and `router.getBasePath()` method: ```js diff --git a/packages/@sanity/structure/README.md b/packages/@sanity/structure/README.md new file mode 100644 index 00000000000..384678bbe39 --- /dev/null +++ b/packages/@sanity/structure/README.md @@ -0,0 +1,5 @@ +# ⚠️ THIS PACKAGE IS DEPRECATED + +> This package is part of Sanity Studio v2, which has been superseded by **Sanity Studio v3**, the current major version released on Dec 7th, 2022. This package is no longer used/needed for Sanity Studio in its current version and will be retired on Dec 7th, 2023. The core packages for Sanity Studio v2 will only receive critical bug fixes until this date. +> +> Please head over to [the documentation for Sanity Studio v3](https://www.sanity.io/docs/sanity-studio) to learn more. diff --git a/packages/@sanity/studio-hints/README.md b/packages/@sanity/studio-hints/README.md index e4e51707ce5..d91bf3e8b7c 100644 --- a/packages/@sanity/studio-hints/README.md +++ b/packages/@sanity/studio-hints/README.md @@ -1,13 +1,18 @@ +# ⚠️ THIS PACKAGE IS DEPRECATED + +> This package is part of Sanity Studio v2, which has been superseded by **Sanity Studio v3**, the current major version released on Dec 7th, 2022. This package is no longer used/needed for Sanity Studio in its current version and will be retired on Dec 7th, 2023. The core packages for Sanity Studio v2 will only receive critical bug fixes until this date. +> +> Please head over to [the documentation for Sanity Studio v3](https://www.sanity.io/docs/sanity-studio) to learn more. + # Studio hints Helpful stuff appears! In the sidecar! This plugin is an implementation of `part:@sanity/default-layout/sidecar`. As such, it exports the three things it is required to: - - `SidecarToggleButton` React component: The button which will appear in the Navbar to toggle on/off the Sidecar - - `SidecarLayout` React component: The content of the Sidecar (once it appears) - - `isSidecarEnabled` Function. Call this to check if the Sidecar implementation is happy and good to go (typically, the sidecar impl. wants to verify if config is present) - +- `SidecarToggleButton` React component: The button which will appear in the Navbar to toggle on/off the Sidecar +- `SidecarLayout` React component: The content of the Sidecar (once it appears) +- `isSidecarEnabled` Function. Call this to check if the Sidecar implementation is happy and good to go (typically, the sidecar impl. wants to verify if config is present) ## Want Studio hints to appear in a running Studio? @@ -20,6 +25,7 @@ sanity install @sanity/studio-hints ### 2. Implement part:@sanity/default-layout/studio-hints-config Add this to the `parts` array in the sanity.json file: + ```json { "implements": "part:@sanity/default-layout/studio-hints-config", @@ -28,13 +34,15 @@ Add this to the `parts` array in the sanity.json file: ``` Create the file: + ```bash touch studioHintsConfig.js ``` Edit that file to specify which hints package the studio-hints plugin will use: + ```js export default { - templateRepoId: 'sanity-io/sanity-template-gatsby-blog' + templateRepoId: 'sanity-io/sanity-template-gatsby-blog', } ``` diff --git a/packages/@sanity/transaction-collator/README.md b/packages/@sanity/transaction-collator/README.md new file mode 100644 index 00000000000..384678bbe39 --- /dev/null +++ b/packages/@sanity/transaction-collator/README.md @@ -0,0 +1,5 @@ +# ⚠️ THIS PACKAGE IS DEPRECATED + +> This package is part of Sanity Studio v2, which has been superseded by **Sanity Studio v3**, the current major version released on Dec 7th, 2022. This package is no longer used/needed for Sanity Studio in its current version and will be retired on Dec 7th, 2023. The core packages for Sanity Studio v2 will only receive critical bug fixes until this date. +> +> Please head over to [the documentation for Sanity Studio v3](https://www.sanity.io/docs/sanity-studio) to learn more. diff --git a/packages/@sanity/webpack-integration/README.md b/packages/@sanity/webpack-integration/README.md index 5476b8b44e9..de9bee1a99c 100644 --- a/packages/@sanity/webpack-integration/README.md +++ b/packages/@sanity/webpack-integration/README.md @@ -1,3 +1,9 @@ +# ⚠️ THIS PACKAGE IS DEPRECATED + +> This package is part of Sanity Studio v2, which has been superseded by **Sanity Studio v3**, the current major version released on Dec 7th, 2022. This package is no longer used/needed for Sanity Studio in its current version and will be retired on Dec 7th, 2023. The core packages for Sanity Studio v2 will only receive critical bug fixes until this date. +> +> Please head over to [the documentation for Sanity Studio v3](https://www.sanity.io/docs/sanity-studio) to learn more. + # @sanity/webpack-integration Tools and modules required for making partisan (the part system) work with webpack. Note: currently only works with Webpack 1. @@ -14,7 +20,7 @@ npm install --save @sanity/webpack-integration const sanityWebpack = require('@sanity/webpack-integration/v1') const options = { basePath: '/path/to/project', - env: 'production' + env: 'production', } // Get array of plugins required for part loading @@ -29,8 +35,6 @@ sanityWebpack.getPostcssPlugins(options) // Get a partial webpack configuration for the Sanity-specific parts. You'll have to merge this with your existing webpack config. sanityWebpack.getConfig(options) - - // Less common, but if you need more fine-grained access to internals: // Get a preconfigured `DefinePlugin` that exposes `__DEV__` diff --git a/packages/@sanity/webpack-loader/README.md b/packages/@sanity/webpack-loader/README.md new file mode 100644 index 00000000000..384678bbe39 --- /dev/null +++ b/packages/@sanity/webpack-loader/README.md @@ -0,0 +1,5 @@ +# ⚠️ THIS PACKAGE IS DEPRECATED + +> This package is part of Sanity Studio v2, which has been superseded by **Sanity Studio v3**, the current major version released on Dec 7th, 2022. This package is no longer used/needed for Sanity Studio in its current version and will be retired on Dec 7th, 2023. The core packages for Sanity Studio v2 will only receive critical bug fixes until this date. +> +> Please head over to [the documentation for Sanity Studio v3](https://www.sanity.io/docs/sanity-studio) to learn more.