Skip to content

Commit

Permalink
Add anchors in definition shortcode (#1802)
Browse files Browse the repository at this point in the history
Signed-off-by: Kévin Commaille <[email protected]>
  • Loading branch information
zecakeh authored Apr 30, 2024
1 parent 7201042 commit a0bc6e7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
1 change: 1 addition & 0 deletions changelogs/internal/newsfragments/1802.clarification
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add anchors in `definition` shortcode.
10 changes: 8 additions & 2 deletions layouts/shortcodes/definition.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@
{{ $definition = partial "json-schema/resolve-refs" (dict "schema" $definition "path" $path) }}
{{ $definition = partial "json-schema/resolve-allof" $definition }}

<section class="rendered-data definition" id="definition-{{ anchorize $definition.title }}">
{{ $anchor_base := printf "definition-%s" (anchorize $definition.title) }}

<section class="rendered-data definition" id="{{ $anchor_base }}">

<details {{ if not $compact }}open{{ end }}>
<summary>
Expand All @@ -46,7 +48,11 @@ <h1>
{{ $definition.description | markdownify }}


{{ $additional_types := partial "json-schema/resolve-additional-types" (dict "schema" $definition "name" (printf "\"%s\"" $path)) }}
{{ $additional_types := partial "json-schema/resolve-additional-types" (dict
"schema" $definition
"anchor_base" $anchor_base
"name" (printf "\"%s\"" $path))
}}

{{ range $additional_types }}
{{ partial "openapi/render-object-table" . }}
Expand Down

0 comments on commit a0bc6e7

Please sign in to comment.