astro/.changeset/tricky-rabbits-count.md
Bjorn Lu 5eba34fcc6
Remove deprecated APIs (#5707)
* Remove deprecated Astro globals

* Remove deprecated hook param

* Fix test

* Add changeset

* Add TODO
2023-01-03 14:06:07 -05:00

36 lines
844 B
Markdown

---
'astro': major
---
Remove deprecated `Astro` global APIs, including `Astro.resolve`, `Astro.fetchContent`, and `Astro.canonicalURL`.
#### `Astro.resolve`
You can resolve asset paths using `import` instead. For example:
```astro
---
import 'style.css'
import imageUrl from './image.png'
---
<img src={imageUrl} />
```
See the [v0.25 migration guide](https://docs.astro.build/en/migrate/#deprecated-astroresolve) for more information.
#### `Astro.fetchContent`
Use `Astro.glob` instead to fetch markdown files, or migrate to the [Content Collections](https://docs.astro.build/en/guides/content-collections/) feature.
```js
let allPosts = await Astro.glob('./posts/*.md');
```
#### `Astro.canonicalURL`
Use `Astro.url` instead to construct the canonical URL.
```js
const canonicalURL = new URL(Astro.url.pathname, Astro.site);
```