Skip to content

Commit

Permalink
chore: fix picture image handling
Browse files Browse the repository at this point in the history
  • Loading branch information
filzrev committed Jan 3, 2024
1 parent 7ff0f0e commit 8ef8934
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions templates/modern/src/markdown.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,18 @@ async function renderClickableImage() {
const a = document.createElement('a')
a.target = '_blank'
a.rel = 'noopener noreferrer nofollow'
a.href = img.src
img.replaceWith(a)
a.appendChild(img)

if (img.parentElement.tagName === 'PICTURE') {
const picture = img.parentElement
picture.addEventListener('click', () => {
a.href = img.currentSrc
a.click()
})
} else {
a.href = img.src
img.replaceWith(a)
a.appendChild(img)
}
}

function shouldMakeClickable(): boolean {
Expand Down

0 comments on commit 8ef8934

Please sign in to comment.