@seo-console/package 1.0.2 → 1.0.3

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.
Files changed (2) hide show
  1. package/README.md +208 -57
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # SEO Console Package
2
2
 
3
- A production-ready SEO validation and management system for Next.js applications. Install this package into your existing Next.js project to add SEO metadata management capabilities.
3
+ A production-ready SEO validation and management system for Next.js applications. This package provides a complete admin interface for managing SEO metadata, accessible through a new tab in your admin section.
4
4
 
5
5
  ## Installation
6
6
 
@@ -8,78 +8,249 @@ A production-ready SEO validation and management system for Next.js applications
8
8
  npm install @seo-console/package
9
9
  ```
10
10
 
11
- ## Quick Start
11
+ ## Setup Guide
12
12
 
13
- ### 1. Storage Options
13
+ ### Step 1: Configure Storage (Optional)
14
14
 
15
- The package supports multiple storage backends. **File storage is the default** and requires no database setup.
15
+ The package uses **file storage by default** (no database required). SEO records are stored in `seo-records.json`.
16
16
 
17
- #### Option A: File Storage (Default - No Database Required)
18
-
19
- File storage is the default option. SEO records are stored in a JSON file (`seo-records.json` by default).
20
-
21
- No configuration needed! The package will automatically use file storage if no Supabase credentials are provided.
22
-
23
- To customize the file path, set an environment variable:
17
+ To customize the storage location, add to your `.env.local`:
24
18
 
25
19
  ```env
26
20
  SEO_CONSOLE_STORAGE_PATH=./data/seo-records.json
27
21
  ```
28
22
 
29
- #### Option B: Supabase Storage (Optional)
30
-
31
- If you prefer using Supabase as your storage backend:
32
-
33
- 1. Create a Supabase project at [supabase.com](https://supabase.com)
34
- 2. Run the database migrations from `migrations/`:
35
- - `001_initial_schema.sql` - User profiles
36
- - `002_seo_records_schema.sql` - SEO records table
37
- 3. Add environment variables:
23
+ **Optional:** If you prefer Supabase, set these environment variables:
38
24
 
39
25
  ```env
40
26
  NEXT_PUBLIC_SUPABASE_URL=https://your-project.supabase.co
41
27
  NEXT_PUBLIC_SUPABASE_ANON_KEY=your-anon-key
42
28
  ```
43
29
 
44
- The package will automatically detect Supabase credentials and use Supabase storage instead of file storage.
30
+ The package will automatically detect and use Supabase if these are set.
45
31
 
46
- ### 2. Use in Your Next.js App
32
+ ### Step 2: Create API Routes
47
33
 
48
- #### Add SEO Metadata to Pages
34
+ Create the following API route in your Next.js app:
35
+
36
+ **`app/api/seo-records/route.ts`:**
49
37
 
50
38
  ```typescript
51
- // app/blog/[slug]/page.tsx
52
- import { useGenerateMetadata } from "@seo-console/package/hooks";
39
+ import { NextRequest, NextResponse } from "next/server";
40
+ import {
41
+ getSEORecords,
42
+ getSEORecordByRoute,
43
+ createSEORecord,
44
+ updateSEORecord,
45
+ deleteSEORecord
46
+ } from "@seo-console/package/server";
53
47
 
54
- export async function generateMetadata({ params }: { params: { slug: string } }) {
55
- const metadata = await useGenerateMetadata({
56
- routePath: `/blog/${params.slug}`,
57
- });
58
- return metadata;
48
+ // GET - Fetch all SEO records
49
+ export async function GET() {
50
+ try {
51
+ const result = await getSEORecords();
52
+ if (!result.success) {
53
+ return NextResponse.json({ error: result.error?.message }, { status: 500 });
54
+ }
55
+ return NextResponse.json({ data: result.data || [] });
56
+ } catch (error) {
57
+ return NextResponse.json(
58
+ { error: error instanceof Error ? error.message : "Failed to fetch records" },
59
+ { status: 500 }
60
+ );
61
+ }
62
+ }
63
+
64
+ // POST - Create a new SEO record
65
+ export async function POST(request: NextRequest) {
66
+ try {
67
+ const body = await request.json();
68
+ const result = await createSEORecord(body);
69
+ if (!result.success) {
70
+ return NextResponse.json({ error: result.error?.message }, { status: 500 });
71
+ }
72
+ return NextResponse.json({ data: result.data });
73
+ } catch (error) {
74
+ return NextResponse.json(
75
+ { error: error instanceof Error ? error.message : "Failed to create record" },
76
+ { status: 500 }
77
+ );
78
+ }
79
+ }
80
+
81
+ // PUT - Update an existing SEO record
82
+ export async function PUT(request: NextRequest) {
83
+ try {
84
+ const body = await request.json();
85
+ const result = await updateSEORecord(body);
86
+ if (!result.success) {
87
+ return NextResponse.json({ error: result.error?.message }, { status: 500 });
88
+ }
89
+ return NextResponse.json({ data: result.data });
90
+ } catch (error) {
91
+ return NextResponse.json(
92
+ { error: error instanceof Error ? error.message : "Failed to update record" },
93
+ { status: 500 }
94
+ );
95
+ }
96
+ }
97
+
98
+ // DELETE - Delete an SEO record
99
+ export async function DELETE(request: NextRequest) {
100
+ try {
101
+ const { searchParams } = new URL(request.url);
102
+ const id = searchParams.get("id");
103
+ if (!id) {
104
+ return NextResponse.json({ error: "ID is required" }, { status: 400 });
105
+ }
106
+ const result = await deleteSEORecord(id);
107
+ if (!result.success) {
108
+ return NextResponse.json({ error: result.error?.message }, { status: 500 });
109
+ }
110
+ return NextResponse.json({ success: true });
111
+ } catch (error) {
112
+ return NextResponse.json(
113
+ { error: error instanceof Error ? error.message : "Failed to delete record" },
114
+ { status: 500 }
115
+ );
116
+ }
59
117
  }
60
118
  ```
61
119
 
62
- #### Add Admin Components to Your Admin Page
120
+ ### Step 3: Add Admin Pages
121
+
122
+ Create the admin SEO section in your Next.js app. This will be accessible as a new tab in your admin area.
123
+
124
+ **Create the directory structure:**
125
+
126
+ ```
127
+ app/admin/seo/
128
+ ├── page.tsx (Main dashboard)
129
+ ├── editor/
130
+ │ └── page.tsx (SEO record editor)
131
+ ├── reports/
132
+ │ └── page.tsx (Reports & analytics)
133
+ ├── search/
134
+ │ └── page.tsx (Search & validation)
135
+ └── settings/
136
+ └── page.tsx (Settings)
137
+ ```
138
+
139
+ **`app/admin/seo/page.tsx` (Main Dashboard):**
63
140
 
64
141
  ```typescript
65
- // app/admin/seo/page.tsx
66
142
  "use client";
67
143
 
68
- import { SEORecordList, SEORecordForm } from "@seo-console/package/components";
69
- import { ValidationDashboard } from "@seo-console/package/components";
144
+ import { useState, useEffect } from "react";
145
+ import { useRouter } from "next/navigation";
146
+ import type { SEORecord } from "@seo-console/package";
70
147
 
71
148
  export default function SEOAdminPage() {
149
+ const router = useRouter();
150
+ const [records, setRecords] = useState<SEORecord[]>([]);
151
+ const [loading, setLoading] = useState(true);
152
+
153
+ useEffect(() => {
154
+ fetch("/api/seo-records")
155
+ .then((res) => res.json())
156
+ .then((data) => {
157
+ setRecords(data.data || []);
158
+ setLoading(false);
159
+ })
160
+ .catch(() => setLoading(false));
161
+ }, []);
162
+
72
163
  return (
73
164
  <div>
74
165
  <h1>SEO Management</h1>
75
- <SEORecordList />
76
- <SEORecordForm />
77
- <ValidationDashboard />
166
+ <nav>
167
+ <a href="/admin/seo">Dashboard</a>
168
+ <a href="/admin/seo/editor">Editor</a>
169
+ <a href="/admin/seo/reports">Reports</a>
170
+ <a href="/admin/seo/search">Search</a>
171
+ <a href="/admin/seo/settings">Settings</a>
172
+ </nav>
173
+ {/* Your SEO dashboard content */}
174
+ </div>
175
+ );
176
+ }
177
+ ```
178
+
179
+ **`app/admin/seo/editor/page.tsx` (Editor):**
180
+
181
+ ```typescript
182
+ "use client";
183
+
184
+ import { useState, useEffect } from "react";
185
+ import { useSearchParams } from "next/navigation";
186
+ import type { SEORecord } from "@seo-console/package";
187
+
188
+ export default function EditorPage() {
189
+ const searchParams = useSearchParams();
190
+ const route = searchParams.get("route");
191
+ const [record, setRecord] = useState<SEORecord | null>(null);
192
+ const [formData, setFormData] = useState({
193
+ title: "",
194
+ description: "",
195
+ canonicalUrl: "",
196
+ });
197
+
198
+ // Load and save logic here
199
+ return (
200
+ <div>
201
+ <h1>Edit SEO Record</h1>
202
+ {/* Your editor form */}
78
203
  </div>
79
204
  );
80
205
  }
81
206
  ```
82
207
 
208
+ > **Note:** For complete implementation examples, see the demo app in the repository. The package provides the data layer and utilities; you'll need to build the UI components or copy from the demo.
209
+
210
+ ### Step 4: Add SEO Metadata to Your Pages
211
+
212
+ Use the `useGenerateMetadata` hook to automatically generate metadata from your SEO records:
213
+
214
+ ```typescript
215
+ // app/blog/[slug]/page.tsx
216
+ import { useGenerateMetadata } from "@seo-console/package/hooks";
217
+
218
+ export async function generateMetadata({ params }: { params: { slug: string } }) {
219
+ const metadata = await useGenerateMetadata({
220
+ routePath: `/blog/${params.slug}`,
221
+ fallback: {
222
+ title: "Blog Post",
223
+ description: "Default description"
224
+ }
225
+ });
226
+ return metadata;
227
+ }
228
+ ```
229
+
230
+ ### Step 5: Add to Your Admin Navigation
231
+
232
+ Add a link to the SEO admin section in your main admin navigation:
233
+
234
+ ```typescript
235
+ // app/admin/layout.tsx or your admin navigation component
236
+ <nav>
237
+ <Link href="/admin/dashboard">Dashboard</Link>
238
+ <Link href="/admin/seo">SEO</Link> {/* Add this */}
239
+ <Link href="/admin/users">Users</Link>
240
+ {/* ... other admin links */}
241
+ </nav>
242
+ ```
243
+
244
+ ## Quick Start Summary
245
+
246
+ 1. **Install:** `npm install @seo-console/package`
247
+ 2. **Create API route:** `app/api/seo-records/route.ts` (see Step 2)
248
+ 3. **Create admin pages:** `app/admin/seo/` directory with pages (see Step 3)
249
+ 4. **Add to navigation:** Link to `/admin/seo` in your admin menu
250
+ 5. **Use in pages:** Add `generateMetadata` to your pages (see Step 4)
251
+
252
+ That's it! The SEO admin interface will be accessible at `/admin/seo` as a new tab in your admin area.
253
+
83
254
  ## API Reference
84
255
 
85
256
  ### Hooks
@@ -100,28 +271,8 @@ const metadata = await useGenerateMetadata({
100
271
  });
101
272
  ```
102
273
 
103
- ### Components
104
-
105
- #### `SEORecordList`
106
-
107
- Displays a list of all SEO records with edit/delete functionality.
108
-
109
- #### `SEORecordForm`
110
-
111
- Form for creating and editing SEO records.
112
-
113
- #### `ValidationDashboard`
114
-
115
- Dashboard showing validation results for all SEO records.
116
-
117
- #### `OGImagePreview`
118
-
119
- Preview component showing how OG images appear on social platforms.
120
-
121
274
  ### Server-Side Functions
122
275
 
123
- The package exports server-side functions for API routes and server components:
124
-
125
276
  ```typescript
126
277
  import {
127
278
  getSEORecords,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@seo-console/package",
3
- "version": "1.0.2",
3
+ "version": "1.0.3",
4
4
  "description": "SEO validation and management system for Next.js applications",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",