diff --git a/src/docs/src/Workers.md b/src/docs/src/Workers.md index 707aa6087..2b426d04b 100644 --- a/src/docs/src/Workers.md +++ b/src/docs/src/Workers.md @@ -5,7 +5,7 @@ description: Run and manage serverless JavaScript funcitons in the cloud. Serverless Workers are serverless functions that run JavaScript code in the cloud. -Workers run server-side, which makes them a good fit for centralized application data and backend logic. See [Integration with Puter.js](/Workers/router/#integration-with-puterjs) for how worker code accesses Puter resources. +Workers run server-side, which makes them a good fit for centralized application data and backend logic. See [Integration with Puter.js](/Workers/router/#integration-with-puter-js) for how worker code accesses Puter resources. ## Router diff --git a/src/docs/src/Workers/create.md b/src/docs/src/Workers/create.md index 0426f37e6..0d2ef07e7 100644 --- a/src/docs/src/Workers/create.md +++ b/src/docs/src/Workers/create.md @@ -6,13 +6,9 @@ platforms: [websites, apps, nodejs, workers] Creates and deploys a new worker from a JavaScript file containing [router](../router) code. -
To create a worker, you'll need a Puter account with a verified email address.
- -
After a worker is created or updated, full propagation may take between 5 to 30 seconds to fully take effect across all edge servers.
- -
A worker is tied to its name — you create it once and keep that name. To deploy changes, don't call create() again with a new name; instead overwrite the worker's source file (see Updating a worker below). Recreating under a different name leaves the old worker live at its old URL while your callers end up pointing at an orphaned one.
- +A worker is tied to its **name**: you create it **once** and keep that name. To deploy changes, don't call `create()` again with a new name — instead overwrite the worker's source file (see [Updating a worker](#updating-a-worker) below). Recreating under a different name leaves the old worker live at its old URL while your callers end up pointing at an orphaned one. +
To create a worker, you'll need a Puter account with a verified email address. After a worker is created or updated, full propagation may take between 5 and 30 seconds to take effect across all edge servers.
## Syntax diff --git a/src/docs/src/Workers/router.md b/src/docs/src/Workers/router.md index fc9907905..71a1ffeef 100644 --- a/src/docs/src/Workers/router.md +++ b/src/docs/src/Workers/router.md @@ -82,6 +82,8 @@ router.get("/files/*path", async ({ params }) => { }); ``` +A wildcard **must be named** — write `*path` (or any name you like), not a bare `*`. A pattern like `/files/*` won't act as a wildcard: with no name after it, the `*` is treated as a literal character, so the route only matches the exact path `/files/*`. The name is what gives the router a key to expose the captured value on `params`. + A common use is a catch-all route for unmatched paths — define it last so it only runs when nothing else matched (see the [404 Handler](#examples) example below). ## CORS diff --git a/src/docs/src/assets/js/router.js b/src/docs/src/assets/js/router.js index 29ba580d8..7f3f46f76 100755 --- a/src/docs/src/assets/js/router.js +++ b/src/docs/src/assets/js/router.js @@ -93,9 +93,28 @@ $(document).on('click', 'a:not(.skip-insta-load):not([target="_blank"])', functi $('#toc-wrapper').html($(data).find('#toc-wrapper').html()); setTimeout(() => { - $('body').animate({ - scrollTop: 0, - }, 100); + // If the URL has a hash, scroll to that heading instead of the + // top of the page. The browser only does this natively on a full + // page load, so the insta-loader has to handle it here. + const hash = window.location.hash; + let target = null; + if ( hash.length > 1 ) { + const id = hash.slice(1); + try { + // Pasted/hand-typed URLs may contain malformed + // percent-encoding, which makes decodeURIComponent throw. + target = document.getElementById(decodeURIComponent(id)); + } catch ( e ) { + target = document.getElementById(id); + } + } + if ( target ) { + target.scrollIntoView(); + } else { + $('body').animate({ + scrollTop: 0, + }, 100); + } }, 30); //set title of page diff --git a/src/docs/src/deployments.md b/src/docs/src/deployments.md index 87fc575d8..dd5afd2d7 100644 --- a/src/docs/src/deployments.md +++ b/src/docs/src/deployments.md @@ -11,7 +11,7 @@ Puter.js is a regular JavaScript library, so your app deploys like any other web Because Puter.js runs entirely in the browser, there's no special backend to provision. Build your app as you normally would and serve the output from any static or web hosting provider, such as Vercel, Cloudflare Pages, Netlify, or GitHub Pages. -
Your app should be served over HTTPS by a web server, like any of the hosting providers above.
+
Your app should be served by a web server, like any of the hosting providers above.
No extra configuration is required. Your app keeps talking to Puter's services from the browser, wherever it's hosted.