@fydemy/cms 1.0.1 → 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.
- package/README.md +23 -56
- package/dist/admin.template.tsx +661 -0
- package/dist/bin.d.mts +1 -0
- package/dist/bin.d.ts +1 -0
- package/dist/bin.js +276 -0
- package/dist/bin.js.map +1 -0
- package/dist/bin.mjs +253 -0
- package/dist/bin.mjs.map +1 -0
- package/dist/components/ui/badge.tsx +36 -0
- package/dist/components/ui/button.tsx +56 -0
- package/dist/components/ui/card.tsx +86 -0
- package/dist/components/ui/input.tsx +25 -0
- package/dist/components/ui/label.tsx +24 -0
- package/dist/components/ui/textarea.tsx +24 -0
- package/dist/components.json +16 -0
- package/dist/index.d.mts +6 -1
- package/dist/index.d.ts +6 -1
- package/dist/index.js +1273 -10
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1271 -10
- package/dist/index.mjs.map +1 -1
- package/dist/lib/utils.ts +6 -0
- package/dist/login.template.tsx +126 -0
- package/package.json +9 -1
package/README.md
CHANGED
|
@@ -32,24 +32,29 @@ yarn add @fydemy/cms
|
|
|
32
32
|
|
|
33
33
|
### 1. Initialize the CMS
|
|
34
34
|
|
|
35
|
-
|
|
35
|
+
Run the initialization command in your Next.js App Router project:
|
|
36
36
|
|
|
37
|
-
```
|
|
38
|
-
|
|
39
|
-
import { initCMS } from "@fydemy/cms";
|
|
40
|
-
|
|
41
|
-
initCMS();
|
|
37
|
+
```bash
|
|
38
|
+
npx fydemy-cms init
|
|
42
39
|
```
|
|
43
40
|
|
|
44
|
-
|
|
41
|
+
This command will automatically:
|
|
42
|
+
|
|
43
|
+
- Create the content directory
|
|
44
|
+
- Scaffold Admin UI pages (`/app/admin`)
|
|
45
|
+
- Create API routes (`/app/api/cms`)
|
|
46
|
+
- Create a `.env.local.example` file
|
|
47
|
+
- Provide instructions for updating `middleware.ts`
|
|
48
|
+
|
|
49
|
+
### 2. Configure Environment
|
|
50
|
+
|
|
51
|
+
Copy `.env.local.example` to `.env.local` and set your credentials:
|
|
45
52
|
|
|
46
53
|
```bash
|
|
47
|
-
|
|
54
|
+
cp .env.local.example .env.local
|
|
48
55
|
```
|
|
49
56
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
Create `.env.local`:
|
|
57
|
+
Update variables in `.env.local`:
|
|
53
58
|
|
|
54
59
|
```env
|
|
55
60
|
# Required for authentication
|
|
@@ -65,62 +70,24 @@ GITHUB_BRANCH=main
|
|
|
65
70
|
|
|
66
71
|
> **Security Note**: Use strong passwords and keep `CMS_SESSION_SECRET` at least 32 characters long.
|
|
67
72
|
|
|
68
|
-
### 3.
|
|
69
|
-
|
|
70
|
-
Create the following API routes in your Next.js app:
|
|
71
|
-
|
|
72
|
-
**`app/api/cms/login/route.ts`**
|
|
73
|
-
|
|
74
|
-
```typescript
|
|
75
|
-
import { handleLogin } from "@fydemy/cms";
|
|
76
|
-
export { handleLogin as POST };
|
|
77
|
-
```
|
|
78
|
-
|
|
79
|
-
**`app/api/cms/logout/route.ts`**
|
|
80
|
-
|
|
81
|
-
```typescript
|
|
82
|
-
import { handleLogout } from "@fydemy/cms";
|
|
83
|
-
export { handleLogout as POST };
|
|
84
|
-
```
|
|
85
|
-
|
|
86
|
-
**`app/api/cms/content/[...path]/route.ts`**
|
|
87
|
-
|
|
88
|
-
```typescript
|
|
89
|
-
import { createContentApiHandlers } from "@fydemy/cms";
|
|
90
|
-
|
|
91
|
-
const handlers = createContentApiHandlers();
|
|
92
|
-
export const GET = handlers.GET;
|
|
93
|
-
export const POST = handlers.POST;
|
|
94
|
-
export const DELETE = handlers.DELETE;
|
|
95
|
-
```
|
|
73
|
+
### 3. Update Middleware
|
|
96
74
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
```typescript
|
|
100
|
-
import { createListApiHandlers } from "@fydemy/cms";
|
|
101
|
-
|
|
102
|
-
const handlers = createListApiHandlers();
|
|
103
|
-
export const GET = handlers.GET;
|
|
104
|
-
```
|
|
105
|
-
|
|
106
|
-
### 4. Add Middleware
|
|
107
|
-
|
|
108
|
-
**`middleware.ts`** (root of your project)
|
|
75
|
+
The init command will guide you to update `middleware.ts` to protect admin routes:
|
|
109
76
|
|
|
110
77
|
```typescript
|
|
111
78
|
import { createAuthMiddleware } from "@fydemy/cms";
|
|
79
|
+
import { NextRequest } from "next/server";
|
|
112
80
|
|
|
113
|
-
export
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
});
|
|
81
|
+
export function middleware(request: NextRequest) {
|
|
82
|
+
return createAuthMiddleware()(request);
|
|
83
|
+
}
|
|
117
84
|
|
|
118
85
|
export const config = {
|
|
119
86
|
matcher: ["/admin/:path*"],
|
|
120
87
|
};
|
|
121
88
|
```
|
|
122
89
|
|
|
123
|
-
###
|
|
90
|
+
### 4. Read Content in Your App
|
|
124
91
|
|
|
125
92
|
```typescript
|
|
126
93
|
import { getMarkdownContent } from "@fydemy/cms";
|