Skip to content

Commit

Permalink
fix absolute image file path for windows
Browse files Browse the repository at this point in the history
  • Loading branch information
timlrx committed Apr 27, 2024
1 parent e02cc1b commit 447fec2
Showing 1 changed file with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { fs, unknownToRelativePosixFilePath } from '@contentlayer2/utils'
import { identity, OT, pipe, T } from '@contentlayer2/utils/effect'
import type * as ImageScript from 'imagescript'
import type sharp from 'sharp'
import * as URL from 'url'

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

const filePath = utils.filePathJoin(documentDirPath, imagePath)
const absoluteFilePath = utils.filePathJoin(contentDirPath, documentDirPath, imagePath)
const absoluteFilePath = URL.pathToFileURL(utils.filePathJoin(contentDirPath, documentDirPath, imagePath)).href
const relativeFilePath = utils.relative(utils.filePathJoin(contentDirPath, documentDirPath), absoluteFilePath)

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

0 comments on commit 447fec2

Please sign in to comment.