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

Restore heading self links #2007

Merged
merged 3 commits into from
Nov 29, 2024
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion changelogs/internal/newsfragments/1996.clarification
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Upgrade docsy to 0.11.0 and hugo to 0.138.0.
Upgrade docsy to 0.11.0 and hugo to 0.139.0.
1 change: 1 addition & 0 deletions changelogs/internal/newsfragments/2007.clarification
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Upgrade docsy to 0.11.0 and hugo to 0.139.0.
11 changes: 11 additions & 0 deletions layouts/_default/_markup/render-heading.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{{- /*

This is a heading render hook (https://gohugo.io/render-hooks/headings/)
using Docsy's heading self-links hook (https://www.docsy.dev/docs/adding-content/navigation/#heading-self-links).

This is used when a heading is encountered in markdown content to generate
the HTML for that heading. A self-link anchor is added at the end of the
heading.

*/ -}}
{{ template "_default/_markup/td-render-heading.html" . }}
richvdh marked this conversation as resolved.
Show resolved Hide resolved
11 changes: 11 additions & 0 deletions layouts/_default/_markup/td-heading-self-link.html
richvdh marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{{- /*

A simplified copy of the inlined "_default/_markup/_td-heading-self-link.html"
template in Docsy's "_default/_markup/td-render-heading.html" template to be
able to reuse it when the heading has custom markup.

Takes a string which is the ID of the heading.

*/ -}}

<a class="td-heading-self-link" href="#{{ . | safeURL }}" aria-label="Heading self-link"></a>
4 changes: 3 additions & 1 deletion layouts/partials/events/render-event.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,16 @@
{{ $event_name := .event_name }}
{{ $desired_example_name := .desired_example_name }}
{{ $event_data := .event_data }}
{{ $anchor := anchorize $event_name }}

<section class="rendered-data event">

<details {{ if not .Site.Params.ui.rendered_data_collapsed }}open{{ end }}>
<summary>

<h1 id="{{ anchorize $event_name }}">
<h1 id="{{ $anchor }}">
{{ with .title }}{{ . | markdownify }}{{ else }}<code>{{ $event_name }}</code>{{ end }}
{{ template "_default/_markup/td-heading-self-link.html" $anchor }}
</h1>

</summary>
Expand Down
1 change: 1 addition & 0 deletions layouts/partials/openapi/render-operation.html
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
<h1 id="{{ $anchor }}">
<span class="http-api-method">{{ $method }}</span>
<span class="endpoint{{ if $operation_data.deprecated }} deprecated-inline{{ end }}">{{ $endpoint }}</span>
{{ template "_default/_markup/td-heading-self-link.html" $anchor }}
</h1>
</summary>

Expand Down