Skip to content

Commit

Permalink
feat: add new documentation about templates
Browse files Browse the repository at this point in the history
  • Loading branch information
SimeonGriggs committed Jun 1, 2023
1 parent 2bddf2f commit 47da9a7
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,7 @@ For more advanced topics see the documentation. For installation see [Usage](#us
- [Deleting translated documents](./docs/03-deleting-translated-documents.md)
- [Importing plugin components](./docs/04-importing-plugin-components.md)
- [Allowing the same slug on different language versions](./docs/05-allowing-the-same-slug-on-different-language-versions.md)
- [Remove default new document template](./docs/06-remove-default-new-document-template.md)

## License

Expand Down
28 changes: 28 additions & 0 deletions docs/06-remove-default-new-document-template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Remove default new document template

This plugin creates new [Parameterized initial value templates](https://www.sanity.io/docs/initial-value-templates#66d873e2136f) so that any schema types configured in the plugin can be started with a language field already set.

However, it does not remove the default new document template which would start a document with no language field value. So your "new document" menus might look like this:

![New document menu with default and added options](./img/new-document-default.png)

To remove the default new document option, update your Sanity Studio configuration like below, where `prev` represents all previously registered templates in the Studio, and we filter out some defaults based on schema type and ID.

```ts
// ./sanity.config.ts

export default defineConfig({
//...rest of config
schema: {
// ...rest of schema

// Filter out the default template for new "page" and "lesson" type documents
templates: (prev) =>
prev.filter((template) => !['page', 'lesson'].includes(template.id)),
},
})
```

Now your new document menu for just this type will look like this

![New document menu with only added options](./img/new-document-filtered.png)
Binary file added docs/img/new-document-default.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/img/new-document-filtered.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 47da9a7

Please sign in to comment.