0
Fork 0
mirror of https://github.com/withastro/astro.git synced 2025-01-06 22:10:10 -05:00

fix: revert src. src

This commit is contained in:
Josh Chappelow 2024-08-18 22:06:47 +09:00
parent 9fdef7bc60
commit 2e8af7f8eb

View file

@ -310,7 +310,7 @@ async function emitOptimizedImages(
if ((node.type === 'image' || isComponent) && typeof node.attributes.src === 'string') { if ((node.type === 'image' || isComponent) && typeof node.attributes.src === 'string') {
let attributeName = isComponent ? 'src' : '__optimizedSrc'; let attributeName = isComponent ? 'src' : '__optimizedSrc';
if (node.attributes.src.startsWith('./')) { if (node.attributes.src.startsWith('./') || node.attributes.src.startsWith('../')) {
node.attributes.src = prependForwardSlash( node.attributes.src = prependForwardSlash(
path.relative( path.relative(
ctx.astroConfig.root.pathname, ctx.astroConfig.root.pathname,
@ -341,7 +341,6 @@ async function emitOptimizedImages(
globalThis.astroAsset.referencedImages.add(fsPath); globalThis.astroAsset.referencedImages.add(fsPath);
} }
node.attributes[attributeName] = { ...src, fsPath }; node.attributes[attributeName] = { ...src, fsPath };
node.attributes.src = src.src;
} }
} else { } else {
throw new MarkdocError({ throw new MarkdocError({
@ -361,7 +360,7 @@ async function emitOptimizedImages(
} }
function shouldOptimizeImage(src: string, rootPath: string) { 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; if (isValidUrl(src)) return false;
const normPath = path.normalize(src); const normPath = path.normalize(src);
if (normPath.startsWith(rootPath) || normPath.startsWith('/')) { if (normPath.startsWith(rootPath) || normPath.startsWith('/')) {