Skip to content

Commit

Permalink
path override to path, changeset
Browse files Browse the repository at this point in the history
  • Loading branch information
stilyan-tinloof committed Jan 15, 2025
1 parent 9c2494f commit 4cf564d
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 6 deletions.
5 changes: 5 additions & 0 deletions .changeset/stupid-rats-scream.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@tinloof/sanity-studio": patch
---

iconSchema path option
6 changes: 2 additions & 4 deletions packages/sanity-studio/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,7 @@ export default defineType({
{ title: "Chat", value: "chat" },
{ title: "Clock", value: "clock" },
],
pathOverride: "static/icons/select",
path: "/icons/select",
},
},
],
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 += "/";
Expand Down
2 changes: 1 addition & 1 deletion packages/sanity-studio/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ export type PathnameInputProps = ObjectFieldProps<SlugValue> & {

export type IconOptions = {
list: { title: string; value: string }[];
pathOverride?: string;
path: string;
};

export type IconParams = Omit<
Expand Down

0 comments on commit 4cf564d

Please sign in to comment.