Skip to content

Fix inconsistent locals usage in middleware code examples#14106

Merged
ArmandPhilippot merged 2 commits into
withastro:mainfrom
morinokami:middleware-0
Jun 20, 2026
Merged

Fix inconsistent locals usage in middleware code examples#14106
ArmandPhilippot merged 2 commits into
withastro:mainfrom
morinokami:middleware-0

Conversation

@morinokami

Copy link
Copy Markdown
Member

Description (required)

The middleware examples reference locals properties (property, orders) that are never set, which can confuse readers. This PR sets every value the example .astro files read so the snippets are self-consistent and runnable, and fixes two latent bugs in the second example (assigning .name on an uninitialized user, and referencing an undefined locals instead of context.locals).

Related issues & labels (optional)

  • Closes #
  • Suggested label:

@astrobot-houston

astrobot-houston commented Jun 20, 2026

Copy link
Copy Markdown
Contributor

Lunaria Status Overview

🌕 This pull request will trigger status changes.

Learn more

By default, every PR changing files present in the Lunaria configuration's files property will be considered and trigger status changes accordingly.

You can change this by adding one of the keywords present in the ignoreKeywords property in your Lunaria configuration file in the PR's title (ignoring all files) or by including a tracker directive in the merged commit's description.

Tracked Files

File Note
en/guides/middleware.mdx Source changed, localizations will be marked as outdated.
Warnings reference
Icon Description
🔄️ The source for this localization has been updated since the creation of this pull request, make sure all changes in the source have been applied.

@github-actions

github-actions Bot commented Jun 20, 2026

Copy link
Copy Markdown

Preview deployment

✅ Deployment complete!

@ArmandPhilippot ArmandPhilippot left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, really helpful! 🙌🏽 And, you caught more things than me!

Comment thread src/content/docs/en/guides/middleware.mdx
@ArmandPhilippot ArmandPhilippot added the code snippet update Updates a code sample: typo, outdated code etc. label Jun 20, 2026
@ArmandPhilippot ArmandPhilippot merged commit 14c4705 into withastro:main Jun 20, 2026
9 checks passed
HiDeoo added a commit that referenced this pull request Jun 22, 2026
* main:
  Fix inconsistent locals usage in middleware code examples (#14106)
  i18n(ko-KR): update multiple pages (#14100)
  Fix TypeScript errors in "Add content to your site" code snippets (#14091)
  Fix TypeScript errors in "Server rendering" code snippets (#14092)
  Fix TypeScript errors in "Build your UI" code snippets (#14090)
  i18n(pt-br): translate recipes/modified-time.mdx (#14096)
  i18n(pt-br): translate recipes/external-links.mdx (#14097)
  i18n(pt-br): fix broken link (#14093)
  i18n(fr): update `guides/i18n` & `modules/astro-i18n` (#14087)
  i18n(pt-br): bring astro:config module reference up-to-date (#14085)
  i18n(pt-br): translate recipes/reading-time.mdx (#14088)
  i18n(ko-KR): update `astro-i18n`, `internationalization` (#14086)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

code snippet update Updates a code sample: typo, outdated code etc.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants