@vilio/blog-module 0.0.3 → 0.0.5

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 (83) hide show
  1. package/dist/actions/index.d.ts +177 -7
  2. package/dist/actions/index.d.ts.map +1 -0
  3. package/dist/actions/index.js +341 -0
  4. package/dist/actions/index.js.map +1 -0
  5. package/dist/components/BlogStatsWidget.d.ts +2 -2
  6. package/dist/components/BlogStatsWidget.d.ts.map +1 -0
  7. package/dist/components/BlogStatsWidget.js +18 -0
  8. package/dist/components/BlogStatsWidget.js.map +1 -0
  9. package/dist/components/RecentCommentsWidget.d.ts +2 -2
  10. package/dist/components/RecentCommentsWidget.d.ts.map +1 -0
  11. package/dist/components/RecentCommentsWidget.js +25 -0
  12. package/dist/components/RecentCommentsWidget.js.map +1 -0
  13. package/dist/components/RecentPostsWidget.d.ts +2 -2
  14. package/dist/components/RecentPostsWidget.d.ts.map +1 -0
  15. package/dist/components/RecentPostsWidget.js +25 -0
  16. package/dist/components/RecentPostsWidget.js.map +1 -0
  17. package/dist/index.d.ts +2 -0
  18. package/dist/index.d.ts.map +1 -0
  19. package/dist/index.js +108 -0
  20. package/dist/index.js.map +1 -0
  21. package/dist/lib/validation.d.ts +51 -4
  22. package/dist/lib/validation.d.ts.map +1 -0
  23. package/dist/lib/validation.js +57 -0
  24. package/dist/lib/validation.js.map +1 -0
  25. package/dist/navigation.d.ts +1 -0
  26. package/dist/navigation.d.ts.map +1 -0
  27. package/dist/navigation.js +43 -0
  28. package/dist/navigation.js.map +1 -0
  29. package/dist/routes.d.ts +1 -0
  30. package/dist/routes.d.ts.map +1 -0
  31. package/dist/routes.js +121 -0
  32. package/dist/routes.js.map +1 -0
  33. package/dist/schema.d.ts +491 -128
  34. package/dist/schema.d.ts.map +1 -0
  35. package/dist/schema.js +168 -0
  36. package/dist/schema.js.map +1 -0
  37. package/dist/ui/views.d.ts +15 -6
  38. package/dist/ui/views.d.ts.map +1 -0
  39. package/dist/ui/views.js +204 -0
  40. package/dist/ui/views.js.map +1 -0
  41. package/locales/en/global.json +28 -1
  42. package/locales/pl/global.json +36 -9
  43. package/package.json +16 -26
  44. package/dist/actions/index.cjs +0 -158
  45. package/dist/actions/index.mjs +0 -121
  46. package/dist/components/BlogStatsWidget.cjs +0 -45
  47. package/dist/components/BlogStatsWidget.mjs +0 -13
  48. package/dist/components/RecentCommentsWidget.cjs +0 -47
  49. package/dist/components/RecentCommentsWidget.mjs +0 -28
  50. package/dist/components/RecentPostsWidget.cjs +0 -47
  51. package/dist/components/RecentPostsWidget.mjs +0 -28
  52. package/dist/components/ui/button.cjs +0 -54
  53. package/dist/components/ui/button.d.ts +0 -11
  54. package/dist/components/ui/button.mjs +0 -47
  55. package/dist/components/ui/card.cjs +0 -47
  56. package/dist/components/ui/card.d.ts +0 -6
  57. package/dist/components/ui/card.mjs +0 -36
  58. package/dist/components/ui/input.cjs +0 -24
  59. package/dist/components/ui/input.d.ts +0 -5
  60. package/dist/components/ui/input.mjs +0 -17
  61. package/dist/components/ui/table.cjs +0 -68
  62. package/dist/components/ui/table.d.ts +0 -8
  63. package/dist/components/ui/table.mjs +0 -65
  64. package/dist/components/ui/textarea.cjs +0 -22
  65. package/dist/components/ui/textarea.d.ts +0 -5
  66. package/dist/components/ui/textarea.mjs +0 -16
  67. package/dist/index.cjs +0 -102
  68. package/dist/index.mjs +0 -97
  69. package/dist/intl.d.ts +0 -7
  70. package/dist/lib/utils.cjs +0 -11
  71. package/dist/lib/utils.d.ts +0 -2
  72. package/dist/lib/utils.mjs +0 -5
  73. package/dist/lib/validation.cjs +0 -16
  74. package/dist/lib/validation.mjs +0 -10
  75. package/dist/navigation.cjs +0 -23
  76. package/dist/navigation.mjs +0 -21
  77. package/dist/routes.cjs +0 -74
  78. package/dist/routes.mjs +0 -68
  79. package/dist/schema.cjs +0 -62
  80. package/dist/schema.mjs +0 -53
  81. package/dist/styles/globals.css +0 -1
  82. package/dist/ui/views.cjs +0 -448
  83. package/dist/ui/views.mjs +0 -237
@@ -1,23 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.navigation = void 0;
7
- var _intl = require("@vilio/intl");
8
- const navigation = exports.navigation = {
9
- public: [{
10
- title: (0, _intl.i18n)("Blog"),
11
- url: "/blog",
12
- icon: "solar:pen-2-broken"
13
- }],
14
- admin: {
15
- [(0, _intl.i18n)("CMS")]: [{
16
- title: (0, _intl.i18n)("Blog Manager"),
17
- url: "/blog",
18
- icon: "solar:posts-carousel-vertical-broken",
19
- roles: ["admin"],
20
- permissions: ["post:create", "post:update", "post:delete"]
21
- }]
22
- }
23
- };
@@ -1,21 +0,0 @@
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 DELETED
@@ -1,74 +0,0 @@
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.mjs DELETED
@@ -1,68 +0,0 @@
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 DELETED
@@ -1,62 +0,0 @@
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
- }));
package/dist/schema.mjs DELETED
@@ -1,53 +0,0 @@
1
- import { userTable } from "@vilio/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
- );
@@ -1 +0,0 @@
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}}