@tansy/blog 0.0.0-stage → 0.1.0

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/messages.d.ts ADDED
@@ -0,0 +1,160 @@
1
+ import type { FieldLabels } from "tansy/plugin";
2
+ /** The blog's dashboard words, read as `t("ext.blog.<key>")`, and its collections' names. */
3
+ export declare const messages: {
4
+ en: {
5
+ section: string;
6
+ pages: {
7
+ "blog/comments": string;
8
+ };
9
+ collections: {
10
+ "blog-comments": string;
11
+ "blog-home": string;
12
+ };
13
+ widgets: {
14
+ "blog-overview": string;
15
+ };
16
+ actions: {
17
+ "blog-approve": string;
18
+ "blog-spam": string;
19
+ };
20
+ categories: {
21
+ Text: string;
22
+ Media: string;
23
+ };
24
+ settings: {
25
+ comments: {
26
+ label: string;
27
+ options: {
28
+ moderated: string;
29
+ open: string;
30
+ off: string;
31
+ };
32
+ };
33
+ notify: {
34
+ label: string;
35
+ description: string;
36
+ };
37
+ feedItems: {
38
+ label: string;
39
+ description: string;
40
+ };
41
+ };
42
+ queue: {
43
+ intro: string;
44
+ cantRead: string;
45
+ empty: string;
46
+ on: string;
47
+ aPost: string;
48
+ showing: string;
49
+ };
50
+ overview: {
51
+ pending: string;
52
+ drafts: string;
53
+ published: string;
54
+ unknown: string;
55
+ pendingLabel: string;
56
+ draftsLabel: string;
57
+ publishedLabel: string;
58
+ };
59
+ moderate: {
60
+ approve: string;
61
+ spam: string;
62
+ approved: string;
63
+ markedSpam: string;
64
+ failed: string;
65
+ };
66
+ editors: {
67
+ startWriting: string;
68
+ quote: string;
69
+ source: string;
70
+ note: string;
71
+ image: string;
72
+ caption: string;
73
+ alt: string;
74
+ video: string;
75
+ pasteVideo: string;
76
+ code: string;
77
+ language: string;
78
+ };
79
+ };
80
+ ar: {
81
+ section: string;
82
+ pages: {
83
+ "blog/comments": string;
84
+ };
85
+ collections: {
86
+ "blog-comments": string;
87
+ "blog-home": string;
88
+ };
89
+ widgets: {
90
+ "blog-overview": string;
91
+ };
92
+ actions: {
93
+ "blog-approve": string;
94
+ "blog-spam": string;
95
+ };
96
+ categories: {
97
+ Text: string;
98
+ Media: string;
99
+ };
100
+ settings: {
101
+ comments: {
102
+ label: string;
103
+ options: {
104
+ moderated: string;
105
+ open: string;
106
+ off: string;
107
+ };
108
+ };
109
+ notify: {
110
+ label: string;
111
+ description: string;
112
+ };
113
+ feedItems: {
114
+ label: string;
115
+ description: string;
116
+ };
117
+ };
118
+ queue: {
119
+ intro: string;
120
+ cantRead: string;
121
+ empty: string;
122
+ on: string;
123
+ aPost: string;
124
+ showing: string;
125
+ };
126
+ overview: {
127
+ pending: string;
128
+ drafts: string;
129
+ published: string;
130
+ unknown: string;
131
+ pendingLabel: string;
132
+ draftsLabel: string;
133
+ publishedLabel: string;
134
+ };
135
+ moderate: {
136
+ approve: string;
137
+ spam: string;
138
+ approved: string;
139
+ markedSpam: string;
140
+ failed: string;
141
+ };
142
+ editors: {
143
+ startWriting: string;
144
+ quote: string;
145
+ source: string;
146
+ note: string;
147
+ image: string;
148
+ caption: string;
149
+ alt: string;
150
+ video: string;
151
+ pasteVideo: string;
152
+ code: string;
153
+ language: string;
154
+ };
155
+ };
156
+ };
157
+ /** The collections' names in other interface languages. Added by a migration, so names an owner set stay. */
158
+ export declare const COLLECTION_LABELS: Record<string, Record<string, string>>;
159
+ /** Fields' words in other interface languages, by collection. Added by a migration, so words an owner set stay. */
160
+ export declare const FIELD_LABELS: Record<string, Record<string, FieldLabels>>;
package/messages.js ADDED
@@ -0,0 +1,264 @@
1
+ /** The blog's dashboard words, read as `t("ext.blog.<key>")`, and its collections' names. */
2
+ export const messages = {
3
+ en: {
4
+ section: "Blog",
5
+ pages: { "blog/comments": "Comments to review" },
6
+ collections: { "blog-comments": "All comments", "blog-home": "Blog home page" },
7
+ widgets: { "blog-overview": "Blog" },
8
+ actions: { "blog-approve": "Approve", "blog-spam": "Mark as spam" },
9
+ categories: { Text: "Text", Media: "Media" },
10
+ settings: {
11
+ comments: { label: "Comments", options: { moderated: "Held for review", open: "Shown straight away", off: "Off" } },
12
+ notify: { label: "Email for comments to review", description: "Who to tell when a comment is waiting. Leave empty for nobody." },
13
+ feedItems: { label: "Posts in feeds", description: "How many of the latest posts the RSS and Atom feeds list." },
14
+ },
15
+ queue: {
16
+ intro: "Comments waiting for review, oldest first. Approving or marking as spam needs permission to update records in Comments.",
17
+ cantRead: "You can't read Comments. Ask an administrator for permission to list them.",
18
+ empty: "Nothing is waiting for review.",
19
+ on: "{name} on {post}",
20
+ aPost: "a post",
21
+ showing: "Showing the oldest {shown} of {total}.",
22
+ },
23
+ overview: {
24
+ pending: "{count, plural, one {# comment waiting for review} other {# comments waiting for review}}",
25
+ drafts: "{count, plural, one {# draft post} other {# draft posts}}",
26
+ published: "{count, plural, one {# published post} other {# published posts}}",
27
+ unknown: "— {label}",
28
+ pendingLabel: "comments waiting for review",
29
+ draftsLabel: "draft posts",
30
+ publishedLabel: "published posts",
31
+ },
32
+ moderate: {
33
+ approve: "Approve",
34
+ spam: "Spam",
35
+ approved: "Approved",
36
+ markedSpam: "Marked as spam",
37
+ failed: "{count, plural, one {One comment couldn't be changed.} other {# comments couldn't be changed.}} Changing comments needs permission to update records in Comments.",
38
+ },
39
+ editors: {
40
+ startWriting: "Start writing…",
41
+ quote: "Write a quote…",
42
+ source: "Who said it",
43
+ note: "Write a note…",
44
+ image: "Image",
45
+ caption: "Add a caption",
46
+ alt: "Alt text: what the image shows, for people who can't see it",
47
+ video: "Video",
48
+ pasteVideo: "Paste a YouTube or Vimeo link.",
49
+ code: "Paste or write code",
50
+ language: "Language, such as ts",
51
+ },
52
+ },
53
+ ar: {
54
+ section: "المدونة",
55
+ pages: { "blog/comments": "تعليقات بانتظار المراجعة" },
56
+ collections: { "blog-comments": "كل التعليقات", "blog-home": "الصفحة الرئيسية للمدونة" },
57
+ widgets: { "blog-overview": "المدونة" },
58
+ actions: { "blog-approve": "موافقة", "blog-spam": "وسم كرسالة مزعجة" },
59
+ categories: { Text: "نص", Media: "وسائط" },
60
+ settings: {
61
+ comments: { label: "التعليقات", options: { moderated: "تُحجز للمراجعة", open: "تظهر فورًا", off: "معطّلة" } },
62
+ notify: { label: "بريد التعليقات التي تنتظر المراجعة", description: "من يُبلَّغ حين ينتظر تعليق المراجعة. اتركه فارغًا لعدم إبلاغ أحد." },
63
+ feedItems: { label: "عدد المقالات في الخلاصات", description: "كم مقالًا من الأحدث تعرضه خلاصتا RSS وAtom." },
64
+ },
65
+ queue: {
66
+ intro: "تعليقات تنتظر المراجعة، الأقدم أولًا. تتطلب الموافقة أو الوسم كرسالة مزعجة صلاحية تحديث السجلات في التعليقات.",
67
+ cantRead: "لا يمكنك قراءة التعليقات. اطلب من المسؤول صلاحية عرضها.",
68
+ empty: "لا شيء ينتظر المراجعة.",
69
+ on: "{name} على {post}",
70
+ aPost: "مقال",
71
+ showing: "يُعرض أقدم {shown} من {total}.",
72
+ },
73
+ overview: {
74
+ pending: "{count, plural, zero {لا تعليقات تنتظر المراجعة} one {تعليق واحد ينتظر المراجعة} two {تعليقان ينتظران المراجعة} few {# تعليقات تنتظر المراجعة} many {# تعليقًا ينتظر المراجعة} other {# تعليق ينتظر المراجعة}}",
75
+ drafts: "{count, plural, zero {لا مسودات} one {مسودة واحدة} two {مسودتان} few {# مسودات} many {# مسودة} other {# مسودة}}",
76
+ published: "{count, plural, zero {لا مقالات منشورة} one {مقال منشور واحد} two {مقالان منشوران} few {# مقالات منشورة} many {# مقالًا منشورًا} other {# مقال منشور}}",
77
+ unknown: "— {label}",
78
+ pendingLabel: "تعليقات تنتظر المراجعة",
79
+ draftsLabel: "مسودات",
80
+ publishedLabel: "مقالات منشورة",
81
+ },
82
+ moderate: {
83
+ approve: "موافقة",
84
+ spam: "مزعج",
85
+ approved: "تمت الموافقة",
86
+ markedSpam: "وُسم كرسالة مزعجة",
87
+ failed: "{count, plural, one {تعذّر تغيير تعليق واحد.} two {تعذّر تغيير تعليقين.} few {تعذّر تغيير # تعليقات.} many {تعذّر تغيير # تعليقًا.} other {تعذّر تغيير # تعليق.}} يتطلب تغيير التعليقات صلاحية تحديث السجلات في التعليقات.",
88
+ },
89
+ editors: {
90
+ startWriting: "ابدأ الكتابة…",
91
+ quote: "اكتب اقتباسًا…",
92
+ source: "قائله",
93
+ note: "اكتب ملاحظة…",
94
+ image: "صورة",
95
+ caption: "أضف تعليقًا توضيحيًا",
96
+ alt: "النص البديل: ما تُظهره الصورة، لمن لا يستطيع رؤيتها",
97
+ video: "فيديو",
98
+ pasteVideo: "الصق رابطًا من YouTube أو Vimeo.",
99
+ code: "الصق رمزًا برمجيًا أو اكتبه",
100
+ language: "اللغة، مثل ts",
101
+ },
102
+ },
103
+ };
104
+ /** The collections' names in other interface languages. Added by a migration, so names an owner set stay. */
105
+ export const COLLECTION_LABELS = {
106
+ "blog-categories": { ar: "التصنيفات" },
107
+ "blog-tags": { ar: "الوسوم" },
108
+ "blog-posts": { ar: "المقالات" },
109
+ "blog-comments": { ar: "التعليقات" },
110
+ "blog-home": { ar: "رئيسية المدونة" },
111
+ };
112
+ /** Fields' words in other interface languages, by collection. Added by a migration, so words an owner set stay. */
113
+ export const FIELD_LABELS = {
114
+ "blog-categories": {
115
+ slug: {
116
+ labels: {
117
+ ar: "الاسم اللطيف"
118
+ },
119
+ descriptions: {
120
+ ar: "يظهر في العنوان. أحرف لاتينية صغيرة وأرقام وشرطات. يُملأ من العنوان إن تُرك فارغًا."
121
+ }
122
+ },
123
+ name: {
124
+ labels: {
125
+ ar: "الاسم"
126
+ }
127
+ },
128
+ description: {
129
+ labels: {
130
+ ar: "الوصف"
131
+ }
132
+ },
133
+ parent: {
134
+ labels: {
135
+ ar: "التصنيف الأب"
136
+ }
137
+ }
138
+ },
139
+ "blog-tags": {
140
+ slug: {
141
+ labels: {
142
+ ar: "الاسم اللطيف"
143
+ },
144
+ descriptions: {
145
+ ar: "يظهر في العنوان. أحرف لاتينية صغيرة وأرقام وشرطات. يُملأ من العنوان إن تُرك فارغًا."
146
+ }
147
+ },
148
+ name: {
149
+ labels: {
150
+ ar: "الاسم"
151
+ }
152
+ }
153
+ },
154
+ "blog-posts": {
155
+ title: {
156
+ labels: {
157
+ ar: "العنوان"
158
+ }
159
+ },
160
+ slug: {
161
+ labels: {
162
+ ar: "الاسم اللطيف"
163
+ },
164
+ descriptions: {
165
+ ar: "يظهر في العنوان. أحرف لاتينية صغيرة وأرقام وشرطات. يُملأ من العنوان إن تُرك فارغًا."
166
+ }
167
+ },
168
+ excerpt: {
169
+ labels: {
170
+ ar: "المقتطف"
171
+ }
172
+ },
173
+ cover: {
174
+ labels: {
175
+ ar: "صورة الغلاف"
176
+ }
177
+ },
178
+ body: {
179
+ labels: {
180
+ ar: "المحتوى"
181
+ }
182
+ },
183
+ byline: {
184
+ labels: {
185
+ ar: "الكاتب"
186
+ }
187
+ },
188
+ categories: {
189
+ labels: {
190
+ ar: "التصنيفات"
191
+ }
192
+ },
193
+ tags: {
194
+ labels: {
195
+ ar: "الوسوم"
196
+ }
197
+ },
198
+ featured: {
199
+ labels: {
200
+ ar: "مميّزة"
201
+ }
202
+ },
203
+ allowComments: {
204
+ labels: {
205
+ ar: "السماح بالتعليقات"
206
+ }
207
+ },
208
+ readingMinutes: {
209
+ labels: {
210
+ ar: "مدة القراءة (دقائق)"
211
+ }
212
+ }
213
+ },
214
+ "blog-comments": {
215
+ post: {
216
+ labels: {
217
+ ar: "المقالة"
218
+ }
219
+ },
220
+ parent: {
221
+ labels: {
222
+ ar: "ردًا على"
223
+ }
224
+ },
225
+ name: {
226
+ labels: {
227
+ ar: "الاسم"
228
+ }
229
+ },
230
+ body: {
231
+ labels: {
232
+ ar: "التعليق"
233
+ }
234
+ },
235
+ state: {
236
+ labels: {
237
+ ar: "الحالة"
238
+ },
239
+ options: {
240
+ pending: {
241
+ ar: "بانتظار المراجعة"
242
+ },
243
+ approved: {
244
+ ar: "مقبول"
245
+ },
246
+ spam: {
247
+ ar: "مزعج"
248
+ }
249
+ }
250
+ }
251
+ },
252
+ "blog-home": {
253
+ title: {
254
+ labels: {
255
+ ar: "العنوان"
256
+ }
257
+ },
258
+ intro: {
259
+ labels: {
260
+ ar: "المقدمة"
261
+ }
262
+ }
263
+ }
264
+ };
package/moderate.d.ts ADDED
@@ -0,0 +1,8 @@
1
+ type T = (key: string, values?: Record<string, string | number>) => string;
2
+ export type CommentState = "approved" | "spam" | "pending";
3
+ /** Sets each comment's state through the records API, which checks the caller's own permission on Comments. */
4
+ export declare function setCommentState(ids: number[], state: CommentState, t: T): Promise<void>;
5
+ export declare function ModerateButtons({ id }: {
6
+ id: number;
7
+ }): import("react").JSX.Element;
8
+ export {};
package/moderate.js ADDED
@@ -0,0 +1,36 @@
1
+ "use client";
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { useState } from "react";
4
+ import { apiPath, Button, useT } from "tansy/admin";
5
+ /** Sets each comment's state through the records API, which checks the caller's own permission on Comments. */
6
+ export async function setCommentState(ids, state, t) {
7
+ const failed = [];
8
+ for (const id of ids) {
9
+ const response = await fetch(apiPath(`/collections/blog-comments/records/${id}`), {
10
+ method: "PATCH",
11
+ headers: { "content-type": "application/json" },
12
+ body: JSON.stringify({ state }),
13
+ });
14
+ if (!response.ok)
15
+ failed.push(id);
16
+ }
17
+ if (failed.length)
18
+ window.alert(t("ext.blog.moderate.failed", { count: failed.length }));
19
+ }
20
+ export function ModerateButtons({ id }) {
21
+ const { t } = useT();
22
+ const [done, setDone] = useState(null);
23
+ const [busy, setBusy] = useState(false);
24
+ if (done)
25
+ return _jsx("span", { className: "cms-faded", children: done === "approved" ? t("ext.blog.moderate.approved") : t("ext.blog.moderate.markedSpam") });
26
+ const set = async (state) => {
27
+ setBusy(true);
28
+ await setCommentState([id], state, t);
29
+ // Shown as done only if it stuck: the page reloads its list on the next visit either way.
30
+ const check = await fetch(apiPath(`/collections/blog-comments/records/${id}?fields=state`)).then((r) => (r.ok ? r.json() : null)).catch(() => null);
31
+ setBusy(false);
32
+ if (check?.state === state)
33
+ setDone(state);
34
+ };
35
+ return (_jsxs("span", { className: "cms-flex cms-gap-2", children: [_jsx(Button, { variant: "primary", loading: busy, onClick: () => set("approved"), children: t("ext.blog.moderate.approve") }), _jsx(Button, { variant: "secondary", disabled: busy, onClick: () => set("spam"), children: t("ext.blog.moderate.spam") })] }));
36
+ }
package/package.json CHANGED
@@ -1,6 +1,46 @@
1
1
  {
2
2
  "name": "@tansy/blog",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.1.0",
4
+ "description": "Turns tansy into a blog: posts, categories, tags, authors, comments and feeds.",
5
+ "keywords": [
6
+ "tansy",
7
+ "tansy-plugin",
8
+ "cms",
9
+ "nextjs"
10
+ ],
11
+ "license": "MIT",
12
+ "author": "Mohamed Salah <mohamedsalahsebai@gmail.com>",
13
+ "homepage": "https://github.com/mhmdsalahsebai/tansy",
14
+ "repository": {
15
+ "type": "git",
16
+ "url": "git+https://github.com/mhmdsalahsebai/tansy.git",
17
+ "directory": "plugins/blog"
18
+ },
19
+ "bugs": "https://github.com/mhmdsalahsebai/tansy/issues",
20
+ "exports": {
21
+ ".": {
22
+ "types": "./index.d.ts",
23
+ "default": "./index.js"
24
+ },
25
+ "./admin": {
26
+ "types": "./admin.d.ts",
27
+ "default": "./admin.js"
28
+ },
29
+ "./client": {
30
+ "types": "./client.d.ts",
31
+ "default": "./client.js"
32
+ },
33
+ "./render": {
34
+ "types": "./render.d.ts",
35
+ "default": "./render.js"
36
+ }
37
+ },
38
+ "peerDependencies": {
39
+ "next": "^16.4.6",
40
+ "react": "^19.3.0",
41
+ "tansy": "^0.1.0"
42
+ },
43
+ "dependencies": {
44
+ "zod": "^4.6.7"
45
+ }
46
+ }
package/render.d.ts ADDED
@@ -0,0 +1,36 @@
1
+ import { type SiteWords } from "tansy/react";
2
+ import type { SiteRecord, TemplateProps } from "tansy/theme";
3
+ import "./blog.css";
4
+ /**
5
+ * The parts of the blog's pages, for a theme that designs its own. Give them the template's
6
+ * `record`, `data` and `words`: a theme's template for a blog collection gets the same lists as the
7
+ * plugin's own, so each part finds what it needs there.
8
+ *
9
+ * import { PostMeta, MorePosts, PostComments } from "@tansy/blog/render";
10
+ */
11
+ type PartProps = {
12
+ post: SiteRecord;
13
+ data: TemplateProps["data"];
14
+ words?: SiteWords;
15
+ };
16
+ /** Byline, date and reading time. */
17
+ export declare function PostMeta({ post, words }: PartProps): import("react").JSX.Element;
18
+ /** Posts as a list of titles, meta and excerpts, with featured posts marked. */
19
+ export declare function PostList({ posts, data, empty, words }: {
20
+ posts: SiteRecord[];
21
+ data: TemplateProps["data"];
22
+ empty: string;
23
+ words?: SiteWords;
24
+ }): import("react").JSX.Element;
25
+ /** The post's categories, as links. */
26
+ export declare function PostCategories({ post, data, words }: PartProps): import("react").JSX.Element | null;
27
+ /** The post's tags, as links. */
28
+ export declare function PostTags({ post, data, words }: PartProps): import("react").JSX.Element | null;
29
+ /** Up to three posts sharing a tag with this one, or the latest when none do. */
30
+ export declare function MorePosts({ post, data, words, heading }: PartProps & {
31
+ heading?: string;
32
+ }): import("react").JSX.Element | null;
33
+ /** Approved comments and the form, unless the post has comments turned off. Shows replies one level deep. */
34
+ export declare function PostComments({ post, data, words }: PartProps): import("react").JSX.Element | null;
35
+ declare const _default: import("tansy/react").Renderers;
36
+ export default _default;