From a0bc6e7f8391fc0b10fdc6fab0d899716186043e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Commaille?= <76261501+zecakeh@users.noreply.github.com> Date: Tue, 30 Apr 2024 17:52:23 +0200 Subject: [PATCH] Add anchors in `definition` shortcode (#1802) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Kévin Commaille --- changelogs/internal/newsfragments/1802.clarification | 1 + layouts/shortcodes/definition.html | 10 ++++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) create mode 100644 changelogs/internal/newsfragments/1802.clarification diff --git a/changelogs/internal/newsfragments/1802.clarification b/changelogs/internal/newsfragments/1802.clarification new file mode 100644 index 00000000..09aebc5d --- /dev/null +++ b/changelogs/internal/newsfragments/1802.clarification @@ -0,0 +1 @@ +Add anchors in `definition` shortcode. diff --git a/layouts/shortcodes/definition.html b/layouts/shortcodes/definition.html index 23461878..a1f0904e 100644 --- a/layouts/shortcodes/definition.html +++ b/layouts/shortcodes/definition.html @@ -26,7 +26,9 @@ {{ $definition = partial "json-schema/resolve-refs" (dict "schema" $definition "path" $path) }} {{ $definition = partial "json-schema/resolve-allof" $definition }} -
+{{ $anchor_base := printf "definition-%s" (anchorize $definition.title) }} + +
@@ -46,7 +48,11 @@ {{ $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" . }}