Skip to content

Commit

Permalink
Make rootSchemaType string and not array of strings
Browse files Browse the repository at this point in the history
  • Loading branch information
djohalo2 committed Dec 8, 2023
1 parent 7e3a56f commit e77bb8b
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Create a shared page tree config file and constant to use in your page types and
import { PageTreeConfig } from 'sanity-plugin-page-tree';

export const pageTreeConfig: PageTreeConfig = {
rootSchemaTypes: ['homePage'],
rootSchemaType: 'homePage',
pageSchemaTypes: ['homePage', 'page'],
apiVersion: '2023-12-08',
};
Expand Down Expand Up @@ -87,7 +87,7 @@ export const structure = (S: StructureBuilder) =>
}),
)
]
);
)
```

### Create internal page links
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
"peerDependencies": {
"react": "^18",
"sanity": "^3",
"styled-components": "^5.2.3"
"styled-components": "^5"
},
"volta": {
"node": "18.17.0"
Expand Down
2 changes: 1 addition & 1 deletion src/components/PageTreeViewItemActions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export const PageTreeViewItemActions = ({ page, onActionOpen, onActionClose }: P
const onAdd = async (type: string) => {
const doc = await client.create({
_type: type,
parent: config.rootSchemaTypes.includes(type) ? undefined : { _type: 'reference', _ref: page._id },
parent: config.rootSchemaType === type ? undefined : { _type: 'reference', _ref: page._id },
language: page.language,
});
setNewPage(doc);
Expand Down
2 changes: 1 addition & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,6 @@ export type PageTreeItem = PageInfoWithPublishedState & {

export type PageTreeConfig = {
apiVersion: string;
rootSchemaTypes: string[];
rootSchemaType: string;
pageSchemaTypes: string[];
};

0 comments on commit e77bb8b

Please sign in to comment.