Skip to content

Commit

Permalink
Handle paths that are already relative
Browse files Browse the repository at this point in the history
  • Loading branch information
ascorbic committed Jul 18, 2024
1 parent 49485d2 commit 356d5f9
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions packages/astro/src/content/sync.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,7 @@ import type { Logger } from '../core/logger/core.js';
import { ASSET_IMPORTS_FILE, DATA_STORE_FILE } from './consts.js';
import { DataStore, globalDataStore } from './data-store.js';
import type { DataWithId, LoaderContext } from './loaders/types.js';
import {
getEntryData,
getEntryDataAndImages,
globalContentConfigObserver,
posixRelative,
} from './utils.js';
import { getEntryDataAndImages, globalContentConfigObserver, posixRelative } from './utils.js';

export interface SyncContentLayerOptions {
store?: DataStore;
Expand Down Expand Up @@ -86,11 +81,13 @@ export async function syncContentLayer({
collectionWithResolvedSchema,
false
);

if (imageImports) {
if (imageImports?.length) {
store.addAssetImports(
imageImports,
posixRelative(fileURLToPath(settings.config.root), filePath)
// This path may already be relative, if we're re-parsing an existing entry
filePath.startsWith('/')
? posixRelative(fileURLToPath(settings.config.root), filePath)
: filePath
);
}

Expand Down

0 comments on commit 356d5f9

Please sign in to comment.