From 4cf564d6c88b3fc8d303baab7b24cd0c142536d7 Mon Sep 17 00:00:00 2001 From: "stilyan.tinloof" Date: Wed, 15 Jan 2025 11:40:45 +0000 Subject: [PATCH] path override to path, changeset --- .changeset/stupid-rats-scream.md | 5 +++++ packages/sanity-studio/README.md | 6 ++---- .../sanity-studio/src/components/IconSelectComponent.tsx | 2 +- packages/sanity-studio/src/types.ts | 2 +- 4 files changed, 9 insertions(+), 6 deletions(-) create mode 100644 .changeset/stupid-rats-scream.md diff --git a/.changeset/stupid-rats-scream.md b/.changeset/stupid-rats-scream.md new file mode 100644 index 0000000..8faea87 --- /dev/null +++ b/.changeset/stupid-rats-scream.md @@ -0,0 +1,5 @@ +--- +"@tinloof/sanity-studio": patch +--- + +iconSchema path option diff --git a/packages/sanity-studio/README.md b/packages/sanity-studio/README.md index 776c17e..54d9c58 100644 --- a/packages/sanity-studio/README.md +++ b/packages/sanity-studio/README.md @@ -480,7 +480,7 @@ export default defineType({ { title: "Chat", value: "chat" }, { title: "Clock", value: "clock" }, ], - pathOverride: "static/icons/select", + path: "/icons/select", }, }, ], @@ -490,9 +490,7 @@ export default defineType({ ### Parameters - `options.list`: Uses the default string option list type of `{title: string, value: string}[]` -- `options.pathOverride`: Override the default path `/icons/select/[icon-value].svg` where icons are looked for - -The ultility searches for icons within the folder `/icons/select/[icon-value].svg`, if you have a Next.js embbedded setup then store them under `/public/icons/select/[icon-value].svg`. +- `options.path`: Path where icons are located ## Disable creation plugin diff --git a/packages/sanity-studio/src/components/IconSelectComponent.tsx b/packages/sanity-studio/src/components/IconSelectComponent.tsx index 28a4918..c2934a3 100644 --- a/packages/sanity-studio/src/components/IconSelectComponent.tsx +++ b/packages/sanity-studio/src/components/IconSelectComponent.tsx @@ -73,7 +73,7 @@ export function IconSelectComponent(props: IconInputProps): JSX.Element { const iconOptions = options as IconOptions | undefined; const iconList = iconOptions?.list ?? []; - let iconsPath = iconOptions?.pathOverride ?? "/icons/select/"; + let iconsPath = iconOptions?.path ?? ""; // Add / to the end of the path if it's not there if (!iconsPath.endsWith("/")) { iconsPath += "/"; diff --git a/packages/sanity-studio/src/types.ts b/packages/sanity-studio/src/types.ts index 4d38d89..7c82b9e 100644 --- a/packages/sanity-studio/src/types.ts +++ b/packages/sanity-studio/src/types.ts @@ -221,7 +221,7 @@ export type PathnameInputProps = ObjectFieldProps & { export type IconOptions = { list: { title: string; value: string }[]; - pathOverride?: string; + path: string; }; export type IconParams = Omit<