@@ -16,15 +16,15 @@ import {CodePlatterProvider} from './CodePlatter';
1616import { ExampleSwitcher } from './ExampleSwitcher' ;
1717import { getLibraryFromPage , getLibraryFromUrl , getLibraryLabel } from './library' ;
1818import { getTextWidth } from './textWidth' ;
19- import { GoUpOneLink } from './GoUpOneLink ' ;
19+ import ChevronRightIcon from '@react-spectrum/s2/icons/ChevronRight ' ;
2020import { H2 , H3 , H4 } from './Headings' ;
2121import Header from './Header' ;
22- import { Link } from './Link' ;
22+ import { Link , TitleLink } from './Link' ;
2323import { MobileHeader } from './MobileHeader' ;
2424import { PickerItem , Provider } from '@react-spectrum/s2' ;
2525import { PropTable } from './PropTable' ;
2626import { StateTable } from './StateTable' ;
27- import { style } from '@react-spectrum/s2/style' with { type : 'macro' } ;
27+ import { iconStyle , style } from '@react-spectrum/s2/style' with { type : 'macro' } ;
2828import { TypeLink } from './types' ;
2929import { VersionBadge } from './VersionBadge' ;
3030import { VisualExample } from './VisualExample' ;
@@ -64,15 +64,16 @@ const components = {
6464 ExampleList
6565} ;
6666
67- const subPageComponents = {
67+ const subPageComponents = ( previousPage ?: Page ) => ( {
6868 ...components ,
6969 h1 : ( { children, ...props } ) => (
7070 < div className = { style ( { display : 'flex' , alignItems : 'center' , gap : 8 } ) } >
71- < GoUpOneLink />
71+ < TitleLink href = "./index.html" > { previousPage ?. exports ?. title } </ TitleLink >
72+ < ChevronRightIcon styles = { iconStyle ( { size : 'XL' } ) } />
7273 < h1 { ...props } id = "top" style = { { '--width-per-em' : getTextWidth ( children ) } as any } className = { h1 } > { children } </ h1 >
7374 </ div >
7475 )
75- } ;
76+ } ) ;
7677
7778function anchorId ( children ) {
7879 return children . replace ( / \s / g, '-' ) . replace ( / [ ^ a - z A - Z 0 - 9 - _ ] / g, '' ) . toLowerCase ( ) ;
@@ -145,6 +146,10 @@ export function Layout(props: PageProps & {children: ReactElement<any>}) {
145146 let title = getTitle ( currentPage ) ;
146147 let description = getDescription ( currentPage ) ;
147148 let isSubpage = currentPage . exports ?. isSubpage ;
149+ let parentPage = pages . find ( p => {
150+ return p . url === currentPage . url . replace ( / \/ [ ^ / ] + \. h t m l $ / , '/index.html' ) ;
151+ } ) ;
152+ console . log ( parentPage ) ;
148153 return (
149154 < Provider elementType = "html" locale = "en" background = "layer-1" styles = { style ( { scrollPaddingTop : { default : 64 , lg : 0 } } ) } >
150155 < head >
@@ -255,7 +260,12 @@ export function Layout(props: PageProps & {children: ReactElement<any>}) {
255260 < article
256261 className = { articleStyles ( { isWithToC : hasToC } ) } >
257262 { currentPage . exports ?. version && < VersionBadge version = { currentPage . exports . version } /> }
258- { React . cloneElement ( children , { components : isSubpage ? subPageComponents : components , pages} ) }
263+ { React . cloneElement ( children , {
264+ components : isSubpage ?
265+ subPageComponents ( parentPage ) :
266+ components ,
267+ pages
268+ } ) }
259269 </ article >
260270 </ CodePlatterProvider >
261271 { hasToC && < aside
0 commit comments