@@ -36,7 +36,7 @@ import YouWillLearnCard from './YouWillLearnCard';
3636import { Challenges , Hint , Solution } from './Challenges' ;
3737import { IconNavArrow } from '../Icon/IconNavArrow' ;
3838import ButtonLink from 'components/ButtonLink' ;
39- import { TocContext } from './TocContext' ;
39+ import { TocContext , IsInTocContext } from './TocContext' ;
4040import type { Toc , TocItem } from './TocContext' ;
4141import { TeamMember } from './TeamMember' ;
4242import { LanguagesContext } from './LanguagesContext' ;
@@ -122,33 +122,57 @@ const RSC = ({children}: {children: React.ReactNode}) => (
122122 < ExpandableCallout type = "rsc" > { children } </ ExpandableCallout >
123123) ;
124124
125- const CanaryBadge = ( { title} : { title : string } ) => (
126- < span
127- title = { title }
128- className = {
129- 'text-base font-display px-1 py-0.5 font-bold bg-gray-10 dark:bg-gray-60 text-gray-60 dark:text-gray-10 rounded'
130- } >
131- < IconCanary
132- size = "s"
133- className = { 'inline me-1 mb-0.5 text-sm text-gray-60 dark:text-gray-10' }
134- />
135- Canary only
136- </ span >
137- ) ;
125+ const CanaryBadge = ( { title} : { title : string } ) => {
126+ const isInToc = useContext ( IsInTocContext ) ;
127+ if ( isInToc ) {
128+ return (
129+ < IconCanary
130+ size = "s"
131+ title = { title }
132+ className = "inline me-1 mb-0.5 text-gray-60 dark:text-gray-10"
133+ />
134+ ) ;
135+ }
136+ return (
137+ < span
138+ title = { title }
139+ className = {
140+ 'text-base font-display px-1 py-0.5 font-bold bg-gray-10 dark:bg-gray-60 text-gray-60 dark:text-gray-10 rounded'
141+ } >
142+ < IconCanary
143+ size = "s"
144+ className = { 'inline me-1 mb-0.5 text-sm text-gray-60 dark:text-gray-10' }
145+ />
146+ Canary only
147+ </ span >
148+ ) ;
149+ } ;
138150
139- const ExperimentalBadge = ( { title} : { title : string } ) => (
140- < span
141- title = { title }
142- className = {
143- 'text-base font-display px-1 py-0.5 font-bold bg-gray-10 dark:bg-gray-60 text-gray-60 dark:text-gray-10 rounded'
144- } >
145- < IconExperimental
146- size = "s"
147- className = { 'inline me-1 mb-0.5 text-sm text-gray-60 dark:text-gray-10' }
148- />
149- Experimental only
150- </ span >
151- ) ;
151+ const ExperimentalBadge = ( { title} : { title : string } ) => {
152+ const isInToc = useContext ( IsInTocContext ) ;
153+ if ( isInToc ) {
154+ return (
155+ < IconExperimental
156+ size = "s"
157+ title = { title }
158+ className = "inline me-1 mb-0.5 text-gray-60 dark:text-gray-10"
159+ />
160+ ) ;
161+ }
162+ return (
163+ < span
164+ title = { title }
165+ className = {
166+ 'text-base font-display px-1 py-0.5 font-bold bg-gray-10 dark:bg-gray-60 text-gray-60 dark:text-gray-10 rounded'
167+ } >
168+ < IconExperimental
169+ size = "s"
170+ className = { 'inline me-1 mb-0.5 text-sm text-gray-60 dark:text-gray-10' }
171+ />
172+ Experimental only
173+ </ span >
174+ ) ;
175+ } ;
152176
153177const NextMajorBadge = ( { title} : { title : string } ) => (
154178 < span
@@ -422,7 +446,11 @@ function InlineToc() {
422446 if ( root . children . length < 2 ) {
423447 return null ;
424448 }
425- return < InlineTocItem items = { root . children } /> ;
449+ return (
450+ < IsInTocContext . Provider value = { true } >
451+ < InlineTocItem items = { root . children } />
452+ </ IsInTocContext . Provider >
453+ ) ;
426454}
427455
428456function InlineTocItem ( { items} : { items : Array < NestedTocNode > } ) {
0 commit comments