@mel000000/weweb-dynamic-metadata 1.0.1 → 1.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +61 -27
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
# weweb-dynamic-metadata
|
|
2
2
|
⭐ Build-time SEO metadata generator for WeWeb static exports
|
|
3
3
|
|
|
4
|
-
[](https://www.npmjs.com/package/weweb-dynamic-metadata)
|
|
5
|
-
[](https://www.npmjs.com/package/weweb-dynamic-metadata)
|
|
4
|
+
[](https://www.npmjs.com/package/@mel000000/weweb-dynamic-metadata)
|
|
5
|
+
[](https://www.npmjs.com/package/@mel000000/weweb-dynamic-metadata)
|
|
6
6
|
[](https://opensource.org/licenses/MIT)
|
|
7
7
|
[](https://github.com/Mel000000/weweb-dynamic-metadata)
|
|
8
8
|
|
|
@@ -23,8 +23,9 @@ A build-time tool that generates unique SEO metadata for each dynamic page in yo
|
|
|
23
23
|
- [Prerequisites Checklist](#prerequisites-checklist)
|
|
24
24
|
- [Setup](#setup)
|
|
25
25
|
- [1. Configure Supabase](#1-configure-supabase)
|
|
26
|
-
- [2.
|
|
27
|
-
- [3.
|
|
26
|
+
- [2. Set Up Environment Variables](#2-set-up-environment-variables)
|
|
27
|
+
- [3. Create Config File](#3-create-config-file)
|
|
28
|
+
- [4. Run the Generator](#4-run-the-generator)
|
|
28
29
|
- [How It Works](#how-it-works)
|
|
29
30
|
- [1. Reads Your Config](#1-reads-your-config)
|
|
30
31
|
- [2. Discovers Content IDs](#2-discovers-content-ids)
|
|
@@ -103,15 +104,15 @@ This project provides a **simpler, cheaper, faster alternative**:
|
|
|
103
104
|
|
|
104
105
|
1. Export your WeWeb project (creates `dist/` folder)
|
|
105
106
|
2. Create `weweb.config.js` in your project root
|
|
106
|
-
3. Run `npx weweb-dynamic-metadata`
|
|
107
|
+
3. Run `npx @mel000000/weweb-dynamic-metadata` or `npx weweb-metadata`
|
|
107
108
|
4. Deploy anywhere - each article now has unique metadata!
|
|
108
109
|
|
|
109
110
|
```bash
|
|
110
111
|
# One-time setup
|
|
111
|
-
npm install --save-dev weweb-dynamic-metadata
|
|
112
|
+
npm install --save-dev @mel000000/weweb-dynamic-metadata
|
|
112
113
|
|
|
113
114
|
# Generate metadata (run after each WeWeb export)
|
|
114
|
-
npx weweb-dynamic-metadata
|
|
115
|
+
npx @mel000000/weweb-dynamic-metadata
|
|
115
116
|
|
|
116
117
|
# That's it! Your articles now have unique SEO metadata
|
|
117
118
|
```
|
|
@@ -130,13 +131,13 @@ npx weweb-dynamic-metadata
|
|
|
130
131
|
## Quick Start
|
|
131
132
|
```bash
|
|
132
133
|
# 1. Install the package
|
|
133
|
-
npm install --save-dev weweb-dynamic-metadata
|
|
134
|
+
npm install --save-dev @mel000000/weweb-dynamic-metadata
|
|
134
135
|
|
|
135
136
|
# 2. Create weweb.config.js in your project root
|
|
136
137
|
# (see Setup section below)
|
|
137
138
|
|
|
138
139
|
# 3. Run it!
|
|
139
|
-
npx weweb-dynamic-metadata
|
|
140
|
+
npx @mel000000/weweb-dynamic-metadata
|
|
140
141
|
|
|
141
142
|
# Done! Your articles now have unique metadata
|
|
142
143
|
```
|
|
@@ -144,7 +145,7 @@ npx weweb-dynamic-metadata
|
|
|
144
145
|
|
|
145
146
|
### Prerequisites Checklist
|
|
146
147
|
Before using this package, ensure you have:
|
|
147
|
-
- A WeWeb project exported to static files (has ``
|
|
148
|
+
- A WeWeb project exported to static files (has ``your-page-name/_param/index.html``)
|
|
148
149
|
- Node.js 18 or higher installed
|
|
149
150
|
- A Supabase project with your content
|
|
150
151
|
- Your Supabase URL and anon key ready
|
|
@@ -172,14 +173,39 @@ FOR SELECT
|
|
|
172
173
|
TO anon
|
|
173
174
|
USING (true);
|
|
174
175
|
```
|
|
175
|
-
#### 2.
|
|
176
|
+
#### 2. Get Your Supabase API Key
|
|
177
|
+
In your Supabase dashboard, go to **Project Settings > API Keys**. You'll see two types of keys:
|
|
178
|
+
|
|
179
|
+
| Key Type | Format | When to Use |
|
|
180
|
+
|----------|--------|-------------|
|
|
181
|
+
| **Project URL** | `https://your-project.supabase.co` | Always needed |
|
|
182
|
+
| **anon / publishable key** | `sb_publishable_...` or JWT | Legacy option (being phased out) |
|
|
183
|
+
| **secret key** (recommended) | `sb_secret_...` | ✅ **Recommended for new projects** |
|
|
184
|
+
|
|
185
|
+
> **Note:** Supabase is transitioning away from the legacy anon key. For new projects, use the **secret key** (starts with `sb_secret_...`). If you're using an older project, the anon key will continue working for now, but consider migrating to the new key format.
|
|
186
|
+
|
|
187
|
+
#### 3. Set Up Environment Variables
|
|
188
|
+
Create a ``.env`` file in your project root to store your Supabase credentials securely:
|
|
189
|
+
```.env
|
|
190
|
+
# .env file
|
|
191
|
+
SUPABASE_URL=https://your-project.supabase.co
|
|
192
|
+
SUPABASE_KEY=your-secret-or-anon-key-here
|
|
193
|
+
```
|
|
194
|
+
⚠️ Important: Never commit your .env file to version control. Add it to your .gitignore:
|
|
195
|
+
```text
|
|
196
|
+
# .gitignore
|
|
197
|
+
.env
|
|
198
|
+
```
|
|
199
|
+
The package uses dotenv to automatically load these environment variables when you run the generator.
|
|
200
|
+
|
|
201
|
+
#### 4. Create Config File
|
|
176
202
|
Create ``weweb.config.js`` in your project root:
|
|
177
203
|
```javascript
|
|
178
204
|
export default {
|
|
179
205
|
// Your Supabase configuration
|
|
180
206
|
supabase: {
|
|
181
207
|
url: process.env.SUPABASE_URL,
|
|
182
|
-
|
|
208
|
+
apikey: process.env.SUPABASE_KEY // Works with both anon and secret keys
|
|
183
209
|
},
|
|
184
210
|
|
|
185
211
|
// Optional: Specify your build folder (defaults to ./dist)
|
|
@@ -188,8 +214,8 @@ export default {
|
|
|
188
214
|
// Define your dynamic routes
|
|
189
215
|
pages: [
|
|
190
216
|
{
|
|
191
|
-
route: "/
|
|
192
|
-
table: "
|
|
217
|
+
route: "/your-page-name/:id",
|
|
218
|
+
table: "table-view-name", // Your Supabase table name
|
|
193
219
|
metadata: {
|
|
194
220
|
title: "title", // Database field for title
|
|
195
221
|
content: "excerpt", // Database field for description
|
|
@@ -199,20 +225,12 @@ export default {
|
|
|
199
225
|
]
|
|
200
226
|
};
|
|
201
227
|
```
|
|
202
|
-
####
|
|
228
|
+
#### 5. Run the Generator
|
|
203
229
|
```bash
|
|
204
230
|
# One-time generation
|
|
205
|
-
npx weweb-dynamic-metadata
|
|
231
|
+
npx @mel000000/weweb-dynamic-metadata
|
|
206
232
|
|
|
207
|
-
# Add to your package.json scripts
|
|
208
|
-
{
|
|
209
|
-
"scripts": {
|
|
210
|
-
"build:metadata": "weweb-dynamic-metadata",
|
|
211
|
-
"build": "weweb export && weweb-dynamic-metadata"
|
|
212
|
-
}
|
|
213
|
-
}
|
|
214
233
|
```
|
|
215
|
-
|
|
216
234
|
## How It Works
|
|
217
235
|
|
|
218
236
|
### 1. Reads Your Config
|
|
@@ -268,7 +286,7 @@ flowchart TD
|
|
|
268
286
|
|
|
269
287
|
subgraph Build ["🔵 Build Time - Metadata Generation"]
|
|
270
288
|
direction TB
|
|
271
|
-
E["Run: npx weweb-dynamic-metadata"] --> F
|
|
289
|
+
E["Run: npx @mel000000/weweb-dynamic-metadata"] --> F
|
|
272
290
|
F["Read weweb.config.js"] --> G
|
|
273
291
|
G["Validate configuration"] --> I["For each dynamic route:<br/>e.g., /article/:id"]
|
|
274
292
|
|
|
@@ -328,7 +346,7 @@ dist/ (or your build folder)
|
|
|
328
346
|
│ └── index.html # Same for ALL articles!
|
|
329
347
|
├── assets/
|
|
330
348
|
├── index.html
|
|
331
|
-
└── ...
|
|
349
|
+
└── ...
|
|
332
350
|
```
|
|
333
351
|
|
|
334
352
|
**The Problem**: Every article at `/your-page-name/1`, `/your-page-name/2`, etc. serves the EXACT same HTML file with identical metadata.
|
|
@@ -376,10 +394,26 @@ After running, you'll get a JSON summary:
|
|
|
376
394
|
"duration": "2.34"
|
|
377
395
|
}
|
|
378
396
|
```
|
|
397
|
+
and an overview in the console:
|
|
398
|
+
```text
|
|
399
|
+
[dotenv@17.3.1] injecting env (2) from .env -- tip: 🛡️ auth for agents: https://vestauth.com
|
|
400
|
+
🚀 WeWeb Dynamic Metadata Generator
|
|
401
|
+
|
|
402
|
+
⏭️ Metadata injector already present in: article\_param\index.html
|
|
403
|
+
🧹 Found 2 duplicate injectors, cleaning up...
|
|
404
|
+
|
|
405
|
+
╔════════════════════════════════════════════════╗
|
|
406
|
+
║🎉 GENERATION COMPLETE ║
|
|
407
|
+
╟────────────────────────────────────────────────╢
|
|
408
|
+
║ ⏱️ Duration: 1.31s ║
|
|
409
|
+
║ 📊 Total entries: 9 ║
|
|
410
|
+
║ 📁 Output: article ║
|
|
411
|
+
╚════════════════════════════════════════════════╝
|
|
412
|
+
```
|
|
379
413
|
## Programmatic Usage
|
|
380
414
|
|
|
381
415
|
```javascript
|
|
382
|
-
import { processFiles } from 'weweb-dynamic-metadata';
|
|
416
|
+
import { processFiles } from '@mel000000/weweb-dynamic-metadata';
|
|
383
417
|
|
|
384
418
|
const result = await processFiles();
|
|
385
419
|
console.log(`Generated ${result.totalMetadataEntries} metadata entries`);
|