Skip to content

Commit

Permalink
feat: try type routePattern
Browse files Browse the repository at this point in the history
  • Loading branch information
florian-lefebvre committed Sep 20, 2024
1 parent f430225 commit ccae0e5
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 3 deletions.
2 changes: 2 additions & 0 deletions examples/blog/src/pages/index.astro
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import BaseHead from '../components/BaseHead.astro';
import Header from '../components/Header.astro';
import Footer from '../components/Footer.astro';
import { SITE_TITLE, SITE_DESCRIPTION } from '../consts';
Astro.routePattern
---

<!doctype html>
Expand Down
2 changes: 1 addition & 1 deletion examples/blog/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": "astro/tsconfigs/base",
"extends": "astro/tsconfigs/strict",
"include": [".astro/types.d.ts", "**/*"],
"exclude": ["dist"],
"compilerOptions": {
Expand Down
4 changes: 2 additions & 2 deletions packages/astro/src/types/public/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ export interface AstroGlobal<
* - The value when rendering `src/pages/blog/[slug].astro` will `blog/[slug]`.
* - The value when rendering `src/pages/[...path].astro` will `[...path]`.
*/
routePattern: string;
routePattern: keyof App.RoutePattern extends never ? string : keyof App.RoutePattern;
/**
* The <Astro.self /> element allows a component to reference itself recursively.
*
Expand Down Expand Up @@ -523,5 +523,5 @@ export interface APIContext<
* - The value when rendering `src/pages/blog/[slug].astro` will `blog/[slug]`.
* - The value when rendering `src/pages/[...path].astro` will `[...path]`.
*/
routePattern: string;
routePattern: keyof App.RoutePattern extends never ? string : keyof App.RoutePattern;
}
1 change: 1 addition & 0 deletions packages/astro/src/types/public/extendables.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ declare global {
* Used by middlewares to store information, that can be read by the user via the global `Astro.locals`
*/
export interface Locals {}
export interface RoutePattern {}
}

namespace Astro {
Expand Down

0 comments on commit ccae0e5

Please sign in to comment.