Skip to content

Commit

Permalink
fix: revert src. src
Browse files Browse the repository at this point in the history
  • Loading branch information
chappelo committed Aug 18, 2024
1 parent 9fdef7b commit 2e8af7f
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions packages/integrations/markdoc/src/content-entry-type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ async function emitOptimizedImages(
if ((node.type === 'image' || isComponent) && typeof node.attributes.src === 'string') {
let attributeName = isComponent ? 'src' : '__optimizedSrc';

if (node.attributes.src.startsWith('./')) {
if (node.attributes.src.startsWith('./') || node.attributes.src.startsWith('../')) {
node.attributes.src = prependForwardSlash(
path.relative(
ctx.astroConfig.root.pathname,
Expand Down Expand Up @@ -341,7 +341,6 @@ async function emitOptimizedImages(
globalThis.astroAsset.referencedImages.add(fsPath);
}
node.attributes[attributeName] = { ...src, fsPath };
node.attributes.src = src.src;
}
} else {
throw new MarkdocError({
Expand All @@ -361,7 +360,7 @@ async function emitOptimizedImages(
}

function shouldOptimizeImage(src: string, rootPath: string) {
// Optimize anything that is NOT external or a true absolute path to `public/`.
// Optimize anything that is NOT external or an absolute path to `public/`
if (isValidUrl(src)) return false;
const normPath = path.normalize(src);
if (normPath.startsWith(rootPath) || normPath.startsWith('/')) {
Expand Down

0 comments on commit 2e8af7f

Please sign in to comment.