UNPKG

gatsby-remark-image-attributes

Version:

Creates HTML image markup with style and data-* attributes from [`mdAST Image`](https://github.com/syntax-tree/mdast#image) nodes with attributes in their title.

22 lines (21 loc) 734 B
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const _1 = __importDefault(require("./")); class FigureAttributeImage extends _1.default { constructor(node) { super(node); } get html() { this.sanitizeTitle().applyDataAttributes(); return `<div class="gatsby-img-attributes" style="${this.style}">${this.node.value}</div>`; } static test(node) { return (!!node.url && /<figure/.test(node.value) && _1.default.hasAttributes(node.title || '')); } } exports.default = FigureAttributeImage;