Skip to content

Commit ca42411

Browse files
committed
fix hover on multiple citations
1 parent e87c819 commit ca42411

File tree

2 files changed

+58
-57
lines changed

2 files changed

+58
-57
lines changed

layouts/shortcodes/cite.html

Lines changed: 55 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -108,70 +108,71 @@
108108

109109
{{- range where $bibliography "id" "eq" $key -}}
110110
{{- $currentRef := . -}}
111+
<span class="hugo-cite-group">
111112

112-
{{/* Add to the collection of cited references */}}
113-
{{- $.Page.Scratch.SetInMap "citedBib" $key $currentRef -}}
113+
{{/* Add to the collection of cited references */}}
114+
{{- $.Page.Scratch.SetInMap "citedBib" $key $currentRef -}}
114115

115-
{{/* Add to the collection of cited references */}}
116-
{{- $.Page.Scratch.SetInMap "citedBib" $key $currentRef -}}
116+
{{/* Add to the collection of cited references */}}
117+
{{- $.Page.Scratch.SetInMap "citedBib" $key $currentRef -}}
117118

118-
<a href="#{{- $key | urlize -}}"><span class="visually-hidden">Citation: </span>
119-
{{- $reference := . -}}
119+
<a href="#{{- $key | urlize -}}"><span class="visually-hidden">Citation: </span>
120+
{{- $reference := . -}}
120121

121-
{{- /* -------------------- BEGIN Display authors -------------------- */ -}}
122-
{{- if not $suppressAuthor -}}
123-
{{- $displayAuthors := $reference.author -}}
124-
{{- if not $reference.author -}}
125-
{{- $displayAuthors = $reference.editor -}}
126-
{{- end -}}
127-
{{- if not $displayAuthors -}}
128-
<span rel="noauthor">
129-
{{- i18n "apa_no_author_abbr" | default "n.a." | upper -}}
130-
</span>
131-
{{- else -}}
132-
{{- range $authorIndex, $author := $displayAuthors | first 2 -}}
133-
<span itemprop="author" itemscope itemtype="https://schema.org/Person">
134-
{{- with $author.given -}}
135-
<meta itemprop="givenName" content="{{ . }}">
122+
{{- /* -------------------- BEGIN Display authors -------------------- */ -}}
123+
{{- if not $suppressAuthor -}}
124+
{{- $displayAuthors := $reference.author -}}
125+
{{- if not $reference.author -}}
126+
{{- $displayAuthors = $reference.editor -}}
127+
{{- end -}}
128+
{{- if not $displayAuthors -}}
129+
<span rel="noauthor">
130+
{{- i18n "apa_no_author_abbr" | default "n.a." | upper -}}
131+
</span>
132+
{{- else -}}
133+
{{- range $authorIndex, $author := $displayAuthors | first 2 -}}
134+
<span itemprop="author" itemscope itemtype="https://schema.org/Person">
135+
{{- with $author.given -}}
136+
<meta itemprop="givenName" content="{{ . }}">
137+
{{- end -}}
138+
{{- with $author.family -}}
139+
<span itemprop="familyName">{{ . | markdownify }}</span>
140+
{{- end -}}
141+
</span>
142+
{{- if and (eq $authorIndex 0) (gt (len $displayAuthors) 2) -}}
143+
,&#32;
136144
{{- end -}}
137-
{{- with $author.family -}}
138-
<span itemprop="familyName">{{ . | markdownify }}</span>
145+
{{- if and (eq (len $displayAuthors) 2) (eq $authorIndex 0) -}}&#32;&amp;&#32;
139146
{{- end -}}
140-
</span>
141-
{{- if and (eq $authorIndex 0) (gt (len $displayAuthors) 2) -}}
142-
,&#32;
143147
{{- end -}}
144-
{{- if and (eq (len $displayAuthors) 2) (eq $authorIndex 0) -}}&#32;&amp;&#32;
148+
{{ if gt (len $displayAuthors) 2 }}
149+
<em>&amp; al.</em>
150+
{{- end -}}
151+
{{- end -}},&#32;
152+
{{- end -}}
153+
{{- /* -------------------- END Display authors -------------------- */ -}}
154+
155+
{{- if and (isset $reference "issued") (isset $reference.issued "date-parts") -}}
156+
{{- range $index, $dateParts := (index .issued "date-parts") -}}{{/* range of dates */}}
157+
{{- range first 1 $dateParts -}}{{/* First element in date-part is the year */ -}}
158+
<span itemprop="datePublished">
159+
{{- . -}}
160+
</span>
145161
{{- end -}}
146-
{{- end -}}
147-
{{ if gt (len $displayAuthors) 2 }}
148-
<em>&amp; al.</em>
149-
{{- end -}}
150-
{{- end -}},&#32;
151-
{{- end -}}
152-
{{- /* -------------------- END Display authors -------------------- */ -}}
153-
154-
{{- if and (isset $reference "issued") (isset $reference.issued "date-parts") -}}
155-
{{- range $index, $dateParts := (index .issued "date-parts") -}}{{/* range of dates */}}
156-
{{- range first 1 $dateParts -}}{{/* First element in date-part is the year */ -}}
157-
<span itemprop="datePublished">
158-
{{- . -}}
159-
</span>
160162
{{- end -}}
161163
{{- end -}}
162-
{{- end -}}
163-
{{- $currentPages := index $pages $keyIndex -}}
164-
{{- with $currentPages -}},&#32;
165-
{{- $formatedPages := (printf "p.&nbsp;%s" $currentPages) | safeHTML -}}
166-
{{- if gt (findRE "-" $currentPages) 0 -}}{{/* If `$pages` contains a dash */}}
167-
{{- $formatedPages = (printf "pp.&nbsp;%s" $currentPages) | safeHTML -}}
168-
{{- end -}}
169-
{{- $formatedPages }}{{- end -}}
170-
</a>
171-
172-
{{- /* Eliminate space between css-hidden citation hover block */ -}}
173-
174-
<span class="hugo-cite-citation"> {{ partial $partialPath $reference }}</span>
164+
{{- $currentPages := index $pages $keyIndex -}}
165+
{{- with $currentPages -}},&#32;
166+
{{- $formatedPages := (printf "p.&nbsp;%s" $currentPages) | safeHTML -}}
167+
{{- if gt (findRE "-" $currentPages) 0 -}}{{/* If `$pages` contains a dash */}}
168+
{{- $formatedPages = (printf "pp.&nbsp;%s" $currentPages) | safeHTML -}}
169+
{{- end -}}
170+
{{- $formatedPages }}{{- end -}}
171+
</a>
172+
173+
{{- /* Eliminate space between css-hidden citation hover block */ -}}
174+
175+
<span class="hugo-cite-citation"> {{ partial $partialPath $reference }}</span></span>
175176

176177
{{- if lt (add 1 $keyIndex) $totalRefs -}};&#32;{{- end -}}
177178

static/hugo-cite.css

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22
/* Hugo-Cite.css
33
/* ----------------------------------------------------------------------------- */
44

5-
.hugo-cite-intext {
5+
.hugo-cite-group {
66
display: inline-block;
77
vertical-align: baseline; /*compensate for lower height */
88
position: relative;
99
font-size: .85em; /* reduce to avoid some breaks */
1010
}
11-
.hugo-cite-intext
11+
.hugo-cite-group
1212
.hugo-cite-citation {
1313
visibility: hidden;
1414
background-color: #ffffff;
@@ -31,7 +31,7 @@
3131
opacity: 0;
3232
transform: translateY(-8px);
3333
}
34-
.hugo-cite-intext:hover
34+
.hugo-cite-group:hover
3535
.hugo-cite-citation {
3636
visibility: visible;
3737
transition: visibility 0s 0s, transform .3s, opacity .3s;

0 commit comments

Comments
 (0)