Skip to content
Merged
Show file tree
Hide file tree
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
14 changes: 7 additions & 7 deletions docs/plugins.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ interface RouteConfig {
* an optional function that will be executed on render.
* Receives the route string, and the config of this route.
*/
preRenderer?: (route?: string, config?: RouteConfig) => Promise<void | false>;
preRenderer?: (route: HandledRoute) => Promise<void | false>;
/** Allow in every other setting possible, depends on plugins */
[key: string]: any;
}
Expand Down Expand Up @@ -151,15 +151,15 @@ The `HandledRoute` interface provides the needed properties to develop your own

### postRenderers?: string[]

`postRenderers` - Array of plugin names to be executed after the initial page render. Each of the plugins in this array will be rendered in the order they appear, and they will receive the output HTML from the previous plugin.
Moreover, this array _replaces_ the `defaultPostRenderers` array.
`postRenderers` - Array of plugin names to be executed after the initial page render. Each of the plugins in this array will be rendered in the order they appear, and they will receive the output HTML from the previous plugin.
Moreover, this array _replaces_ the `defaultPostRenderers` array.

```typescript
const defaultPostRenderers = ['seoHrefOptimise'];
const sampleConf: ScullyConfig = {
defaultPostRenderers,
routes: {
/** gets the default postrenderes */
/** gets the default postrenderes */
normalRoute: {
type: 'default'
},
Expand All @@ -175,13 +175,13 @@ const sampleConf: ScullyConfig = {
}
}
};
````
```

The `defaultPostRenderers` and `postRenderers` are designed this way in order to allow you to dispose off the default renderers.
The `defaultPostRenderers` and `postRenderers` are designed this way in order to allow you to dispose off the default renderers.
Moreover, the current design is versatile, flexible, and it makes it easy to opt-out.

Do not forget to add the `defaultPostRenderers`!

### templateFile?: string

`templateFile` - Unrelated to the angular template!. The file's name containing the template to be rendered. This property is specific to contentFolder. It contains the full path to the file that should be used to generate the content. Remember that content will be inserted _after_ the initial rendering.
Expand Down
24 changes: 12 additions & 12 deletions docs/plugins_es.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ lang: es

# Plugins

Scully utiliza un sistema de plugins que permite a los usuarios definir nuevas formas en las que Scully haga el pre-render de la aplicación. Hay cinco tipos
Scully utiliza un sistema de plugins que permite a los usuarios definir nuevas formas en las que Scully haga el pre-render de la aplicación. Hay cinco tipos
principales de plugins:

1. [Router Plugin](#router-plugin)
Expand Down Expand Up @@ -101,7 +101,7 @@ interface RouteConfig {
* una función opcional que se ejecuta al mostrar la página.
* Recive el string de la ruta y su configuración.
*/
preRenderer?: (route?: string, config?: RouteConfig) => Promise<void | false>;
preRenderer?: (route: HandledRoute) => Promise<void | false>;
/** Permitir en cualquier otra configuración posible, depende de los plugins */
[key: string]: any;
}
Expand Down Expand Up @@ -151,15 +151,15 @@ La interface `HandledRoute` proporciona las propiedades necesarias para desarrol

### postRenderers?: string[]

`postRenderers` - Arreglo de nombres de plugins que se ejecutarán desplues de mostrar la página de inicio. Cada uno de los plugins en este arreglo se mostrarán en el orden en el que aparecen y recibiran el HTML resultante del plugin anterior.
Además, teste arreglo _reemplaza_ el arreglo `defaultPostRenderers`.
`postRenderers` - Arreglo de nombres de plugins que se ejecutarán desplues de mostrar la página de inicio. Cada uno de los plugins en este arreglo se mostrarán en el orden en el que aparecen y recibiran el HTML resultante del plugin anterior.
Además, teste arreglo _reemplaza_ el arreglo `defaultPostRenderers`.

```typescript
const defaultPostRenderers = ['seoHrefOptimise'];
const sampleConf: ScullyConfig = {
defaultPostRenderers,
routes: {
/** obtiene los postrenderes por defecto */
/** obtiene los postrenderes por defecto */
normalRoute: {
type: 'default'
},
Expand All @@ -175,13 +175,13 @@ const sampleConf: ScullyConfig = {
}
}
};
````
```

Los `defaultPostRenderers` y los `postRenderers` están diseñados de esta manera con la finalidad de permitirle deshacerse de los renderers por defecto.
Los `defaultPostRenderers` y los `postRenderers` están diseñados de esta manera con la finalidad de permitirle deshacerse de los renderers por defecto.
Además, este diseño actual de los renders se adapta fácilmente a los diversos casos de uso.

!No olvide agregar los `defaultPostRenderers`!

### templateFile?: string

`templateFile` - ¡No relacionado con la plantilla Angular! El nombre del archivo que contiene la plantilla que se mostrará. Esta propiedad es específica del contentFolder. Contiene el "path" completo al archivo que debe ser utilizado para generar el contenido. Recuerde que dicho contenido será insertado _despues_ del render inicial.
Expand Down Expand Up @@ -324,7 +324,7 @@ module.exports.smileEmojiPlugin = smileEmojiPlugin;
## File Handler Plugin

Un **file handler plugin** es usado por el plugin `contentFolder` durante el proceso de `render`. El plugin `contentFolder`
procesa las carpetas con archivos markdownu otro tipo de archivo que contenga. El `render` procesa cualquier plugin `fileHandler` existente para cualquier tipo de extensión de archivo.
procesa las carpetas con archivos markdownu otro tipo de archivo que contenga. El `render` procesa cualquier plugin `fileHandler` existente para cualquier tipo de extensión de archivo.

Scully tiene dos plugins `fileHandler`. El [markdown plugin](../scully/fileHanderPlugins/markdown.ts) y
el [asciidoc plugin](../scully/fileHanderPlugins/asciidoc.ts). Estos plugins manejan y procesan el
Expand All @@ -334,7 +334,7 @@ Si desea soportar archivos `.docx`, `.csv`, o de cualquier otro tipo; es necesar
El plugin `contentFolder` se encarga de mostrar el contenido del tipo de archivo correspondiente. Sin embargo, si los archivos necesitan ser transformados despues de que el plugin `contentFolder` los muestre;
Es necesario un plugin de tipo `fileHandler`.

### Interface File Handler Plugin
### Interface File Handler Plugin

Un **file handler plugin** es una función que regresa una `Promise<string>`. La interface se muestra a continuación:

Expand All @@ -357,7 +357,7 @@ registerPlugin('fileHandler', 'csv', { handler: csvFilePlugin });
module.exports.csvFilePlugin = csvFilePlugin;
```

### Ejemplos deFile Handler Plugin
### Ejemplos deFile Handler Plugin

Aquí hay algunos links de **render plugins** ya incluidos en Scully:

Expand All @@ -370,4 +370,4 @@ Este tipo de plugin es llamado automáticamente despues de que todas las rutas h

## AllDone Plugin

Un plugin de tipo `allDone` es parecido a un plugin `routeDiscoveryDone` con la expeción de que se llama _después_ de que Scully termina de ejecutar todos los procesos.
Un plugin de tipo `allDone` es parecido a un plugin `routeDiscoveryDone` con la expeción de que se llama _después_ de que Scully termina de ejecutar todos los procesos.
2 changes: 1 addition & 1 deletion libs/scully/src/lib/renderPlugins/executePlugins.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export const executePluginsForRoute = async (route: HandledRoute) => {
const preRender = route.config && route.config.preRenderer;
if (preRender) {
try {
const prResult = await preRender(route.route, route.config);
const prResult = await preRender(route);
if (prResult === false) {
logError(
`prerender stopped rendering for "${yellow(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export const addOptionalRoutes = async (
? config.postRenderers
: undefined;
/** adding in the postrenderes. Note that the plugin might choose to overwrite the ones that come from the config */
const r = (await routePluginHandler(cur)).map((row) =>
const r = (await routePluginHandler(cur)).map(row =>
postRenderers ? { postRenderers, ...row, config } : { ...row, config }
);
x.push(...r);
Expand All @@ -42,7 +42,7 @@ interface RouteConfig {
* an optional function that will be executed on render.
* Receives the route string, and the config of this route.
*/
preRenderer?: (route?: string, config?: RouteConfig) => Promise<void | false>;
preRenderer?: (route: HandledRoute) => Promise<void | false>;
/** Allow in every other setting possible, depends on plugins */
[key: string]: any;
}
Expand Down Expand Up @@ -95,7 +95,7 @@ async function routePluginHandler(route: string): Promise<HandledRoute[]> {
route,
conf
) as unknown)) as HandledRoute[];
generatedRoutes.forEach((handledRoute) => {
generatedRoutes.forEach(handledRoute => {
if (!handledRoute.route.startsWith('/')) {
logWarn(
`The plugin '${
Expand Down
Loading