Access current route #970
aldo-roman
started this conversation in
Proposal
Replies: 2 comments 2 replies
-
+1 — this is something I’ve wanted in the past too. |
Beta Was this translation helpful? Give feedback.
0 replies
-
When you say "route" what exactly do you mean? The actual file path that matched the URL? |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Body
Summary
To have a property
Astro.route
that contains the current route being rendered.Background & Motivation
When rendering a navbar statically, I'd like to know which route is currently active. Right now, I can only know which URL is active via
Astro.url
. Unfortunately, this does not allow to know which route is being rendered.Goals
Example
If pages directory is:
The rendered URLs would be
/foo/
,/bar/
, etc.There is currently no way to know if a URL belongs to either group
/[group1]/index.astro
or/[group2]/index.astro
.The current
Astro.url
is not enough to discern which group a URL belongs.The proposed
Astro.route
would return/[group1]/index.astro
or/[group2]/index.astro
as fit.Beta Was this translation helpful? Give feedback.
All reactions