zce / velite

Turns Markdown / MDX, YAML, JSON, or others into app's data layer with Zod schema.
http://velite.js.org
MIT License
476 stars 23 forks source link

s.image add option to not copy the file to a folder #70

Closed jahirfiquitiva closed 6 months ago

jahirfiquitiva commented 7 months ago

Hey

I would like to request a feature so that when we use s.image we can configure it to not copy the file to any folder.

For example...

I have this frontmatter

cover: /media/images/blog/blog-post-cover.jpg

s.image would read that file in ./public/media/images/blog/blog-post-cover.jpg, meaning it is already in that folder, no need to copy it, and return the image metadata it already does.

Maybe cover would need the whole path (./public/media/images/blog/blog-post-cover.jpg) so that s.image checked right there and not try to figure out the root folder.

Thanks in advance!

zce commented 7 months ago

Your idea is excellent, and it aligns with the original TODO list.

https://github.com/zce/velite/blob/328dabcbaa33e106b9e938fe1dbde009f9886be3/src/schemas/image.ts#L19-L20

https://github.com/zce/velite/issues/68

PR welcome if possible.

zce commented 6 months ago

@jahirfiquitiva https://velite.js.org/guide/velite-schemas#options-absoluteroot

zce commented 6 months ago

BTW. I strongly recommend using relative path reference assets in Markdown for better maintainability and portability.

 root
├── content
│   └── posts
│        └── hello-world
│             ├── reference-asset.png
│             └── index.md
├── public
├── package.json
└── velite.config.js