Skip to content

Commit 31b32ed

Browse files
committed
fix: remove \n from caption
1 parent 55a2303 commit 31b32ed

File tree

4 files changed

+9
-10
lines changed

4 files changed

+9
-10
lines changed

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

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -197,16 +197,15 @@
197197
// Create image title
198198
const createImageTitle = (lightboxImage) => {
199199
if (!showImageCaption) return
200-
console.log('Creating image title')
201200
const title = lightboxImage.getAttribute('alt');
202201

203202
if (!title) return null;
204203
// create div for image title and description
205204
const titleDiv = createElementWithClass('div', LIGHTBOX_CLASSES.title);
206205

207206
// Split the title by newline and filter out any empty lines
208-
const titleLines = title.split('\n').map(line => line.trim()).filter(line => line.length > 0);
209-
207+
const titleLines = title.split('"').map(line => line.trim()).filter(line => line.length > 0);
208+
210209
titleLines.forEach((line, index) => {
211210
const titleSpan = document.createElement('span');
212211
titleSpan.classList.add('title-caption');
@@ -217,7 +216,7 @@
217216
} else {
218217
titleSpan.classList.add('additional-lines');
219218
}
220-
219+
line = line.replace(/\\n/g, '');
221220
titleSpan.textContent = line;
222221
titleDiv.appendChild(titleSpan);
223222
});

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ resources:
99
- src: "img/bird.jpg"
1010
title: "Example caption 1"
1111
params:
12-
description: "Description for bird image
13-
new line test
14-
end of line
15-
"
12+
description: >
13+
Description for bird image
14+
new line test
15+
end of line
1616
cssClass: "size-large"
1717
- src: "img/city.jpg"
1818
title: "Example caption 2"

layouts/shortcodes/gallery.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@
104104
{{- end -}}
105105

106106
{{ if ne $description "" }}
107-
{{- $title = printf "%s\n%q" $title $description -}}
107+
{{- $title = printf "%s"%q" $title $description -}}
108108
{{ end }}
109109

110110
<!-- Single Image Item -->

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@d-oit/hinode-mod-image-lightbox-gallery",
3-
"version": "1.0.0",
3+
"version": "0.0.1-rc1",
44
"description": "Hugo module compatible with Hinode image lightbox gallery",
55
"keywords": [
66
"hugo",

0 commit comments

Comments
 (0)