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

docs(content): How to change statusCode using RouteMeta #1410

Merged
merged 1 commit into from
Oct 17, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 27 additions & 5 deletions apps/docs-app/docs/features/routing/overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,17 @@ Route components **must** be defined as the default export and all route compone

There are 5 primary types of routes:

- [Index Routes](#index-routes)
- [Static Routes](#static-routes)
- [Dynamic Routes](#dynamic-routes)
- [Layout Routes](#layout-routes)
- [Catch-all Routes](#catch-all-routes)
- [Routing](#routing)
- [Defining Routes](#defining-routes)
- [Index Routes](#index-routes)
- [Static Routes](#static-routes)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

markdown linter did this.

- [Route Groups](#route-groups)
- [Dynamic Routes](#dynamic-routes)
- [Using Route Component Input Bindings](#using-route-component-input-bindings)
- [Layout Routes](#layout-routes)
- [Pathless Layout Routes](#pathless-layout-routes)
- [Catch-all Routes](#catch-all-routes)
- [Putting It All Together](#putting-it-all-together)

These routes can be combined in different ways to build URLs for navigation.

Expand Down Expand Up @@ -263,6 +269,22 @@ The example route below in `src/app/pages/[...page-not-found].page.ts` defines a
```ts
import { Component } from '@angular/core';
import { RouterLink } from '@angular/router';
import { injectResponse } from '@analogjs/router/tokens';
import { RouteMeta } from '@analogjs/router';

export const routeMeta: RouteMeta = {
title: 'Page Not Found',
canActivate: [
() => {
const response = injectResponse();
if (import.meta.env.SSR && response) {
response.statusCode = 404;
response.end();
}
return true;
},
],
};

@Component({
standalone: true,
Expand Down
Loading