astro/.changeset/seven-singers-mate.md
Matthew Phillips 78b5bde14c
Astro.resolve (#1085)
* add: Astro.resolve

* Add docs and tests for Astro.resolve

* Add warnings when using string literals

* Prevent windows errors

* Adds a changeset

* Use the astro logger to log the warning

* Use the .js extension

* Dont warn for data urls

* Rename nonRelative and better match

Co-authored-by: Jonathan Neal <jonathantneal@hotmail.com>
2021-08-16 16:43:06 -04:00

603 B

docs astro
patch patch

Adds support for Astro.resolve

Astro.resolve() helps with creating URLs relative to the current Astro file, allowing you to reference files within your src/ folder.

Astro does not resolve relative links within HTML, such as images:

<img src="../images/penguin.png" />

The above will be sent to the browser as-is and the browser will resolve it relative to the current page. If you want it to be resolved relative to the .astro file you are working in, use Astro.resolve:

<img src={Astro.resolve('../images/penguin.png')} />