Merge branch 'master' into preview

This commit is contained in:
ccbikai 2024-12-08 11:44:47 +08:00
commit 73649d4ab0
8 changed files with 36 additions and 28 deletions

View file

@ -1 +1 @@
v20.11 20.11.0

View file

@ -71,7 +71,8 @@ We welcome your contributions and PRs.
- [Sink Tool](https://github.com/zhuzhuyule/sink-extension) - [Sink Tool](https://github.com/zhuzhuyule/sink-extension)
- [x] Raycast Extension - [x] Raycast Extension
- [Raycast-Sink](https://github.com/foru17/raycast-sink) - [Raycast-Sink](https://github.com/foru17/raycast-sink)
- [ ] Apple Shortcuts - [x] Apple Shortcuts
- [Sink Shortcuts](https://s.search1api.com/sink001)
- [ ] Enhanced Link Management (with Cloudflare D1) - [ ] Enhanced Link Management (with Cloudflare D1)
- [ ] Analytics Enhancements (Support for merging filter conditions) - [ ] Analytics Enhancements (Support for merging filter conditions)
- [ ] Dashboard Performance Optimization (Infinite loading) - [ ] Dashboard Performance Optimization (Infinite loading)
@ -80,22 +81,26 @@ We welcome your contributions and PRs.
## 🏗️ Deployment ## 🏗️ Deployment
> Video tutorial: <https://www.youtube.com/watch?v=MkU23U2VE9E> > Video tutorial: [Watch here](https://www.youtube.com/watch?v=MkU23U2VE9E)
1. [Fork](https://github.com/ccbikai/Sink/fork) the repository to your GitHub account. 1. [Fork](https://github.com/ccbikai/Sink/fork) the repository to your GitHub account.
2. Create a [Cloudflare Pages](https://developers.cloudflare.com/pages/) project. 2. Create a project in [Cloudflare Pages](https://developers.cloudflare.com/pages/).
3. Select the `Sink` repository and the `Nuxt.js` preset. 3. Select the `Sink` repository and choose the `Nuxt.js` preset.
4. Configure environment variables. 4. Configure the following environment variables:
1. `NUXT_SITE_TOKEN` length must exceed **8**. - `NUXT_SITE_TOKEN`: Must be longer than **8** characters. This token grants access to your dashboard.
2. `NUXT_CF_ACCOUNT_ID` [find your account ID](https://developers.cloudflare.com/fundamentals/setup/find-account-and-zone-ids/). - `NUXT_CF_ACCOUNT_ID`: Locate your [account ID](https://developers.cloudflare.com/fundamentals/setup/find-account-and-zone-ids/).
3. `NUXT_CF_API_TOKEN` Create a [Cloudflare API token](https://developers.cloudflare.com/fundamentals/api/get-started/create-token/). This token requires `Account.Account Analytics` permissions at the very least. [Reference.](https://developers.cloudflare.com/analytics/analytics-engine/sql-api/#authentication). - `NUXT_CF_API_TOKEN`: Create a [Cloudflare API token](https://developers.cloudflare.com/fundamentals/api/get-started/create-token/) with at least `Account.Account Analytics` permissions. [See reference.](https://developers.cloudflare.com/analytics/analytics-engine/sql-api/#authentication)
5. Save and deploy. 5. Save and deploy the project.
6. Cancel the deployment, navigate to `Settings` -> `Functions`. 6. Cancel the deployment, then navigate to **Settings** -> **Bindings** -> **Add**:
1. KV namespace bindings. Bind the variable name `KV` to a KV namespace. - **KV Namespace**: Bind the variable name `KV` to a KV namespace (create a new one under **Workers & Pages** -> **KV**).
2. Workers AI Bindings. Bind the variable name `AI` to the Workers AI Catalog. _Optional_ - **Workers AI** (_Optional_): Bind the variable name `AI` to the Workers AI Catalog.
3. Analytics Engine bindings. Bind the variable name `ANALYTICS` to the `sink` dataset, and enable [Cloudflare Analytics Engine beta](https://developers.cloudflare.com/analytics/analytics-engine/get-started/) for your account. - **Analytics Engine**:
7. Redeploy. - In **Workers & Pages**, go to **Account details** on the right side, find `Analytics Engine`, and click `Set up` to enable the free version.
- Return to **Settings** -> **Bindings** -> **Add** and select **Analytics engine**.
- Bind the variable name `ANALYTICS` to the `sink` dataset.
7. Redeploy the project.
## ⚒️ Configuration ## ⚒️ Configuration

View file

@ -1,11 +1,11 @@
export default defineAppConfig({ export default defineAppConfig({
title: 'Sink', title: 'Sink',
twitter: 'https://x.com/0xKaiBi',
github: 'https://github.com/ccbikai/sink',
email: 'sink.cool@miantiao.me', email: 'sink.cool@miantiao.me',
telegram: 'https://t.me/htmlzone', github: 'https://github.com/ccbikai/sink',
mastodon: 'https://c.im/@mt', twitter: 'https://sink.cool/kai',
blog: 'https://mt.ci', telegram: 'https://sink.cool/telegram',
mastodon: 'https://sink.cool/mastodon',
blog: 'https://sink.cool/blog',
description: 'A Simple / Speedy / Secure Link Shortener with Analytics, 100% run on Cloudflare.', description: 'A Simple / Speedy / Secure Link Shortener with Analytics, 100% run on Cloudflare.',
image: 'https://sink.cool/banner.png', image: 'https://sink.cool/banner.png',
previewTTL: 24 * 3600, // 24h previewTTL: 24 * 3600, // 24h

View file

@ -5,8 +5,8 @@
Please check the Cloudflare KV bindings, the KV environment variable name should be all uppercase letters. Please check the Cloudflare KV bindings, the KV environment variable name should be all uppercase letters.
<details> <details>
<summary><b>Screenshots</b></summary> <summary><b>Screenshot</b></summary>
<img alt="KV" src="https://github.com/ccbikai/Sink/assets/21292149/3b7d584c-3afe-4d24-8c9e-e0d549c47438"/> <img alt="KV Bindings setting in Cloudflare" src="/docs/images/faqs-kv.png"/>
</details> </details>
## 2. Why can't I log in? ## 2. Why can't I log in?
@ -15,17 +15,20 @@ Please check if `NUXT_SITE_TOKEN` is set to pure numbers, Sink does not support
## 3. Why can't I see the analytics data? ## 3. Why can't I see the analytics data?
Analytics data needs to read Cloudflare's data, check if `NUXT_CF_ACCOUNT_ID` and `NUXT_CF_API_TOKEN` are correctly configured. Pay attention to the account id deployment zone id, whether the Worker analytics engine is turned on. Analytics data requires access to Cloudflares settings:
1. Verify `NUXT_CF_ACCOUNT_ID` and `NUXT_CF_API_TOKEN` are configured correctly (ensure the Account ID matches the deployment zone ID).
2. Check that the Worker analytics engine is enabled.
<details> <details>
<summary><b>Screenshots</b></summary> <summary><b>Screenshot</b></summary>
<img alt="Analytics" src="https://github.com/ccbikai/Sink/assets/21292149/aceede26-5aa1-400c-8d06-d6adc46bdcb8"/> <img alt="Analytics engine Bindings setting in Cloudflare " src="/docs/images/faqs-Analytics_engine.png"/>
</details> </details>
## 4. I don't want the current homepage? Can it be redirected to my blog? ## 4. I don't want the current homepage? Can it be redirected to my blog?
Of course. Please set the environment variable `NUXT_HOME_URL` to your blog or official website address. Of course. Please set the environment variable `NUXT_HOME_URL` to your blog or official website address.
## 5. Why can't I see the statistics after deploying with NuxtHub? ## 5. Why can't I see statistics after deploying with NuxtHub?
NuxtHub's ANALYTICS points to its dataset, you need to set the `NUXT_DATASET` environment variable to point to the same dataset. NuxtHub's ANALYTICS points to its dataset, you need to set the `NUXT_DATASET` environment variable to point to the same dataset.

Binary file not shown.

After

Width:  |  Height:  |  Size: 52 KiB

BIN
docs/images/faqs-kv.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 52 KiB

View file

@ -1,7 +1,7 @@
{ {
"name": "sink", "name": "sink",
"type": "module", "type": "module",
"version": "0.1.4", "version": "0.1.5",
"private": true, "private": true,
"packageManager": "pnpm@9.7.1", "packageManager": "pnpm@9.7.1",
"engines": { "engines": {

View file

@ -10,7 +10,7 @@ export default eventHandler(async (event) => {
const list = await KV.list({ const list = await KV.list({
prefix: `link:`, prefix: `link:`,
limit, limit,
cursor, cursor: cursor || undefined,
}) })
if (Array.isArray(list.keys)) { if (Array.isArray(list.keys)) {
list.links = await Promise.all(list.keys.map(async (key: { name: string }) => { list.links = await Promise.all(list.keys.map(async (key: { name: string }) => {