Switch demo URL to hosted, docs improvements

This commit is contained in:
Tiago Rangel
2025-01-14 16:07:02 +00:00
parent 59ddae287e
commit 87592cb554
4 changed files with 6 additions and 26 deletions
+2 -2
View File
@@ -27,14 +27,14 @@ export default defineConfig({
nav: [
{ text: "Home", link: "/" },
{ text: "Docs", link: "/guide" },
{ text: "Demo", link: "/guide/demo.md" },
{ text: "Demo", link: "https://cap-starter.glitch.me/" },
],
sidebar: [
{ text: "Quickstart", link: "/guide/index.md" },
{ text: "Effectiveness", link: "/guide/effectiveness.md" },
{ text: "Floating mode", link: "/guide/floating.md" },
{ text: "Demo", link: "/guide/demo.md" },
{ text: "Demo", link: "https://cap-starter.glitch.me/" },
],
socialLinks: [
-21
View File
@@ -1,21 +0,0 @@
# Demo
**Note:** The docs demo might not work. Please download and use the code from the [demo folder in the repo](https://github.com/tiagorangel1/cap/tree/main/demo) instead — it includes all of the setup needed with an Express.js server.
### Normal button:
<Demo />
```html
<cap-widget onsolve="alert(`Verification token: ${event.detail.token}`)"></cap-widget>
```
### Floating button:
<Demo-floating />
```html
<cap-widget id="floating" onsolve="alert(`Verification token: ${event.detail.token}`)"></cap-widget>
<button data-cap-floating="#floating" data-cap-floating-offset="8" data-cap-floating-position="bottom" class="demo-button">Trigger Floating</button>
```
+3 -2
View File
@@ -46,8 +46,6 @@ widget.addEventListener("solve", function (e) {
Alternatively, you can use `onsolve=""` directly within the widget or wrap the widget in a `<form></form>` (where Cap will automatically submit the token alongside other form data).
## Server-side
Cap is fully self-hosted, so you'll need to start a server with the Cap API running at the same URL as specified in the `data-cap-api-endpoint` attribute. This is easy since we've already pre-made a library to help you generate and validate challenges for you.
@@ -57,6 +55,9 @@ Start by installing it using npm or bun:
npm i @cap.js/server
```
> [!NOTE]
> It is recommended to use at least Node.js 14 or Bun 1.0.0. You might experience multiple issues on older versions of these runtimes.
Now, you'll need to change your server code to add the routes that Cap needs to work. Here's an example with Express.js:
```js
+1 -1
View File
@@ -12,7 +12,7 @@ hero:
link: /guide
- theme: alt
text: Demo
link: /guide/demo.md
link: https://cap-starter.glitch.me/
features:
- icon: ⚡️