File tree Expand file tree Collapse file tree 2 files changed +33
-0
lines changed
src/lib/output/themes/default/layouts Expand file tree Collapse file tree 2 files changed +33
-0
lines changed Original file line number Diff line number Diff line change 11# Unreleased
22
3+ ### Features
4+
5+ - If ` hostedBaseUrl ` is set to the root page on a website, TypeDoc will now include ` WebSite ` structured data, #2760 .
6+
37### Bug Fixes
48
59- Fix support for ESM config files with Node 23, #2752 .
Original file line number Diff line number Diff line change @@ -5,6 +5,34 @@ import type { PageEvent } from "../../../events";
55import { getDisplayName } from "../../lib" ;
66import type { DefaultThemeRenderContext } from "../DefaultThemeRenderContext" ;
77
8+ // See #2760
9+ function buildSiteMetadata ( context : DefaultThemeRenderContext ) {
10+ try {
11+ // We have to know where we are hosted in order to generate this block
12+ const url = new URL ( context . options . getValue ( "hostedBaseUrl" ) ) ;
13+
14+ // No point in generating this if we aren't the root page on the site
15+ if ( url . pathname !== "/" ) {
16+ return null ;
17+ }
18+
19+ return (
20+ < script type = "application/ld+json" >
21+ < Raw
22+ html = { JSON . stringify ( {
23+ "@context" : "https://schema.org" ,
24+ "@type" : "WebSite" ,
25+ name : context . page . project . name ,
26+ url : url . toString ( ) ,
27+ } ) }
28+ />
29+ </ script >
30+ ) ;
31+ } catch {
32+ return null ;
33+ }
34+ }
35+
836export const defaultLayout = (
937 context : DefaultThemeRenderContext ,
1038 template : RenderTemplate < PageEvent < Reflection > > ,
@@ -20,6 +48,7 @@ export const defaultLayout = (
2048 ? getDisplayName ( props . model )
2149 : `${ getDisplayName ( props . model ) } | ${ getDisplayName ( props . project ) } ` }
2250 </ title >
51+ { props . url === "index.html" && buildSiteMetadata ( context ) }
2352 < meta name = "description" content = { "Documentation for " + props . project . name } />
2453 < meta name = "viewport" content = "width=device-width, initial-scale=1" />
2554
You can’t perform that action at this time.
0 commit comments