diff --git a/src/content/docs/workers/configuration/cron-triggers.mdx b/src/content/docs/workers/configuration/cron-triggers.mdx index 1b028e7b72d8ab2..8e777a6771fdc45 100644 --- a/src/content/docs/workers/configuration/cron-triggers.mdx +++ b/src/content/docs/workers/configuration/cron-triggers.mdx @@ -5,7 +5,7 @@ head: [] description: Enable your Worker to be executed on a schedule. --- -import { WranglerConfig } from "~/components"; +import { Render, WranglerConfig } from "~/components"; ## Background @@ -27,7 +27,9 @@ Cron Triggers execute on UTC time. To respond to a Cron Trigger, you must add a [`"scheduled"` handler](/workers/runtime-apis/handlers/scheduled/) to your Worker. -Refer to the following examples to write your code: + + +Refer to the following additional examples to write your code: - [Setting Cron Triggers](/workers/examples/cron-trigger/) - [Multiple Cron Triggers](/workers/examples/multiple-cron-triggers/) @@ -57,8 +59,6 @@ crons = [ "*/3 * * * *", "0 15 1 * *", "59 23 LW * *" ] You also can set a different Cron Trigger for each [environment](/workers/wrangler/environments/) in your [Wrangler configuration file](/workers/wrangler/configuration/). You need to put the `[triggers]` table under your chosen environment. For example: - - ```toml diff --git a/src/content/docs/workers/examples/cron-trigger.mdx b/src/content/docs/workers/examples/cron-trigger.mdx index 8bf9e34325dcadf..87b5b10c67635a4 100644 --- a/src/content/docs/workers/examples/cron-trigger.mdx +++ b/src/content/docs/workers/examples/cron-trigger.mdx @@ -13,34 +13,9 @@ sidebar: description: Set a Cron Trigger for your Worker. --- -import { TabItem, Tabs, WranglerConfig } from "~/components"; +import { Render, TabItem, Tabs, WranglerConfig } from "~/components"; - - -```js -export default { - async scheduled(event, env, ctx) { - console.log("cron processed"); - }, -}; -``` - - - -```ts -interface Env {} -export default { - async scheduled( - controller: ScheduledController, - env: Env, - ctx: ExecutionContext, - ) { - console.log("cron processed"); - }, -}; -``` - - + ## Set Cron Triggers in Wrangler @@ -63,8 +38,6 @@ crons = ["0 * * * *"] You also can set a different Cron Trigger for each [environment](/workers/wrangler/environments/) in your [Wrangler configuration file](/workers/wrangler/configuration/). You need to put the `[triggers]` table under your chosen environment. For example: - - ```toml diff --git a/src/content/partials/workers/cron-trigger-example.mdx b/src/content/partials/workers/cron-trigger-example.mdx new file mode 100644 index 000000000000000..e75e7b91757b686 --- /dev/null +++ b/src/content/partials/workers/cron-trigger-example.mdx @@ -0,0 +1,20 @@ +--- +{} +--- + +import { TypeScriptExample } from "~/components"; + + +```ts +interface Env {} +export default { + async scheduled( + controller: ScheduledController, + env: Env, + ctx: ExecutionContext, + ) { + console.log("cron processed"); + }, +}; +``` +