-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Resolve images in the frontmatter relative to the current file #6627
Conversation
🦋 Changeset detectedLatest commit: 8b2af55 The changes in this PR will be included in the next version bump. Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
I see this is all WIP, but love this implementation! Pretty simple all things considered 👍 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
object[schemaName] = z.preprocess( | ||
async (value: unknown) => { | ||
if (!value || typeof value !== 'string') return value; | ||
return (await resolver(value))?.id; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we have a test for aliased paths?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We do! This file has it all: a relative path, a nested path and an aliased path.
Changes
Previously, all images in the frontmatter were relative to
src/assets
, this PR changes it so it's relative to the current file instead. This is a proper resolve, so you can use aliases (including~/assets/
) and stuff.This PR does not cover using images in certain cases, such as arrays. This is intentional as this is not supported at the moment in general so I'll tacle it in a dedicated PR
Testing
Updated tests
Docs
withastro/docs#2910