notion-to-md icon indicating copy to clipboard operation
notion-to-md copied to clipboard

Caption for images

Open zirkelc opened this issue 1 year ago • 6 comments

It's quite easy to implement caption for images:

n2m.setCustomTransformer('image', async (block) => {
  const { image } = block as ImageBlockObjectResponse;
  const src = image.type === 'external' ? image.external.url : image.file.url;
  const caption = image.caption ? image.caption[0]?.plain_text : '';

  return `
  <figure>
    <img src="${src}" alt=${caption} />
    <figcaption>${caption}</figcaption>
  </figure>`;
});

I was wondering why that's not the default behaviour?

zirkelc avatar Apr 04 '23 08:04 zirkelc