@arch-cadre/blog-module 1.0.13 → 1.0.15
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/dist/actions/index.cjs +158 -0
- package/dist/actions/index.d.ts +4 -37
- package/dist/actions/index.mjs +121 -0
- package/dist/components/BlogStatsWidget.cjs +45 -0
- package/dist/components/BlogStatsWidget.d.ts +2 -1
- package/dist/components/BlogStatsWidget.mjs +13 -0
- package/dist/components/RecentCommentsWidget.cjs +47 -0
- package/dist/components/RecentCommentsWidget.d.ts +2 -1
- package/dist/components/RecentCommentsWidget.mjs +28 -0
- package/dist/components/RecentPostsWidget.cjs +47 -0
- package/dist/components/RecentPostsWidget.d.ts +2 -1
- package/dist/components/RecentPostsWidget.mjs +28 -0
- package/dist/components/ui/button.cjs +54 -0
- package/dist/components/ui/button.mjs +47 -0
- package/dist/components/ui/card.cjs +47 -0
- package/dist/components/ui/card.mjs +36 -0
- package/dist/components/ui/input.cjs +24 -0
- package/dist/components/ui/input.mjs +17 -0
- package/dist/components/ui/table.cjs +68 -0
- package/dist/components/ui/table.mjs +65 -0
- package/dist/components/ui/textarea.cjs +22 -0
- package/dist/components/ui/textarea.mjs +16 -0
- package/dist/index.cjs +100 -0
- package/dist/index.mjs +95 -0
- package/dist/intl.d.ts +7 -0
- package/dist/lib/utils.cjs +11 -0
- package/dist/lib/{utils.js → utils.mjs} +1 -1
- package/dist/lib/validation.cjs +16 -0
- package/dist/lib/validation.d.ts +2 -2
- package/dist/lib/validation.mjs +10 -0
- package/dist/navigation.cjs +23 -0
- package/dist/navigation.mjs +21 -0
- package/dist/routes.cjs +74 -0
- package/dist/routes.mjs +68 -0
- package/dist/schema.cjs +62 -0
- package/dist/schema.mjs +53 -0
- package/dist/styles/globals.css +1 -0
- package/dist/ui/views.cjs +448 -0
- package/dist/ui/views.d.ts +6 -5
- package/dist/ui/views.mjs +232 -0
- package/package.json +14 -10
- package/dist/actions/index.js +0 -149
- package/dist/components/BlogStatsWidget.js +0 -17
- package/dist/components/RecentCommentsWidget.js +0 -24
- package/dist/components/RecentPostsWidget.js +0 -24
- package/dist/components/ui/button.js +0 -33
- package/dist/components/ui/card.js +0 -12
- package/dist/components/ui/input.js +0 -8
- package/dist/components/ui/table.js +0 -16
- package/dist/components/ui/textarea.js +0 -8
- package/dist/index.js +0 -98
- package/dist/lib/validation.js +0 -11
- package/dist/navigation.js +0 -21
- package/dist/routes.js +0 -55
- package/dist/schema.js +0 -60
- package/dist/ui/views.js +0 -119
package/dist/routes.cjs
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.publicRoutes = exports.privateRoutes = void 0;
|
|
7
|
+
var _server = require("@arch-cadre/core/server");
|
|
8
|
+
var React = _interopRequireWildcard(require("react"));
|
|
9
|
+
var _index = require("./actions/index.cjs");
|
|
10
|
+
var _views = require("./ui/views.cjs");
|
|
11
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
12
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
13
|
+
const publicRoutes = exports.publicRoutes = [{
|
|
14
|
+
path: "/blog",
|
|
15
|
+
component: async () => {
|
|
16
|
+
const posts = await (0, _index.getPosts)();
|
|
17
|
+
return /* @__PURE__ */React.createElement(_views.BlogListPage, {
|
|
18
|
+
posts
|
|
19
|
+
});
|
|
20
|
+
},
|
|
21
|
+
auth: false
|
|
22
|
+
}, {
|
|
23
|
+
path: "/blog/:slug",
|
|
24
|
+
component: async ({
|
|
25
|
+
params
|
|
26
|
+
}) => {
|
|
27
|
+
const {
|
|
28
|
+
slug
|
|
29
|
+
} = await params;
|
|
30
|
+
const post = await (0, _index.getPostBySlug)(slug);
|
|
31
|
+
const comments = post ? await (0, _index.getComments)(post.id) : [];
|
|
32
|
+
const session = await (0, _server.getCurrentSession)();
|
|
33
|
+
return /* @__PURE__ */React.createElement(_views.PostDetailPage, {
|
|
34
|
+
post,
|
|
35
|
+
comments,
|
|
36
|
+
currentUser: session?.user
|
|
37
|
+
});
|
|
38
|
+
},
|
|
39
|
+
auth: false
|
|
40
|
+
}];
|
|
41
|
+
const privateRoutes = exports.privateRoutes = [{
|
|
42
|
+
path: "/blog",
|
|
43
|
+
component: async () => {
|
|
44
|
+
const posts = await (0, _index.getPosts)();
|
|
45
|
+
return /* @__PURE__ */React.createElement(_views.BlogAdminPage, {
|
|
46
|
+
posts
|
|
47
|
+
});
|
|
48
|
+
},
|
|
49
|
+
auth: true,
|
|
50
|
+
roles: ["admin"],
|
|
51
|
+
permissions: ["post:create", "post:update", "post:delete"]
|
|
52
|
+
}, {
|
|
53
|
+
path: "/blog/new",
|
|
54
|
+
component: _views.CreatePostForm,
|
|
55
|
+
auth: true,
|
|
56
|
+
roles: ["admin"],
|
|
57
|
+
permissions: ["post:create"]
|
|
58
|
+
}, {
|
|
59
|
+
path: "/blog/edit/:id",
|
|
60
|
+
component: async ({
|
|
61
|
+
params
|
|
62
|
+
}) => {
|
|
63
|
+
const {
|
|
64
|
+
id
|
|
65
|
+
} = await params;
|
|
66
|
+
const post = await (0, _index.getPostById)(id);
|
|
67
|
+
return /* @__PURE__ */React.createElement(_views.EditPostForm, {
|
|
68
|
+
post
|
|
69
|
+
});
|
|
70
|
+
},
|
|
71
|
+
auth: true,
|
|
72
|
+
roles: ["admin"],
|
|
73
|
+
permissions: ["post:update"]
|
|
74
|
+
}];
|
package/dist/routes.mjs
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { getCurrentSession } from "@arch-cadre/core/server";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
import { getComments, getPostById, getPostBySlug, getPosts } from "./actions/index.mjs";
|
|
4
|
+
import {
|
|
5
|
+
BlogAdminPage,
|
|
6
|
+
BlogListPage,
|
|
7
|
+
CreatePostForm,
|
|
8
|
+
EditPostForm,
|
|
9
|
+
PostDetailPage
|
|
10
|
+
} from "./ui/views.mjs";
|
|
11
|
+
export const publicRoutes = [
|
|
12
|
+
{
|
|
13
|
+
path: "/blog",
|
|
14
|
+
component: async () => {
|
|
15
|
+
const posts = await getPosts();
|
|
16
|
+
return /* @__PURE__ */ React.createElement(BlogListPage, { posts });
|
|
17
|
+
},
|
|
18
|
+
auth: false
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
path: "/blog/:slug",
|
|
22
|
+
component: async ({ params }) => {
|
|
23
|
+
const { slug } = await params;
|
|
24
|
+
const post = await getPostBySlug(slug);
|
|
25
|
+
const comments = post ? await getComments(post.id) : [];
|
|
26
|
+
const session = await getCurrentSession();
|
|
27
|
+
return /* @__PURE__ */ React.createElement(
|
|
28
|
+
PostDetailPage,
|
|
29
|
+
{
|
|
30
|
+
post,
|
|
31
|
+
comments,
|
|
32
|
+
currentUser: session?.user
|
|
33
|
+
}
|
|
34
|
+
);
|
|
35
|
+
},
|
|
36
|
+
auth: false
|
|
37
|
+
}
|
|
38
|
+
];
|
|
39
|
+
export const privateRoutes = [
|
|
40
|
+
{
|
|
41
|
+
path: "/blog",
|
|
42
|
+
component: async () => {
|
|
43
|
+
const posts = await getPosts();
|
|
44
|
+
return /* @__PURE__ */ React.createElement(BlogAdminPage, { posts });
|
|
45
|
+
},
|
|
46
|
+
auth: true,
|
|
47
|
+
roles: ["admin"],
|
|
48
|
+
permissions: ["post:create", "post:update", "post:delete"]
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
path: "/blog/new",
|
|
52
|
+
component: CreatePostForm,
|
|
53
|
+
auth: true,
|
|
54
|
+
roles: ["admin"],
|
|
55
|
+
permissions: ["post:create"]
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
path: "/blog/edit/:id",
|
|
59
|
+
component: async ({ params }) => {
|
|
60
|
+
const { id } = await params;
|
|
61
|
+
const post = await getPostById(id);
|
|
62
|
+
return /* @__PURE__ */ React.createElement(EditPostForm, { post });
|
|
63
|
+
},
|
|
64
|
+
auth: true,
|
|
65
|
+
roles: ["admin"],
|
|
66
|
+
permissions: ["post:update"]
|
|
67
|
+
}
|
|
68
|
+
];
|
package/dist/schema.cjs
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.relations = exports.postsTable = exports.commentsTable = exports.blogSchema = void 0;
|
|
7
|
+
var _core = require("@arch-cadre/core");
|
|
8
|
+
var _drizzleOrm = require("drizzle-orm");
|
|
9
|
+
var _pgCore = require("drizzle-orm/pg-core");
|
|
10
|
+
const postsTable = exports.postsTable = (0, _pgCore.pgTable)("blog_posts", {
|
|
11
|
+
id: (0, _pgCore.text)("id").primaryKey().$defaultFn(() => crypto.randomUUID()),
|
|
12
|
+
title: (0, _pgCore.text)("title").notNull(),
|
|
13
|
+
slug: (0, _pgCore.text)("slug").unique().notNull(),
|
|
14
|
+
content: (0, _pgCore.text)("content").notNull(),
|
|
15
|
+
authorId: (0, _pgCore.text)("author_id").references(() => _core.userTable.id, {
|
|
16
|
+
onDelete: "cascade"
|
|
17
|
+
}).notNull(),
|
|
18
|
+
createdAt: (0, _pgCore.timestamp)("created_at").defaultNow().notNull()
|
|
19
|
+
});
|
|
20
|
+
const commentsTable = exports.commentsTable = (0, _pgCore.pgTable)("blog_comments", {
|
|
21
|
+
id: (0, _pgCore.text)("id").primaryKey().$defaultFn(() => crypto.randomUUID()),
|
|
22
|
+
postId: (0, _pgCore.text)("post_id").references(() => postsTable.id, {
|
|
23
|
+
onDelete: "cascade"
|
|
24
|
+
}).notNull(),
|
|
25
|
+
authorId: (0, _pgCore.text)("author_id").references(() => _core.userTable.id, {
|
|
26
|
+
onDelete: "cascade"
|
|
27
|
+
}).notNull(),
|
|
28
|
+
content: (0, _pgCore.text)("content").notNull(),
|
|
29
|
+
createdAt: (0, _pgCore.timestamp)("created_at").defaultNow().notNull()
|
|
30
|
+
});
|
|
31
|
+
const blogSchema = exports.blogSchema = {
|
|
32
|
+
postsTable,
|
|
33
|
+
commentsTable
|
|
34
|
+
};
|
|
35
|
+
const relations = exports.relations = (0, _drizzleOrm.defineRelations)({
|
|
36
|
+
user: _core.userTable,
|
|
37
|
+
post: postsTable,
|
|
38
|
+
comment: commentsTable
|
|
39
|
+
}, r => ({
|
|
40
|
+
user: {
|
|
41
|
+
posts: r.many.post({
|
|
42
|
+
from: r.user.id,
|
|
43
|
+
to: r.post.authorId
|
|
44
|
+
}),
|
|
45
|
+
comments: r.many.comment({
|
|
46
|
+
from: r.user.id,
|
|
47
|
+
to: r.comment.authorId
|
|
48
|
+
})
|
|
49
|
+
},
|
|
50
|
+
post: {
|
|
51
|
+
comments: r.many.comment({
|
|
52
|
+
from: r.post.id,
|
|
53
|
+
to: r.comment.postId
|
|
54
|
+
})
|
|
55
|
+
},
|
|
56
|
+
comment: {
|
|
57
|
+
post: r.one.post({
|
|
58
|
+
from: r.comment.postId,
|
|
59
|
+
to: r.post.id
|
|
60
|
+
})
|
|
61
|
+
}
|
|
62
|
+
}));
|
package/dist/schema.mjs
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { userTable } from "@arch-cadre/core";
|
|
2
|
+
import { defineRelations } from "drizzle-orm";
|
|
3
|
+
import { pgTable, text, timestamp } from "drizzle-orm/pg-core";
|
|
4
|
+
export const postsTable = pgTable("blog_posts", {
|
|
5
|
+
id: text("id").primaryKey().$defaultFn(() => crypto.randomUUID()),
|
|
6
|
+
title: text("title").notNull(),
|
|
7
|
+
slug: text("slug").unique().notNull(),
|
|
8
|
+
content: text("content").notNull(),
|
|
9
|
+
authorId: text("author_id").references(() => userTable.id, { onDelete: "cascade" }).notNull(),
|
|
10
|
+
createdAt: timestamp("created_at").defaultNow().notNull()
|
|
11
|
+
});
|
|
12
|
+
export const commentsTable = pgTable("blog_comments", {
|
|
13
|
+
id: text("id").primaryKey().$defaultFn(() => crypto.randomUUID()),
|
|
14
|
+
postId: text("post_id").references(() => postsTable.id, { onDelete: "cascade" }).notNull(),
|
|
15
|
+
authorId: text("author_id").references(() => userTable.id, { onDelete: "cascade" }).notNull(),
|
|
16
|
+
content: text("content").notNull(),
|
|
17
|
+
createdAt: timestamp("created_at").defaultNow().notNull()
|
|
18
|
+
});
|
|
19
|
+
export const blogSchema = {
|
|
20
|
+
postsTable,
|
|
21
|
+
commentsTable
|
|
22
|
+
};
|
|
23
|
+
export const relations = defineRelations(
|
|
24
|
+
{
|
|
25
|
+
user: userTable,
|
|
26
|
+
post: postsTable,
|
|
27
|
+
comment: commentsTable
|
|
28
|
+
},
|
|
29
|
+
(r) => ({
|
|
30
|
+
user: {
|
|
31
|
+
posts: r.many.post({
|
|
32
|
+
from: r.user.id,
|
|
33
|
+
to: r.post.authorId
|
|
34
|
+
}),
|
|
35
|
+
comments: r.many.comment({
|
|
36
|
+
from: r.user.id,
|
|
37
|
+
to: r.comment.authorId
|
|
38
|
+
})
|
|
39
|
+
},
|
|
40
|
+
post: {
|
|
41
|
+
comments: r.many.comment({
|
|
42
|
+
from: r.post.id,
|
|
43
|
+
to: r.comment.postId
|
|
44
|
+
})
|
|
45
|
+
},
|
|
46
|
+
comment: {
|
|
47
|
+
post: r.one.post({
|
|
48
|
+
from: r.comment.postId,
|
|
49
|
+
to: r.post.id
|
|
50
|
+
})
|
|
51
|
+
}
|
|
52
|
+
})
|
|
53
|
+
);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
@import "tailwindcss";@import "tw-animate-css";@custom-variant dark (&:is(.dark *));:root{--background:oklch(1 0 0);--foreground:oklch(0.145 0 0);--card:oklch(1 0 0);--card-foreground:oklch(0.145 0 0);--popover:oklch(1 0 0);--popover-foreground:oklch(0.145 0 0);--primary:oklch(0.205 0 0);--primary-foreground:oklch(0.985 0 0);--secondary:oklch(0.97 0 0);--secondary-foreground:oklch(0.205 0 0);--muted:oklch(0.97 0 0);--muted-foreground:oklch(0.556 0 0);--accent:oklch(0.97 0 0);--accent-foreground:oklch(0.205 0 0);--destructive:oklch(0.577 0.245 27.325);--destructive-foreground:oklch(0.577 0.245 27.325);--border:oklch(0.922 0 0);--input:oklch(0.922 0 0);--ring:oklch(0.708 0 0);--chart-1:oklch(0.646 0.222 41.116);--chart-2:oklch(0.6 0.118 184.704);--chart-3:oklch(0.398 0.07 227.392);--chart-4:oklch(0.828 0.189 84.429);--chart-5:oklch(0.769 0.188 70.08);--radius:0.625rem;--sidebar:oklch(0.985 0 0);--sidebar-foreground:oklch(0.145 0 0);--sidebar-primary:oklch(0.205 0 0);--sidebar-primary-foreground:oklch(0.985 0 0);--sidebar-accent:oklch(0.97 0 0);--sidebar-accent-foreground:oklch(0.205 0 0);--sidebar-border:oklch(0.922 0 0);--sidebar-ring:oklch(0.708 0 0)}.dark{--background:oklch(0.145 0 0);--foreground:oklch(0.985 0 0);--card:oklch(0.145 0 0);--card-foreground:oklch(0.985 0 0);--popover:oklch(0.145 0 0);--popover-foreground:oklch(0.985 0 0);--primary:oklch(0.985 0 0);--primary-foreground:oklch(0.205 0 0);--secondary:oklch(0.269 0 0);--secondary-foreground:oklch(0.985 0 0);--muted:oklch(0.269 0 0);--muted-foreground:oklch(0.708 0 0);--accent:oklch(0.269 0 0);--accent-foreground:oklch(0.985 0 0);--destructive:oklch(0.396 0.141 25.723);--destructive-foreground:oklch(0.637 0.237 25.331);--border:oklch(0.269 0 0);--input:oklch(0.269 0 0);--ring:oklch(0.439 0 0);--chart-1:oklch(0.488 0.243 264.376);--chart-2:oklch(0.696 0.17 162.48);--chart-3:oklch(0.769 0.188 70.08);--chart-4:oklch(0.627 0.265 303.9);--chart-5:oklch(0.645 0.246 16.439);--sidebar:oklch(0.205 0 0);--sidebar-foreground:oklch(0.985 0 0);--sidebar-primary:oklch(0.488 0.243 264.376);--sidebar-primary-foreground:oklch(0.985 0 0);--sidebar-accent:oklch(0.269 0 0);--sidebar-accent-foreground:oklch(0.985 0 0);--sidebar-border:oklch(0.269 0 0);--sidebar-ring:oklch(0.439 0 0)}@theme inline{--color-background:var(--background);--color-foreground:var(--foreground);--color-card:var(--card);--color-card-foreground:var(--card-foreground);--color-popover:var(--popover);--color-popover-foreground:var(--popover-foreground);--color-primary:var(--primary);--color-primary-foreground:var(--primary-foreground);--color-secondary:var(--secondary);--color-secondary-foreground:var(--secondary-foreground);--color-muted:var(--muted);--color-muted-foreground:var(--muted-foreground);--color-accent:var(--accent);--color-accent-foreground:var(--accent-foreground);--color-destructive:var(--destructive);--color-destructive-foreground:var(--destructive-foreground);--color-border:var(--border);--color-input:var(--input);--color-ring:var(--ring);--color-chart-1:var(--chart-1);--color-chart-2:var(--chart-2);--color-chart-3:var(--chart-3);--color-chart-4:var(--chart-4);--color-chart-5:var(--chart-5);--radius-sm:calc(var(--radius) - 4px);--radius-md:calc(var(--radius) - 2px);--radius-lg:var(--radius);--radius-xl:calc(var(--radius) + 4px);--color-sidebar:var(--sidebar);--color-sidebar-foreground:var(--sidebar-foreground);--color-sidebar-primary:var(--sidebar-primary);--color-sidebar-primary-foreground:var(--sidebar-primary-foreground);--color-sidebar-accent:var(--sidebar-accent);--color-sidebar-accent-foreground:var(--sidebar-accent-foreground);--color-sidebar-border:var(--sidebar-border);--color-sidebar-ring:var(--sidebar-ring)}@layer base{*{@apply border-border outline-ring/50}body{@apply bg-background text-foreground}}
|