11import { useEffect } from 'preact/hooks' ;
22import Markup from 'preact-markup' ;
33import widgets from '../widgets' ;
4- import style from './style.module.css' ;
5- import { useTranslation } from '../../lib/i18n' ;
64import { TocContext } from '../table-of-contents' ;
75
86const COMPONENTS = {
97 ...widgets
108} ;
119
12- function SiblingNav ( { route, lang, start } ) {
13- let title = '' ;
14- let url = '' ;
15- if ( route ) {
16- url = route . path . toLowerCase ( ) ;
17- title =
18- typeof route . name === 'object'
19- ? route . name [ lang || 'en' ]
20- : route . name || route . title ;
21- }
22- const label = useTranslation ( start ? 'previous' : 'next' ) ;
23-
24- return (
25- < a class = { style . nextLink } data-dir-end = { ! start } href = { url } >
26- { start && < span class = { style . icon } > ← </ span > }
27- { ! start && < span class = { style . icon } > →</ span > }
28- < span class = { style . nextInner } >
29- < span class = { style . nextTitle } >
30- < span class = { style . nextTitleInner } > { title } </ span >
31- </ span >
32- < span class = { style . nextUrl } > { label } </ span >
33- </ span >
34- </ a >
35- ) ;
36- }
37-
3810export default function ContentRegion ( { content, components, ...props } ) {
39- const hasNav = ! ! ( props . next || props . prev ) ;
4011 components = Object . assign ( { } , COMPONENTS , components ) ;
4112
4213 useEffect ( ( ) => {
@@ -49,11 +20,7 @@ export default function ContentRegion({ content, components, ...props }) {
4920 } , [ props . current ] ) ;
5021
5122 return (
52- < content-region
53- name = { props . current }
54- data-page-nav = { hasNav }
55- can-edit = { props . canEdit }
56- >
23+ < content-region name = { props . current } can-edit = { props . canEdit } >
5724 { content && (
5825 < TocContext . Provider value = { { toc : props . toc } } >
5926 < Markup
@@ -64,20 +31,6 @@ export default function ContentRegion({ content, components, ...props }) {
6431 />
6532 </ TocContext . Provider >
6633 ) }
67- { hasNav && (
68- < div class = { style . nextWrapper } >
69- { props . prev ? (
70- < SiblingNav start lang = { props . lang } route = { props . prev } />
71- ) : (
72- < span />
73- ) }
74- { props . next ? (
75- < SiblingNav lang = { props . lang } route = { props . next } />
76- ) : (
77- < span />
78- ) }
79- </ div >
80- ) }
8134 </ content-region >
8235 ) ;
8336}
0 commit comments