Skip to content

Commit deb9453

Browse files
committed
feat: mark items as deprecated in sidebar
1 parent 02c609f commit deb9453

File tree

4 files changed

+62
-24
lines changed

4 files changed

+62
-24
lines changed

sidebars.js

+11-7
Original file line numberDiff line numberDiff line change
@@ -46,19 +46,19 @@ module.exports = {
4646
{
4747
type: 'doc',
4848
id: 'latest/tutorial/in-app-purchases',
49-
customProps: { tags: ['mac'] },
49+
customProps: { platforms: ['mac'] },
5050
},
5151
'latest/tutorial/keyboard-shortcuts',
5252
'latest/tutorial/launch-app-from-url-in-another-app',
5353
{
5454
type: 'doc',
5555
id: 'latest/tutorial/linux-desktop-actions',
56-
customProps: { tags: ['linux'] },
56+
customProps: { platforms: ['linux'] },
5757
},
5858
{
5959
type: 'doc',
6060
id: 'latest/tutorial/macos-dock',
61-
customProps: { tags: ['mac'] },
61+
customProps: { platforms: ['mac'] },
6262
},
6363
'latest/tutorial/multithreading',
6464
'latest/tutorial/native-file-drag-drop',
@@ -70,20 +70,20 @@ module.exports = {
7070
{
7171
type: 'doc',
7272
id: 'latest/tutorial/recent-documents',
73-
customProps: { tags: ['mac', 'windows'] },
73+
customProps: { platforms: ['mac', 'windows'] },
7474
},
7575
{
7676
type: 'doc',
7777
id: 'latest/tutorial/represented-file',
78-
customProps: { tags: ['mac'] },
78+
customProps: { platforms: ['mac'] },
7979
},
8080
'latest/tutorial/spellchecker',
8181
'latest/tutorial/tray',
8282
'latest/tutorial/web-embeds',
8383
{
8484
type: 'doc',
8585
id: 'latest/tutorial/windows-taskbar',
86-
customProps: { tags: ['windows'] },
86+
customProps: { platforms: ['windows'] },
8787
},
8888
{
8989
type: 'category',
@@ -228,7 +228,11 @@ module.exports = {
228228
'latest/api/app',
229229
'latest/api/auto-updater',
230230
'latest/api/base-window',
231-
'latest/api/browser-view',
231+
{
232+
type: 'doc',
233+
id: 'latest/api/browser-view',
234+
customProps: { deprecated: true },
235+
},
232236
'latest/api/browser-window',
233237
'latest/api/clipboard',
234238
'latest/api/content-tracing',

src/theme/DocSidebarItem/Link/index.tsx

+23-12
Original file line numberDiff line numberDiff line change
@@ -53,18 +53,29 @@ export default function DocSidebarItemLink({
5353

5454
{
5555
// BEGIN SWIZZLED CODE
56-
isStringArray(customProps?.tags) && (
57-
<ul className={styles.tagContainer}>
58-
{customProps.tags.map((tag) => (
59-
<li
60-
className={clsx('badge', styles.badge, styles[tag])}
61-
key={tag}
62-
>
63-
<TagContent platform={tag} />
64-
</li>
65-
))}
66-
</ul>
67-
)
56+
}
57+
{isStringArray(customProps?.platforms) && (
58+
<ul className={styles.tagContainer}>
59+
{customProps.platforms.map((tag) => (
60+
<li
61+
className={clsx('badge', styles.badge, styles[tag])}
62+
key={tag}
63+
>
64+
<TagContent platform={tag} />
65+
</li>
66+
))}
67+
</ul>
68+
)}
69+
70+
{customProps?.deprecated && (
71+
<ul className={styles.tagContainer}>
72+
<li className={clsx('badge', styles.badge2, styles.deprecated)}>
73+
Deprecated
74+
</li>
75+
</ul>
76+
)}
77+
78+
{
6879
// END SWIZZLED CODE
6980
}
7081
</Link>

src/theme/DocSidebarItem/Link/styles.module.css

+9-1
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,12 @@
1515
width: 20px;
1616
}
1717

18+
.badge2 {
19+
font-style: italic;
20+
}
21+
1822
.linux {
19-
background: tomato;
23+
background: coral;
2024
}
2125

2226
.mac {
@@ -26,3 +30,7 @@
2630
.windows {
2731
background: dodgerblue;
2832
}
33+
34+
.deprecated {
35+
background: tomato;
36+
}

src/theme/README.md

+19-4
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,32 @@ passed in, so we must Swizzle.
2424

2525
See: https://docusaurus.io/docs/sidebar#passing-custom-props
2626

27-
The `customProps` object will accept a `tags` property of type
28-
`Array<'mac'|'windows'|'linux'>`. These will be rendered as SVG icons that are
29-
stored as static assets in `static/assets/img/`.
27+
The `customProps` object will accept:
28+
29+
A `platforms` property of type `Array<'mac'|'windows'|'linux'>`.
30+
These will be rendered as SVG icons that are stored as static assets in `static/assets/img/`.
3031

3132
```js
3233
// sidebars.js
3334
{
3435
type: 'doc',
3536
id: 'doc1',
3637
customProps: {
37-
tags: ['mac', 'windows', 'linux']
38+
platforms: ['mac', 'windows', 'linux']
39+
},
40+
};
41+
```
42+
43+
A `deprecated` property of type `boolean`. This will mark a specific API as deprecated in the
44+
sidebar if the entire module is deprecated.
45+
46+
```js
47+
// sidebars.js
48+
{
49+
type: 'doc',
50+
id: 'doc2',
51+
customProps: {
52+
deprecated: true
3853
},
3954
};
4055
```

0 commit comments

Comments
 (0)