Skip to content
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

Merged
merged 6 commits into from
Mar 23, 2023

Conversation

Princesseuh
Copy link
Member

@Princesseuh Princesseuh commented Mar 22, 2023

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

@changeset-bot
Copy link

changeset-bot bot commented Mar 22, 2023

🦋 Changeset detected

Latest 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

@github-actions github-actions bot added the pkg: astro Related to the core `astro` package (scope) label Mar 22, 2023
@bholmesdev
Copy link
Contributor

I see this is all WIP, but love this implementation! Pretty simple all things considered 👍

@Princesseuh Princesseuh marked this pull request as ready for review March 23, 2023 13:24
Copy link
Member

@natemoo-re natemoo-re left a 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;
Copy link
Member

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?

Copy link
Member Author

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.

@Princesseuh Princesseuh merged commit d338b6f into main Mar 23, 2023
@Princesseuh Princesseuh deleted the feat/relative-image-frontmatter branch March 23, 2023 16:50
@astrobot-houston astrobot-houston mentioned this pull request Mar 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pkg: astro Related to the core `astro` package (scope)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants