0.2.7
ℹ️ [TLDR] 0.2.7 brings experimental support for an image field when using files source.
✨ (Experimental) Support for image Field with Files Source
When using source-files as the content source, you can now use an image field. This will process images that are colocated with your content files, resolving the image path to a rich object containing properties for the image file. This will also move the image into a path that will ensure the image is publicly available on your site.
image Field Example (Files Source)
Given a document type definition that specifies a coverImage field of type image:
const Post = defineDocumentType(() => ({
  name: 'Post',
  filePathPattern: 'posts/*.md',
  fields: {
    coverImage: { type: 'image' },
  },
}))And a content file that references a colocated image file:
---
coverImage: ./image-a.png
---
# Hello worldContentlayer will produce the following for the coverImage property within the document:
"coverImage": {
  "filePath": "posts/image-a.png",
  "relativeFilePath": "image-a.png",
  "format": "png",
  "height": 480,
  "width": 640,
  "blurhashDataUrl": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAgAAAAICAMAAADz0U65AAAACVBMVEV8Ou12OOBtM9E8a9LBAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAHElEQVQImWNgwAIYmZhgDEYwzcQEQiABRhDCAgADQQAWowgdtgAAAABJRU5ErkJggg=="
},Date Improvements
date values that include timezones work more consistently (see #9 for details, and thanks to @pard68 & @mshick for their contributions).
This change removes the date-fns library in favor of the new Temporal API (via a polyfill).
Other Improvements
- There is now a 
resolveCwdwhen using the files content source to explicitly tell Contentlayer how to resolve the current working directory. This also changes the default resolution behavior. See #270 for the change, which closes #266. And thanks to @mshick for their contribution here. - Upgraded dependencies.
 - Strengthen codebase with more tests.
 
🐞 Bug Fixes
- Fix and better error logging when fields are missing from 
defineDocument. See #268 for details.