From 97601f12ff268d4471ac46be9321318b8e4177c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Commaille?= Date: Wed, 20 Nov 2024 10:41:20 +0100 Subject: [PATCH] Restore heading self links MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It was a change I did not notice when upgrading Docsy from 0.8.0 to 0.11.0. Docsy changed the way heading self links are generated: they used to be rendered with JS and now they use a Hugo render hook. This means two things: - We need to enable them explicitly by overriding the `_default/_markup/render-heading.html` template. - We need to add the self heading ourselves to headings that are not rendered by Hugo, i.e. HTML headings that we create ourselves. Signed-off-by: Kévin Commaille --- layouts/_default/_markup/render-heading.html | 1 + layouts/_default/_markup/td-heading-self-link.html | 11 +++++++++++ layouts/partials/events/render-event.html | 4 +++- layouts/partials/openapi/render-operation.html | 1 + 4 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 layouts/_default/_markup/render-heading.html create mode 100644 layouts/_default/_markup/td-heading-self-link.html diff --git a/layouts/_default/_markup/render-heading.html b/layouts/_default/_markup/render-heading.html new file mode 100644 index 00000000..7f8e9742 --- /dev/null +++ b/layouts/_default/_markup/render-heading.html @@ -0,0 +1 @@ +{{ template "_default/_markup/td-render-heading.html" . }} diff --git a/layouts/_default/_markup/td-heading-self-link.html b/layouts/_default/_markup/td-heading-self-link.html new file mode 100644 index 00000000..20d95611 --- /dev/null +++ b/layouts/_default/_markup/td-heading-self-link.html @@ -0,0 +1,11 @@ +{{- /* + + A copy of the private "_default/_markup/_td-heading-self-link.html" template + in Docsy's "_default/_markup/_td-render-heading.html" partial to be able to + reuse it when the title has custom markup. + + Takes a string which is the ID of the heading. + +*/ -}} + + \ No newline at end of file diff --git a/layouts/partials/events/render-event.html b/layouts/partials/events/render-event.html index 154e51bf..f9cbb246 100644 --- a/layouts/partials/events/render-event.html +++ b/layouts/partials/events/render-event.html @@ -15,14 +15,16 @@ {{ $event_name := .event_name }} {{ $desired_example_name := .desired_example_name }} {{ $event_data := .event_data }} +{{ $anchor := anchorize $event_name }}
-

+

{{ with .title }}{{ . | markdownify }}{{ else }}{{ $event_name }}{{ end }} + {{ template "_default/_markup/td-heading-self-link.html" $anchor }}

diff --git a/layouts/partials/openapi/render-operation.html b/layouts/partials/openapi/render-operation.html index 614e37a1..b55a209e 100644 --- a/layouts/partials/openapi/render-operation.html +++ b/layouts/partials/openapi/render-operation.html @@ -37,6 +37,7 @@

{{ $method }} {{ $endpoint }} + {{ template "_default/_markup/td-heading-self-link.html" $anchor }}