summaryrefslogtreecommitdiff
path: root/.changeset/nasty-crabs-worry.md
diff options
context:
space:
mode:
Diffstat (limited to '.changeset/nasty-crabs-worry.md')
-rw-r--r--.changeset/nasty-crabs-worry.md25
1 files changed, 25 insertions, 0 deletions
diff --git a/.changeset/nasty-crabs-worry.md b/.changeset/nasty-crabs-worry.md
new file mode 100644
index 000000000..f2a935404
--- /dev/null
+++ b/.changeset/nasty-crabs-worry.md
@@ -0,0 +1,25 @@
+---
+'astro': minor
+---
+
+Adds a new property to the globals `Astro` and `APIContext` called `routePattern`. The `routePattern` represents the current route (component)
+that is being rendered by Astro. It's usually a path pattern will look like this: `blog/[slug]`:
+
+```astro
+---
+// src/pages/blog/[slug].astro
+const route = Astro.routePattern;
+console.log(route); // it will log "blog/[slug]"
+---
+```
+
+```js
+// src/pages/index.js
+
+export const GET = (ctx) => {
+ console.log(ctx.routePattern) // it will log src/pages/index.js
+ return new Response.json({ loreum: "ipsum" })
+}
+```
+
+