Skip to content

Commit 447fec2

Browse files
committed
fix absolute image file path for windows
1 parent e02cc1b commit 447fec2

File tree

1 file changed

+2
-1
lines changed
  • packages/@contentlayer/source-files/src/fetchData/mapping

1 file changed

+2
-1
lines changed

packages/@contentlayer/source-files/src/fetchData/mapping/field-image.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { fs, unknownToRelativePosixFilePath } from '@contentlayer2/utils'
44
import { identity, OT, pipe, T } from '@contentlayer2/utils/effect'
55
import type * as ImageScript from 'imagescript'
66
import type sharp from 'sharp'
7+
import * as URL from 'url'
78

89
import { FetchDataError } from '../../errors/index.js'
910
import type { HasDocumentContext } from '../DocumentContext.js'
@@ -56,7 +57,7 @@ const getImageFieldData = ({
5657
const documentDirPath = utils.dirname(documentFilePath)
5758

5859
const filePath = utils.filePathJoin(documentDirPath, imagePath)
59-
const absoluteFilePath = utils.filePathJoin(contentDirPath, documentDirPath, imagePath)
60+
const absoluteFilePath = URL.pathToFileURL(utils.filePathJoin(contentDirPath, documentDirPath, imagePath)).href
6061
const relativeFilePath = utils.relative(utils.filePathJoin(contentDirPath, documentDirPath), absoluteFilePath)
6162

6263
const fileBuffer = yield* $(fs.readFileBuffer(absoluteFilePath))

0 commit comments

Comments
 (0)