Skip to content

Commit

Permalink
feat(ImagesPlugin): add inlineSvg option
Browse files Browse the repository at this point in the history
  • Loading branch information
ogonkov authored and yndx-birman committed Dec 4, 2023
1 parent eaa778f commit 1c802ec
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/transform/plugins/images/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {StateCore} from '../../typings';

interface ImageOpts extends MarkdownItPluginOpts {
assetsPublicPath: string;
inlineSvg?: boolean;
}

function replaceImageSrc(
Expand Down Expand Up @@ -94,8 +95,9 @@ const index: MarkdownItPluginCb<Opts> = (md, opts) => {
}

const imgSrc = childrenTokens[j].attrGet('src') || '';
const shouldInlineSvg = opts.inlineSvg !== false && !isExternalHref(imgSrc);

if (imgSrc.endsWith('.svg') && !isExternalHref(imgSrc)) {
if (imgSrc.endsWith('.svg') && shouldInlineSvg) {
childrenTokens[j] = convertSvg(childrenTokens[j], state, opts);
} else {
replaceImageSrc(childrenTokens[j], state, opts);
Expand Down

0 comments on commit 1c802ec

Please sign in to comment.