Skip to content

Commit ae6395e

Browse files
authored
fix: links within quotes and captions (#184)
1 parent 3f29995 commit ae6395e

File tree

4 files changed

+18
-7
lines changed

4 files changed

+18
-7
lines changed

blocks/article-header/article-header.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@
6565
font-weight: var(--spectrum-title-weight-s);
6666
}
6767

68-
& p:not(.author-description p, .quote__quotation) {
68+
& p:not(.author-description p, .quote__quotation, figcaption p) {
6969
margin-block-start: 0.5rem;
7070
}
7171
}

blocks/image-with-caption/image-with-caption.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export default function decorate(block) {
88
const imageData = {
99
firstImage: block.children?.[0]?.children?.[0]?.firstElementChild,
1010
secondImage: block.children?.[0]?.children?.[1]?.firstElementChild,
11-
caption: block.children?.[1]?.children?.[0]?.textContent?.trim(),
11+
caption: block.children?.[1]?.children?.[0]?.innerHTML,
1212
altText: block.children?.[2]?.children?.[0]?.textContent?.trim(),
1313
secondAltText: block.children?.[2]?.children?.[1]?.textContent?.trim(),
1414
fullWidth: block.children?.[3]?.children?.[0]?.textContent?.trim(),
@@ -33,7 +33,7 @@ export default function decorate(block) {
3333
if (imageData.caption) {
3434
const imageCaption = document.createElement('figcaption');
3535
imageCaption.classList.add('util-detail-s', 'image-with-caption__caption');
36-
imageCaption.innerText = imageData.caption;
36+
imageCaption.innerHTML = imageData.caption;
3737
imageContainer.append(imageCaption);
3838
}
3939

blocks/quote/quote.css

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,16 @@
2222

2323
.quote__quotation {
2424
margin: 0;
25+
26+
& + .quote__quotation {
27+
margin-top: 0.5em;
28+
}
2529
}
2630

2731
.quote__attribution {
2832
margin-block: 0.5rem 0;
2933

34+
& cite,
3035
& a {
3136
font-style: normal;
3237
}

blocks/quote/quote.js

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,17 @@ export default async function decorate(block) {
22
const [quotation, attribution, attributionUrl] = [...block.children].map((c) => c.firstElementChild);
33
const blockquote = document.createElement('blockquote');
44

5-
const quoteText = document.createElement('p');
6-
quoteText.className = 'quote__quotation util-heading-quote';
7-
quoteText.innerHTML = quotation.innerText;
8-
blockquote.append(quoteText);
5+
// Append quote text, within paragraph(s). May contain links.
6+
if (quotation?.children?.length > 0) {
7+
Array.from(quotation.children).forEach(textElement => {
8+
const quoteText = document.createElement('p');
9+
quoteText.className = 'quote__quotation util-heading-quote';
10+
quoteText.innerHTML = textElement.innerHTML;
11+
blockquote.append(quoteText);
12+
});
13+
}
914

15+
// Append optional paragraph with attribution text and link.
1016
if (attribution) {
1117
const attributionText = document.createElement('p');
1218
attributionText.className = 'quote__attribution util-detail-s';

0 commit comments

Comments
 (0)