File tree Expand file tree Collapse file tree 2 files changed +15
-11
lines changed Expand file tree Collapse file tree 2 files changed +15
-11
lines changed Original file line number Diff line number Diff line change 11/**
2- * Merge an array of multiple handlers into one. The `resolve` passed
3- * to the first handler will call the second handler, and so on,
4- * until the last handler calls the framework.
5- *
6- * If handlers use the `transformPageChunk` option, the functions
7- * will be 'chained', meaning a transform function specified in
8- * the first handler will be applied to later handlers, and
9- * multiple transformations can be applied.
10- *
112 * @param {...import('types').Handle } handlers
123 * @returns {import('types').Handle }
134 */
Original file line number Diff line number Diff line change @@ -300,15 +300,26 @@ declare module '@sveltejs/kit/hooks' {
300300 * /** @type {import('@sveltejs/kit').Handle } *\/
301301 * async function first({ event, resolve }) {
302302 * console.log('first pre-processing');
303- * const result = await resolve(event);
303+ * const result = await resolve(event, {
304+ * transformPageChunk: ({ html }) => {
305+ * // transforms are applied in reverse order
306+ * console.log('first transform');
307+ * return html;
308+ * }
309+ * });
304310 * console.log('first post-processing');
305311 * return result;
306312 * }
307313 *
308314 * /** @type {import('@sveltejs/kit').Handle } *\/
309315 * async function second({ event, resolve }) {
310316 * console.log('second pre-processing');
311- * const result = await resolve(event);
317+ * const result = await resolve(event, {
318+ * transformPageChunk: ({ html }) => {
319+ * console.log('second transform');
320+ * return html;
321+ * }
322+ * });
312323 * console.log('second post-processing');
313324 * return result;
314325 * }
@@ -321,6 +332,8 @@ declare module '@sveltejs/kit/hooks' {
321332 * ```
322333 * first pre-processing
323334 * second pre-processing
335+ * second transform
336+ * first transform
324337 * second post-processing
325338 * first post-processing
326339 * ```
You can’t perform that action at this time.
0 commit comments