@@ -2,19 +2,39 @@ import { classNames, getDisplayName, hasTypeParameters, join } from "../../lib";
2
2
import { JSX } from "../../../../utils" ;
3
3
import type { DefaultThemeRenderContext } from "../DefaultThemeRenderContext" ;
4
4
import type { PageEvent } from "../../../events" ;
5
- import { type Reflection , ReflectionKind } from "../../../../models" ;
5
+ import type { Reflection } from "../../../../models" ;
6
6
7
7
export const header = ( context : DefaultThemeRenderContext , props : PageEvent < Reflection > ) => {
8
- const HeadingLevel = props . model . isProject ( ) ? "h2" : "h1" ;
8
+ const opts = context . options . getValue ( "headings" ) ;
9
+
10
+ // Don't render on the index page or the class hierarchy page
11
+ // We should probably someday render on the class hierarchy page, but currently breadcrumbs
12
+ // are entirely dependent on the reflection hierarchy, so it doesn't make sense today.
13
+ const renderBreadcrumbs = props . url !== "index.html" && props . url !== "hierarchy.html" ;
14
+
15
+ // Titles are always rendered on DeclarationReflection pages and the modules page for the project.
16
+ // They are also rendered on the readme + document pages if configured to do so by the user.
17
+ let renderTitle : boolean ;
18
+ let titleKindString = "" ;
19
+ if ( props . model . isProject ( ) ) {
20
+ if ( props . url === "index.html" && props . model . readme ?. length ) {
21
+ renderTitle = opts . readme ;
22
+ } else {
23
+ renderTitle = true ;
24
+ }
25
+ } else if ( props . model . isDocument ( ) ) {
26
+ renderTitle = opts . document ;
27
+ } else {
28
+ renderTitle = true ;
29
+ titleKindString = " " + context . internationalization . kindSingularString ( props . model . kind ) ;
30
+ }
31
+
9
32
return (
10
33
< div class = "tsd-page-title" >
11
- { props . url !== "index.html" && props . url !== "hierarchy.html" && (
12
- < ul class = "tsd-breadcrumb" > { context . breadcrumb ( props . model ) } </ ul >
13
- ) }
14
- { ! props . model . isDocument ( ) && (
15
- < HeadingLevel class = { classNames ( { deprecated : props . model . isDeprecated ( ) } ) } >
16
- { props . model . kind !== ReflectionKind . Project &&
17
- `${ context . internationalization . kindSingularString ( props . model . kind ) } ` }
34
+ { renderBreadcrumbs && < ul class = "tsd-breadcrumb" > { context . breadcrumb ( props . model ) } </ ul > }
35
+ { renderTitle && (
36
+ < h1 class = { classNames ( { deprecated : props . model . isDeprecated ( ) } ) } >
37
+ { titleKindString }
18
38
{ getDisplayName ( props . model ) }
19
39
{ hasTypeParameters ( props . model ) && (
20
40
< >
@@ -24,7 +44,7 @@ export const header = (context: DefaultThemeRenderContext, props: PageEvent<Refl
24
44
</ >
25
45
) }
26
46
{ context . reflectionFlags ( props . model ) }
27
- </ HeadingLevel >
47
+ </ h1 >
28
48
) }
29
49
</ div >
30
50
) ;
0 commit comments