mirror of
https://github.com/withastro/astro.git
synced 2024-12-30 22:03:56 -05:00
fix: revert src. src
This commit is contained in:
parent
9fdef7bc60
commit
2e8af7f8eb
1 changed files with 2 additions and 3 deletions
|
@ -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,
|
||||
|
@ -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({
|
||||
|
@ -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('/')) {
|
||||
|
|
Loading…
Reference in a new issue