From ffa845ab0d47b6b30b39949f960ba3f880571cf3 Mon Sep 17 00:00:00 2001 From: Christian Svensson Date: Tue, 4 Nov 2025 16:03:51 +0100 Subject: [PATCH] docs(core): correct example code block formatting (#3601) The example for the CSP middleware looks a bit broken currently on JSR, due to the `@example` markdown is not wrapped in a code block. image ## Changes - Improves formatting a bit, to be less compact - Wraps the example in a code block ` ```ts ` - Adds a title to the `@example` - "Basic usage" - To avoid the example being labeled as "Example1" on JSR --- packages/fresh/src/middlewares/csp.ts | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/packages/fresh/src/middlewares/csp.ts b/packages/fresh/src/middlewares/csp.ts index 9b909e2e..6fd91c73 100644 --- a/packages/fresh/src/middlewares/csp.ts +++ b/packages/fresh/src/middlewares/csp.ts @@ -12,16 +12,21 @@ export interface CSPOptions { csp?: string[]; } -/** Middleware to set Content-Security-Policy headers +/** + * Middleware to set Content-Security-Policy headers + * * @param options - CSP options - * @example + * + * @example Basic usage + * ```ts * app.use(csp({ * reportOnly: true, * reportTo: '/api/csp-reports', * csp: [ - * "script-src 'self' 'unsafe-inline' 'https://example.com'", + * "script-src 'self' 'unsafe-inline' 'https://example.com'", * ], * })); + * ``` */ export function csp(options: CSPOptions = {}): Middleware { const {