Skip to content

Commit 6db4c65

Browse files
committed
feat: make name and icon configurable
1 parent 024c1c5 commit 6db4c65

File tree

1 file changed

+17
-4
lines changed

1 file changed

+17
-4
lines changed

src/plugin.tsx

+17-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, {CSSProperties} from 'react'
1+
import React, {ComponentType, CSSProperties} from 'react'
22
import {Dashboard} from './containers/Dashboard'
33
import {definePlugin} from 'sanity'
44
import {DashboardConfig, DashboardWidget, LayoutConfig} from './types'
@@ -25,7 +25,18 @@ const DashboardIcon = () => (
2525
)
2626

2727
export interface DashboardPluginConfig {
28+
/**
29+
* Dashboard tool title
30+
*/
2831
title?: string
32+
/**
33+
* Dashboard tool name (used in url path)
34+
*/
35+
name?: string
36+
/**
37+
* Dashboard tool icon
38+
*/
39+
icon?: ComponentType
2940
widgets?: DashboardWidget[]
3041

3142
/**
@@ -39,8 +50,10 @@ export const dashboardTool = definePlugin<DashboardPluginConfig>((config = {}) =
3950
layout: config.defaultLayout ?? {},
4051
widgets: config.widgets ?? [],
4152
}
42-
53+
4354
const title = config.title ?? 'Dashboard'
55+
const name = config.name ?? 'dashboard'
56+
const icon = config.icon ?? DashboardIcon
4457

4558
return {
4659
name: 'dashboard',
@@ -49,8 +62,8 @@ export const dashboardTool = definePlugin<DashboardPluginConfig>((config = {}) =
4962
...prev,
5063
{
5164
title,
52-
name: 'dashboard',
53-
icon: DashboardIcon,
65+
name,
66+
icon,
5467
component: () => <Dashboard config={pluginConfig} />,
5568
},
5669
]

0 commit comments

Comments
 (0)