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: ✏️ add docs\concepts\handled-routes_es.md #987

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
96 changes: 96 additions & 0 deletions docs/concepts/handled-routes_es.md
@@ -0,0 +1,96 @@
---
lang: es
position: 100
published: true
title: Controlando Rutas
---

# Controlando Rutas

Cuando tomamos una [ruta no controlada](/docs/concepts/unhandled-routes.md), y ejecuta utilizando el [plugin de router](/docs/Reference/plugins/types/router.md), al terminar su ejecución debería existir una ruta controlada. Esto significa que el plugin toma una ruta como esta:

```html
/user/:id
```

y devuelve algo así:

```typescript
const handledRoutes:HandledRoute[] = [
{
route: '/user/1'
type: 'json'
},
{
route: '/user/2'
type: 'json'
},
...
{
route: '/user/10'
type: 'json'
},
]
```

Tomaremos esas rutas y agregaremos el `config` y `rawRoute` por cada una de ellas.

> **_Nota:_** Todas las rutas no controladas son envíadas al plugin de router, incluso las que no tienen configuración. Aquellas son manejadas por el manejador de rutas por defecto

## La interfaz del manejador de rutas

```typescript
export interface HandledRoute {
/** the _complete_ route */
route: string;
/** the raw route, will be used by puppeteer over the route.route, will be used as is. must include the http(s):// part and eventual params*/
rawRoute?: string;
/** String, must be an existing plugin name. mandatory */
type?: string;
/** the relevant part of the scully-config */
config?: RouteConfig;
/** variables exposed to angular _while rendering only!_ */
exposeToPage?: {
manualIdle?: boolean;
transferState?: Serializable;
[key: string]: Serializable;
};
/** data will be injected into the static page */
injectToPage?: {
[key: string]: Serializable;
};
/** an array with render plugin names that will be executed */
postRenderers?: (string | symbol)[];
/** the path to the file for a content file */
templateFile?: string;
/** optional title, if data holds a title, that will be used instead */
title?: string;
/**
* additional data that will end up in scully.routes.json
* the frontMatter data will be added here too.
*/
data?: RouteData;
/**
* Plugin to use for rendering
* Default to puppeteer
* this support different renders: puppeteer / imgRender / universal / others
*/
renderPlugin?: string | symbol;
}
```

```typescript
export interface RouteConfig {
/** this route does a manual Idle check */
manualIdleCheck?: boolean;
/** type of the route */
type?: string;
/**
* an optional function that will be executed on render.
* Receives the route string, and the config of this route.
*/
preRenderer?: (route: HandledRoute) => Promise<void | false>;
/** Allow in every other setting possible, depends on plugins */
[key: string]: any;
}
```