Skip to content

Commit 9eb68a2

Browse files
committed
fix: caption
1 parent c1287d2 commit 9eb68a2

File tree

4 files changed

+10
-9
lines changed

4 files changed

+10
-9
lines changed

assets/js/modules/image-lightbox-gallery/lightbox.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,9 @@
204204
const titleDiv = createElementWithClass('div', LIGHTBOX_CLASSES.title);
205205

206206
// Split the title by newline and filter out any empty lines
207-
const titleLines = title.split('"').map(line => line.trim()).filter(line => line.length > 0);
207+
// Replace literal "\n" with actual newlines, then split by real newlines
208+
const normalizedTitle = title.replace(/\\n/g, '\n');
209+
const titleLines = normalizedTitle.split('\n').map(line => line.trim()).filter(line => line.length > 0);
208210

209211
titleLines.forEach((line, index) => {
210212
const titleSpan = document.createElement('span');
@@ -216,7 +218,7 @@
216218
} else {
217219
titleSpan.classList.add('additional-lines');
218220
}
219-
line = line.replace(/\\n/g, '');
221+
//line = line.replace('\\n', '<br>');
220222
titleSpan.textContent = line;
221223
titleDiv.appendChild(titleSpan);
222224
});

assets/scss/image-lightbox-gallery.scss

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,9 +105,7 @@
105105
.slide-lightbox-container {
106106
display: flex;
107107
align-items: center;
108-
padding: 12px 12px 12px 6px;
109108
position: absolute;
110-
top: 50%;
111109
cursor: pointer;
112110
z-index: 3;
113111
transform: translateY(-50%);

exampleSite/content/gallery/gallery-stack-resources-images-sample.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@ title: "Gallery Stack Resources Sample"
44
thumbnail:
55
url: /img/bird.jpg
66

7-
slug: "gallery-stack-res-img-sample1"
87
resources:
98
- src: "img/bird.jpg"
109
title: "Example caption 1"
1110
params:
12-
description: >
11+
description: |
1312
Description for bird image
1413
new line test
14+
1515
end of line
1616
cssClass: "size-large"
1717
- src: "img/city.jpg"

layouts/shortcodes/gallery.html

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,19 +108,20 @@
108108
{{- end -}}
109109

110110
{{ if ne $description "" }}
111-
{{- $title = printf "%s&quot;%q" $title $description -}}
111+
{{- $title = printf "%s \\n %s" $title $description -}}
112+
{{ $title = $title }}
112113
{{ end }}
113114

114115
{{ if eq $isError false }}
115116
<!-- Single Image Item -->
116-
<div id="{{ $imageUrl }}" class="gallery-item {{ $randomClass }}" {{ $dataAttributes | safeHTMLAttr }}>
117+
<div id="{{ $imageUrl }}" class="gallery-item {{ $randomClass }}" {{ $dataAttributes | safeHTMLAttr }} aria-describedby="{{ $title }}">
117118
{{ partial "assets/image.html" (dict
118119
"url" $imageUrl
119120
"ratio" $ratio
120121
"page" $.Page
121122
"class" $imageCssClass
122123
"loading" $loading
123-
"title" $title
124+
"title" $title
124125
"caption" $caption
125126
) }}
126127
</div>

0 commit comments

Comments
 (0)