Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added more render hooks #1917

Merged
merged 2 commits into from
Apr 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

- Classes which are `abstract` and enums which are `const` will now be indicated in their rendered documentation, #1874.
- Added a new option `compilerOptions`, which can be used to override compiler options read from `tsconfig.json`, #1891.
- Added new render hooks: `content.begin`, `content.end`, `navigation.begin`, `navigation.end`

### Bug Fixes

Expand All @@ -13,6 +14,7 @@

- @ejuda
- @schlusslicht
- @matteobruni

## v0.22.14 (2022-04-07)

Expand Down
20 changes: 20 additions & 0 deletions src/lib/output/renderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,26 @@ export interface RendererHooks {
* Applied immediately before the closing `</body>` tag.
*/
"body.end": [DefaultThemeRenderContext];

/**
* Applied immediately before the main template.
*/
"content.begin": [DefaultThemeRenderContext];

/**
* Applied immediately after the main template.
*/
"content.end": [DefaultThemeRenderContext];

/**
* Applied immediately before calling `context.navigation`.
*/
"navigation.begin": [DefaultThemeRenderContext];

/**
* Applied immediately after calling `context.navigation`.
*/
"navigation.end": [DefaultThemeRenderContext];
}

/**
Expand Down
12 changes: 10 additions & 2 deletions src/lib/output/themes/default/layouts/default.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,16 @@ export const defaultLayout = (context: DefaultThemeRenderContext, props: PageEve

<div class="container container-main">
<div class="row">
<div class="col-8 col-content">{props.template(props)}</div>
<div class="col-4 col-menu menu-sticky-wrap menu-highlight">{context.navigation(props)}</div>
<div class="col-8 col-content">
{context.hook("content.begin")}
{props.template(props)}
{context.hook("content.end")}
</div>
<div class="col-4 col-menu menu-sticky-wrap menu-highlight">
{context.hook("navigation.begin")}
{context.navigation(props)}
{context.hook("navigation.end")}
</div>
</div>
</div>

Expand Down