Skip to content

Commit

Permalink
improve audio block fallback rendering
Browse files Browse the repository at this point in the history
display title and/or artist in fallback link if available
  • Loading branch information
AprilSylph committed Nov 24, 2021
1 parent 5c4f4a1 commit 2edf98b
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/lib/npf.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ const blockRenderers = {
});
},

audio ({ url, media, provider, embed_html }) {
audio ({ url, media, provider, title, artist, embed_html }) {
if (media && provider === 'tumblr') {
return Object.assign(document.createElement('audio'), {
src: media.url,
Expand All @@ -157,10 +157,10 @@ const blockRenderers = {
} else if (embed_html) {
return Object.assign(document.createElement('figure'), { innerHTML: embed_html });
} else {
return document.createElement('a').tap(a => {
a.href = url;
a.target = '_blank';
a.append('(audio)');
return Object.assign(document.createElement('a'), {
href: url,
target: '_blank',
textContent: `${title || 'Audio'}${artist ? ` by ${artist}` : ''}`
});
}
},
Expand Down

0 comments on commit 2edf98b

Please sign in to comment.