Skip to content

Commit

Permalink
fix: generate unique properties anchor (#733)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
xoxys authored Oct 28, 2023
1 parent 83469c4 commit 460d278
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .gitsv/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ release-notes:
- name: Documentation
commit-types: [docs]
section-type: commits
- name: Breaking Changes
- name: BREAKING CHANGES
section-type: breaking-changes

commit-message:
Expand Down
5 changes: 3 additions & 2 deletions layouts/shortcodes/propertylist.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
{{- $properties = (sort $properties . $order) }}
{{- end }}
{{- 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>
{{- if .required }}
<span class="gdoc-props__tag warning">{{ i18n "propertylist_required" | lower }}</span>
Expand All @@ -32,7 +33,7 @@
{{- end }}
{{- end }}
{{- 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>
</a>
{{- end }}
Expand Down
2 changes: 1 addition & 1 deletion src/sass/_shortcodes.scss
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@
padding: 0;
}

.gdoc-post__anchor {
.gdoc-page__anchor {
display: none;
}
}
Expand Down

0 comments on commit 460d278

Please sign in to comment.