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

Add a new Astro.metadata global object #10844

Closed
ematipico opened this issue Apr 22, 2024 · 6 comments
Closed

Add a new Astro.metadata global object #10844

ematipico opened this issue Apr 22, 2024 · 6 comments
Assignees

Comments

@ematipico
Copy link
Member

ematipico commented Apr 22, 2024

This is an opportunity to land a new feature in Astro, without knowing too much about the internals; however, you must be familiar with Astro itself because you will implement a test that would require familiarity as a user. You will have to take care of everything:

  • code
  • tests
  • documentation
  • code reviews and address comments from reviewers

Important

We want to land this feature for Astro v4.8, scheduled for the 9th of May. Please don't volunteer if you can't commit to this deadline.

Feature

We want to add a new Astro.metadata. The metadata will be used to store read-only information that integrations and users can use to implement some logic.

For this feature/issue, you will add Astro.metadata.route.

Technical changes

Here's a TODO list of the things that you will have to do in order to land the PR:

  • Add metadata in the AstroGlobal interface
    export interface AstroGlobal<
    Props extends Record<string, any> = Record<string, any>,
    Self = AstroComponentFactory,
    Params extends Record<string, string | undefined> = Record<string, string | undefined>,
    > extends AstroGlobalPartial,
  • Create a new AstroGlobalMetadata interface and add route. The route type must be RouteData['route']. Make sure to document the stuff that you add. Follow the in-code patterns.
  • Populate the Astro global object with metadata.route. The RenderContext has a RouteData object, that's where metadata.route will come from. I don't think we need any caching:
  • Create an integration test. We already have astro-global.test.js, we can update that test with new use cases.
    • This feature must work in dev, ssg, ssr. The metadata must be accessible inside Astro components, middleware and endpoints, so let's create tests to cover those cases
  • Create a changeset that shows a minimal example

Coordination

GitHub and Discord are the best places for coordination. Use the #contribute channel for questions.

@github-actions github-actions bot added the needs triage Issue needs to be triaged label Apr 22, 2024
@ematipico ematipico changed the title [placeholder] Add a new Astro.metadata global object Apr 22, 2024
@ematipico ematipico added - P2: nice to have Not breaking anything but nice to have (priority) good first issue Good for newcomers. If you need additional guidance, feel free to post in #dev on Discord and removed needs triage Issue needs to be triaged labels Apr 22, 2024
@nnisarggada
Copy link

I'd like to work on this please

@matfire
Copy link

matfire commented Apr 22, 2024

hey, it's the guy from discord

@matthewp
Copy link
Contributor

I might have missed the context on this one. So it looks like this is just the route string, right? What's the use-case for adding this?

@ematipico
Copy link
Member Author

I am assigning to @matfire, he reached out to me on Discord.

@matthewp Chris asked us to expose this information, he needs it for some use case related to the toolbar

@ematipico
Copy link
Member Author

Hi @matfire , I think we are going to hold off on this feature. We are having some internal discussions about the use case, and this is my fault for rushing things without communicating with the rest of the team.

I am going to close for the time being, I hope you haven't started any work in the meantime.

@ematipico ematipico closed this as not planned Won't fix, can't repro, duplicate, stale Apr 22, 2024
@ematipico ematipico removed - P2: nice to have Not breaking anything but nice to have (priority) good first issue Good for newcomers. If you need additional guidance, feel free to post in #dev on Discord labels Apr 22, 2024
@matfire
Copy link

matfire commented Apr 22, 2024

I'd started looking at the codebase and trying to get a feel of how it all comes together :)
No problem; if and when it comes up again, I'd get glad to help

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants