@vilio/blog-module 0.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/dist/actions/index.cjs +158 -0
- package/dist/actions/index.d.ts +34 -0
- package/dist/actions/index.mjs +121 -0
- package/dist/components/BlogStatsWidget.cjs +45 -0
- package/dist/components/BlogStatsWidget.d.ts +2 -0
- package/dist/components/BlogStatsWidget.mjs +13 -0
- package/dist/components/RecentCommentsWidget.cjs +47 -0
- package/dist/components/RecentCommentsWidget.d.ts +2 -0
- package/dist/components/RecentCommentsWidget.mjs +28 -0
- package/dist/components/RecentPostsWidget.cjs +47 -0
- package/dist/components/RecentPostsWidget.d.ts +2 -0
- package/dist/components/RecentPostsWidget.mjs +28 -0
- package/dist/components/ui/button.cjs +54 -0
- package/dist/components/ui/button.d.ts +11 -0
- package/dist/components/ui/button.mjs +47 -0
- package/dist/components/ui/card.cjs +47 -0
- package/dist/components/ui/card.d.ts +6 -0
- package/dist/components/ui/card.mjs +36 -0
- package/dist/components/ui/input.cjs +24 -0
- package/dist/components/ui/input.d.ts +5 -0
- package/dist/components/ui/input.mjs +17 -0
- package/dist/components/ui/table.cjs +68 -0
- package/dist/components/ui/table.d.ts +8 -0
- package/dist/components/ui/table.mjs +65 -0
- package/dist/components/ui/textarea.cjs +22 -0
- package/dist/components/ui/textarea.d.ts +5 -0
- package/dist/components/ui/textarea.mjs +16 -0
- package/dist/index.cjs +102 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.mjs +97 -0
- package/dist/intl.d.ts +7 -0
- package/dist/lib/utils.cjs +11 -0
- package/dist/lib/utils.d.ts +2 -0
- package/dist/lib/utils.mjs +5 -0
- package/dist/lib/validation.cjs +16 -0
- package/dist/lib/validation.d.ts +24 -0
- package/dist/lib/validation.mjs +10 -0
- package/dist/navigation.cjs +23 -0
- package/dist/navigation.d.ts +2 -0
- package/dist/navigation.mjs +21 -0
- package/dist/routes.cjs +74 -0
- package/dist/routes.d.ts +3 -0
- package/dist/routes.mjs +68 -0
- package/dist/schema.cjs +62 -0
- package/dist/schema.d.ts +736 -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 +16 -0
- package/dist/ui/views.mjs +237 -0
- package/locales/en/global.json +45 -0
- package/locales/pl/global.json +45 -0
- package/manifest.json +11 -0
- package/package.json +59 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { i18n } from "@vilio/intl";
|
|
2
|
+
export const navigation = {
|
|
3
|
+
public: [
|
|
4
|
+
{
|
|
5
|
+
title: i18n("Blog"),
|
|
6
|
+
url: "/blog",
|
|
7
|
+
icon: "solar:pen-2-broken"
|
|
8
|
+
}
|
|
9
|
+
],
|
|
10
|
+
admin: {
|
|
11
|
+
[i18n("CMS")]: [
|
|
12
|
+
{
|
|
13
|
+
title: i18n("Blog Manager"),
|
|
14
|
+
url: "/blog",
|
|
15
|
+
icon: "solar:posts-carousel-vertical-broken",
|
|
16
|
+
roles: ["admin"],
|
|
17
|
+
permissions: ["post:create", "post:update", "post:delete"]
|
|
18
|
+
}
|
|
19
|
+
]
|
|
20
|
+
}
|
|
21
|
+
};
|
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("@vilio/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.d.ts
ADDED
package/dist/routes.mjs
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { getCurrentSession } from "@vilio/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("@vilio/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
|
+
}));
|