fix: generate unique properties anchor (#733)

BREAKING CHANGE: The way anchors are generated for properties of a propertylist has changed to be unique, even if the shortcode is used multiple times on a page.
This commit is contained in:
Robert Kaussow 2023-10-28 22:48:31 +02:00 committed by GitHub
parent 83469c437f
commit 460d27814a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 5 additions and 4 deletions

View File

@ -35,7 +35,7 @@ release-notes:
- name: Documentation - name: Documentation
commit-types: [docs] commit-types: [docs]
section-type: commits section-type: commits
- name: Breaking Changes - name: BREAKING CHANGES
section-type: breaking-changes section-type: breaking-changes
commit-message: commit-message:

View File

@ -11,7 +11,8 @@
{{- $properties = (sort $properties . $order) }} {{- $properties = (sort $properties . $order) }}
{{- end }} {{- end }}
{{- range $properties }} {{- range $properties }}
<dt class="flex flex-wrap align-center gdoc-props__meta"{{ if $showAnchor }} id="{{ anchorize .name }}"{{ end }}> {{- $uniqueAnchor := anchorize (printf "%s-%s" $name .name) | safeHTML }}
<dt class="flex flex-wrap align-center gdoc-props__meta"{{ if $showAnchor }} id="{{ $uniqueAnchor }}"{{ end }}>
<span class="gdoc-props__title">{{ .name }}</span> <span class="gdoc-props__title">{{ .name }}</span>
{{- if .required }} {{- if .required }}
<span class="gdoc-props__tag warning">{{ i18n "propertylist_required" | lower }}</span> <span class="gdoc-props__tag warning">{{ i18n "propertylist_required" | lower }}</span>
@ -32,7 +33,7 @@
{{- end }} {{- end }}
{{- end }} {{- end }}
{{- if $showAnchor }} {{- if $showAnchor }}
<a data-clipboard-text="{{ .Page.Permalink }}#{{ anchorize .name | safeHTML }}" class="gdoc-page__anchor clip flex align-center" title="{{ i18n "title_anchor_prefix" }} {{ .name | safeHTML }}" aria-label="{{ i18n "title_anchor_prefix" }} {{ .name | safeHTML }}" href="#{{ anchorize .name | safeHTML }}"> <a data-clipboard-text="{{ .Page.Permalink }}#{{ $uniqueAnchor }}" class="gdoc-page__anchor clip flex align-center" title="{{ i18n "title_anchor_prefix" }} {{ .name | safeHTML }}" aria-label="{{ i18n "title_anchor_prefix" }} {{ .name | safeHTML }}" href="#{{ $uniqueAnchor }}">
<svg class="gdoc-icon gdoc_link"><use xlink:href="#gdoc_link"></use></svg> <svg class="gdoc-icon gdoc_link"><use xlink:href="#gdoc_link"></use></svg>
</a> </a>
{{- end }} {{- end }}

View File

@ -90,7 +90,7 @@
padding: 0; padding: 0;
} }
.gdoc-post__anchor { .gdoc-page__anchor {
display: none; display: none;
} }
} }