@@ -17,36 +17,28 @@ export function load(app: Application) {
1717}
1818```
1919
20- This isn't very interesting since it exactly duplicates the default theme. Most themes need to adjust the templates
21- in some way. This can be done by providing them class which returns a different context class. Say we wanted to replace
22- TypeDoc's default analytics helper with one that uses [ Open Web Analytics] ( https://www.openwebanalytics.com/ ) instead of
23- Google Analytics. This could be done with the following theme:
20+ This isn't very interesting since it exactly duplicates the default theme.
21+ Most themes need to adjust the templates in some way. This can be done by
22+ providing them class which returns a different context class. Say we wanted
23+ to replace TypeDoc's default footer with one that mentioned your copyright.
24+ This could be done with the following theme.
25+
26+ In this case, it would probably be better to add this content using a render
27+ hook for ` footer.begin ` or ` footer.end ` , but it can be done in this way as well.
2428
2529``` tsx
2630import { Application , DefaultTheme , PageEvent , JSX , Reflection } from " typedoc" ;
2731
28- const script = `
29- (function() {
30- var _owa = document.createElement('script'); _owa.type = 'text/javascript';
31- _owa.async = true; _owa.src = '${site }' + '/modules/base/js/owa.tracker-combined-min.js';
32- var _owa_s = document.getElementsByTagName('script')[0]; _owa_s.parentNode.insertBefore(_owa,
33- _owa_s);
34- }());
35- ` .trim ();
36-
3732class MyThemeContext extends DefaultThemeRenderContext {
38- // Important: If you use `this`, this function MUST be bound! Template functions are free
39- // to destructure the context object to only grab what they care about.
40- override analytics = () => {
41- // Reusing existing option rather than declaring our own for brevity
42- if (! this .options .isSet (" gaId" )) return ;
43-
44- const site = this .options .getValue (" gaId" );
45-
33+ // Important: If you use `this`, this function MUST be bound! Template functions
34+ // are free to destructure the context object to only grab what they care about.
35+ override footer = (context ) => {
4636 return (
47- <script >
48- <JSX.Raw html = { script } />
49- </script >
37+ <footer >
38+ { context .hook (" footer.begin" , context )}
39+ Copyright 2024
40+ { context .hook (" footer.end" , context )}
41+ </footer >
5042 );
5143 };
5244}
@@ -62,7 +54,7 @@ export function load(app: Application) {
6254}
6355```
6456
65- ## Hooks (v0.22.8+)
57+ ## Hooks
6658
6759When rendering themes, TypeDoc's default theme will call several functions to allow plugins to inject HTML
6860into a page without completely overwriting a theme. Hooks live on the parent ` Renderer ` and may be called
0 commit comments