@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/render.js ADDED
@@ -0,0 +1,123 @@
1
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { apiPath, defineRenderers, pickWords, Pager, sitePath, RichText, StreamField } from "tansy/react";
3
+ import { Comments } from "./comments";
4
+ import { blogWords, siteMessages } from "./site-messages";
5
+ import { embedUrl } from "./text";
6
+ import "./blog.css";
7
+ const text = (value) => (typeof value === "string" ? value : "");
8
+ const ids = (value) => (Array.isArray(value) ? value.filter((id) => typeof id === "number") : typeof value === "number" ? [value] : []);
9
+ const items = (list) => list?.items ?? [];
10
+ const fileHref = (id, thumb) => apiPath(`/files/${encodeURIComponent(id)}${thumb ? `?thumb=${thumb}` : ""}`);
11
+ /** Records of a lookup list, by id, so links follow each collection's URL pattern. */
12
+ const byId = (list) => new Map(items(list).map((record) => [record.id, record]));
13
+ /** A link to a record in the page's language. */
14
+ function Linked({ record, label, words }) {
15
+ if (!record)
16
+ return null;
17
+ const href = text(record.recordPath) && sitePath(words, text(record.recordPath));
18
+ return href ? _jsx("a", { href: href, children: text(label) }) : _jsx("span", { children: text(label) });
19
+ }
20
+ /** Byline, date and reading time. */
21
+ export function PostMeta({ post, words }) {
22
+ const { t, formatDate } = blogWords(words);
23
+ const date = text(post.publishedAt);
24
+ const minutes = typeof post.readingMinutes === "number" ? post.readingMinutes : null;
25
+ const byline = text(post.byline);
26
+ return (_jsxs("p", { className: "bl-meta", children: [byline && _jsxs(_Fragment, { children: [_jsx("span", { className: "bl-byline", children: byline }), _jsx("span", { "aria-hidden": true, children: " \u00B7 " })] }), date && _jsx("time", { dateTime: date, children: formatDate(date, "long") }), minutes !== null && _jsxs(_Fragment, { children: [_jsx("span", { "aria-hidden": true, children: " \u00B7 " }), t("blog.minutes", { count: minutes })] })] }));
27
+ }
28
+ /** Posts as a list of titles, meta and excerpts, with featured posts marked. */
29
+ export function PostList({ posts, data, empty, words }) {
30
+ if (!posts.length)
31
+ return _jsx("p", { className: "bl-muted", children: empty });
32
+ return (_jsx("ul", { className: "bl-list", children: posts.map((post) => (_jsxs("li", { className: post.featured === true ? "bl-item bl-featured" : "bl-item", children: [_jsx("h2", { className: "bl-item-title", children: _jsx(Linked, { record: post, label: post.title, words: words }) }), _jsx(PostMeta, { post: post, data: data, words: words }), text(post.excerpt) && _jsx("p", { children: text(post.excerpt) })] }, post.id))) }));
33
+ }
34
+ /** The post's categories, as links. */
35
+ export function PostCategories({ post, data, words }) {
36
+ const categories = byId(data.categories);
37
+ if (!ids(post.categories).length)
38
+ return null;
39
+ return _jsx("p", { className: "bl-kicker", children: ids(post.categories).map((id) => _jsx(Linked, { record: categories.get(id), label: categories.get(id)?.name, words: words }, id)) });
40
+ }
41
+ /** The post's tags, as links. */
42
+ export function PostTags({ post, data, words }) {
43
+ const tags = byId(data.tags);
44
+ if (!ids(post.tags).length)
45
+ return null;
46
+ return _jsx("ul", { className: "bl-tags", "aria-label": blogWords(words).t("blog.tags"), children: ids(post.tags).map((id) => _jsx("li", { children: _jsx(Linked, { record: tags.get(id), label: tags.get(id)?.name, words: words }) }, id)) });
47
+ }
48
+ /** Up to three posts sharing a tag with this one, or the latest when none do. */
49
+ export function MorePosts({ post, data, words, heading = blogWords(words).t("blog.morePosts") }) {
50
+ const related = items(data.related);
51
+ const more = (related.length ? related : items(data.recent)).filter((other) => other.id !== post.id).slice(0, 3);
52
+ if (!more.length)
53
+ return null;
54
+ return (_jsxs("section", { className: "bl-more", "aria-labelledby": "bl-more-title", children: [_jsx("h2", { id: "bl-more-title", children: heading }), _jsx(PostList, { posts: more, data: data, empty: "", words: words })] }));
55
+ }
56
+ /** Approved comments and the form, unless the post has comments turned off. Shows replies one level deep. */
57
+ export function PostComments({ post, data, words }) {
58
+ if (post.allowComments === false)
59
+ return null;
60
+ return _jsx(Comments, { postId: post.id, initial: items(data.comments), words: words ? pickWords(words, "blog") : undefined });
61
+ }
62
+ function Home({ record, data, stream, path, words, t }) {
63
+ const posts = items(data.posts);
64
+ // Featured posts go first, keeping the newest-first order within each group.
65
+ const ordered = [...posts.filter((post) => post.featured === true), ...posts.filter((post) => post.featured !== true)];
66
+ return (_jsxs("main", { className: "bl-main", children: [_jsx("h1", { children: text(record?.title) || t("blog.home") }), Array.isArray(record?.intro) && (data.posts?.page ?? 1) === 1 && _jsx("div", { className: "bl-body", children: _jsx(StreamField, { blocks: record.intro, ...stream }) }), _jsx(PostList, { posts: ordered, data: data, empty: t("blog.noPosts"), words: words }), _jsx(Pager, { list: data.posts, path: path, previous: t("blog.newerPosts"), next: t("blog.olderPosts"), className: "bl-pager", words: words })] }));
67
+ }
68
+ function Post({ record, data, stream, fileUrl, fileText, words }) {
69
+ if (!record)
70
+ return null;
71
+ return (_jsxs("main", { className: "bl-main", children: [_jsxs("article", { children: [_jsx(PostCategories, { post: record, data: data, words: words }), _jsx("h1", { children: text(record.title) }), _jsx(PostMeta, { post: record, data: data, words: words }), text(record.cover) && _jsx("img", { className: "bl-cover", src: fileUrl(text(record.cover), "800x0"), alt: fileText(text(record.cover)).alt }), _jsx("div", { className: "bl-body", children: _jsx(StreamField, { blocks: record.body, ...stream }) }), _jsx(PostTags, { post: record, data: data, words: words })] }), _jsx(MorePosts, { post: record, data: data, words: words }), _jsx(PostComments, { post: record, data: data, words: words })] }));
72
+ }
73
+ function Archive({ record, data, path, heading, words, t }) {
74
+ if (!record)
75
+ return null;
76
+ return (_jsxs("main", { className: "bl-main", children: [_jsx("p", { className: "bl-kicker", children: heading }), _jsx("h1", { children: text(record.name) }), text(record.description) && _jsx("p", { children: text(record.description) }), record.bio !== undefined && record.bio !== null && _jsx("div", { className: "bl-body", children: _jsx(RichText, { doc: record.bio }) }), _jsx(PostList, { posts: items(data.posts), data: data, empty: t("blog.noPostsHere"), words: words }), _jsx(Pager, { list: data.posts, path: path, previous: t("blog.newerPosts"), next: t("blog.olderPosts"), className: "bl-pager", words: words })] }));
77
+ }
78
+ const Category = (props) => _jsx(Archive, { ...props, heading: props.t("blog.category") });
79
+ const Tag = (props) => _jsx(Archive, { ...props, heading: props.t("blog.tag") });
80
+ const TextBlock = ({ value }) => _jsx(RichText, { doc: value.body });
81
+ function Quote({ value }) {
82
+ return (_jsxs("blockquote", { className: "bl-quote", children: [_jsx("p", { children: text(value.text) }), text(value.source) && _jsx("cite", { children: text(value.source) })] }));
83
+ }
84
+ function Callout({ value }) {
85
+ const tone = ["info", "tip", "warning"].includes(text(value.tone)) ? text(value.tone) : "info";
86
+ return _jsx("aside", { className: `bl-callout bl-callout-${tone}`, role: "note", children: _jsx(RichText, { doc: value.body }) });
87
+ }
88
+ function Image({ value }) {
89
+ if (!text(value.image))
90
+ return null;
91
+ return (_jsxs("figure", { className: "bl-figure", children: [_jsx("img", { src: fileHref(text(value.image), "800x0"), alt: text(value.alt), loading: "lazy" }), text(value.caption) && _jsx("figcaption", { children: text(value.caption) })] }));
92
+ }
93
+ function Embed({ value, words }) {
94
+ const url = text(value.url);
95
+ const src = embedUrl(url);
96
+ return (_jsxs("figure", { className: "bl-figure", children: [src
97
+ ? _jsx("div", { className: "bl-embed", children: _jsx("iframe", { src: src, title: text(value.caption) || blogWords(words).t("blog.video"), loading: "lazy", allow: "encrypted-media; picture-in-picture; fullscreen", referrerPolicy: "strict-origin-when-cross-origin", sandbox: "allow-scripts allow-same-origin allow-presentation" }) })
98
+ : _jsx("a", { href: url.startsWith("https://") ? url : undefined, rel: "noopener noreferrer", children: url }), text(value.caption) && _jsx("figcaption", { children: text(value.caption) })] }));
99
+ }
100
+ function Code({ value }) {
101
+ const language = text(value.language).replace(/[^a-z0-9+#-]/gi, "");
102
+ return _jsx("pre", { className: "bl-code", children: _jsx("code", { "data-language": language || undefined, children: text(value.code) }) });
103
+ }
104
+ const LOOKUP = { perPage: 200, fields: "id,name", urls: "1" };
105
+ const LISTED = { collection: "blog-posts", sort: "-publishedAt", fields: "id,title,excerpt,publishedAt,readingMinutes,byline,featured", urls: "1" };
106
+ const PAGE = 20;
107
+ export default defineRenderers({
108
+ messages: siteMessages,
109
+ blocks: { blog_text: TextBlock, blog_quote: Quote, blog_callout: Callout, blog_image: Image, blog_embed: Embed, blog_code: Code },
110
+ templates: { "blog-home": Home, "blog-posts": Post, "blog-categories": Category, "blog-tags": Tag },
111
+ queries: {
112
+ "blog-home": { posts: { ...LISTED, perPage: PAGE, paged: true } },
113
+ "blog-posts": {
114
+ related: { ...LISTED, filter: "tags ?= @record.tags && id != @record.id", perPage: 3 },
115
+ recent: { ...LISTED, perPage: 4 },
116
+ categories: { collection: "blog-categories", ...LOOKUP },
117
+ tags: { collection: "blog-tags", ...LOOKUP },
118
+ comments: { collection: "blog-comments", filter: "post = @record.id", sort: "createdAt", perPage: 200, fields: "id,name,body,parent,createdAt" },
119
+ },
120
+ "blog-categories": { posts: { ...LISTED, filter: "categories ?= @record.id", perPage: PAGE, paged: true } },
121
+ "blog-tags": { posts: { ...LISTED, filter: "tags ?= @record.id", perPage: PAGE, paged: true } },
122
+ },
123
+ });
package/schema.d.ts ADDED
@@ -0,0 +1,313 @@
1
+ import type { PluginRole } from "tansy/plugin";
2
+ /** The collections the blog creates on first install. Owners can change all of it afterwards. */
3
+ export declare const COLLECTIONS: readonly ["blog-categories", "blog-tags", "blog-posts", "blog-comments", "blog-home"];
4
+ /** Blocks a post's body allows when it's created. Owners can add their own. */
5
+ export declare const BODY_BLOCKS: string[];
6
+ /** Who writes and who runs the blog. Created once, then owners change them under Roles like any other. */
7
+ export declare function blogRoles(): PluginRole[];
8
+ /** The name shown on a post. Filled from the writer's account, and only editors can change it. */
9
+ export declare const BYLINE_FIELD: {
10
+ name: string;
11
+ type: string;
12
+ config: {
13
+ maxLength: number;
14
+ };
15
+ };
16
+ /** A field the plugin's code reads or writes, by collection: the contract Extensions checks. */
17
+ export declare const CONTRACT: {
18
+ "blog-posts": {
19
+ slug: string;
20
+ title: string;
21
+ excerpt: string;
22
+ body: string;
23
+ byline: string;
24
+ categories: string;
25
+ tags: string;
26
+ allowComments: string;
27
+ readingMinutes: string;
28
+ };
29
+ "blog-categories": {
30
+ slug: string;
31
+ name: string;
32
+ };
33
+ "blog-tags": {
34
+ slug: string;
35
+ name: string;
36
+ };
37
+ "blog-comments": {
38
+ post: string;
39
+ parent: string;
40
+ name: string;
41
+ body: string;
42
+ state: string;
43
+ };
44
+ };
45
+ export declare function blogSchema(basePath: string): {
46
+ version: number;
47
+ collections: ({
48
+ slug: string;
49
+ name: string;
50
+ description: string;
51
+ urlPattern: string;
52
+ rules: {
53
+ listRule: string;
54
+ viewRule: string;
55
+ createRule: null;
56
+ updateRule: null;
57
+ deleteRule: null;
58
+ };
59
+ fields: ({
60
+ name: string;
61
+ type: string;
62
+ config: {
63
+ unique: boolean;
64
+ maxLength: number;
65
+ pattern: string;
66
+ patternError: string;
67
+ };
68
+ } | {
69
+ name: string;
70
+ type: string;
71
+ config: {
72
+ required: boolean;
73
+ maxLength: number;
74
+ multiline?: undefined;
75
+ collection?: undefined;
76
+ displayField?: undefined;
77
+ };
78
+ } | {
79
+ name: string;
80
+ type: string;
81
+ config: {
82
+ multiline: boolean;
83
+ maxLength: number;
84
+ required?: undefined;
85
+ collection?: undefined;
86
+ displayField?: undefined;
87
+ };
88
+ } | {
89
+ name: string;
90
+ type: string;
91
+ config: {
92
+ collection: string;
93
+ displayField: string;
94
+ required?: undefined;
95
+ maxLength?: undefined;
96
+ multiline?: undefined;
97
+ };
98
+ })[];
99
+ type?: undefined;
100
+ } | {
101
+ slug: string;
102
+ name: string;
103
+ description: string;
104
+ urlPattern: string;
105
+ rules: {
106
+ listRule: string;
107
+ viewRule: string;
108
+ createRule: null;
109
+ updateRule: null;
110
+ deleteRule: null;
111
+ };
112
+ fields: ({
113
+ name: string;
114
+ type: string;
115
+ config: {
116
+ maxLength: number;
117
+ };
118
+ } | {
119
+ name: string;
120
+ type: string;
121
+ config: {
122
+ required: boolean;
123
+ maxLength: number;
124
+ searchable: boolean;
125
+ multiline?: undefined;
126
+ allowedBlocks?: undefined;
127
+ collection?: undefined;
128
+ displayField?: undefined;
129
+ allowMultiple?: undefined;
130
+ defaultValue?: undefined;
131
+ };
132
+ } | {
133
+ name: string;
134
+ type: string;
135
+ config: {
136
+ multiline: boolean;
137
+ maxLength: number;
138
+ searchable: boolean;
139
+ required?: undefined;
140
+ allowedBlocks?: undefined;
141
+ collection?: undefined;
142
+ displayField?: undefined;
143
+ allowMultiple?: undefined;
144
+ defaultValue?: undefined;
145
+ };
146
+ } | {
147
+ name: string;
148
+ type: string;
149
+ config: {
150
+ required?: undefined;
151
+ maxLength?: undefined;
152
+ searchable?: undefined;
153
+ multiline?: undefined;
154
+ allowedBlocks?: undefined;
155
+ collection?: undefined;
156
+ displayField?: undefined;
157
+ allowMultiple?: undefined;
158
+ defaultValue?: undefined;
159
+ };
160
+ } | {
161
+ name: string;
162
+ type: string;
163
+ config: {
164
+ allowedBlocks: string[];
165
+ required?: undefined;
166
+ maxLength?: undefined;
167
+ searchable?: undefined;
168
+ multiline?: undefined;
169
+ collection?: undefined;
170
+ displayField?: undefined;
171
+ allowMultiple?: undefined;
172
+ defaultValue?: undefined;
173
+ };
174
+ } | {
175
+ name: string;
176
+ type: string;
177
+ config: {
178
+ collection: string;
179
+ displayField: string;
180
+ allowMultiple: boolean;
181
+ required?: undefined;
182
+ maxLength?: undefined;
183
+ searchable?: undefined;
184
+ multiline?: undefined;
185
+ allowedBlocks?: undefined;
186
+ defaultValue?: undefined;
187
+ };
188
+ } | {
189
+ name: string;
190
+ type: string;
191
+ config: {
192
+ defaultValue: boolean;
193
+ required?: undefined;
194
+ maxLength?: undefined;
195
+ searchable?: undefined;
196
+ multiline?: undefined;
197
+ allowedBlocks?: undefined;
198
+ collection?: undefined;
199
+ displayField?: undefined;
200
+ allowMultiple?: undefined;
201
+ };
202
+ })[];
203
+ type?: undefined;
204
+ } | {
205
+ slug: string;
206
+ name: string;
207
+ description: string;
208
+ urlPattern: null;
209
+ rules: {
210
+ listRule: string;
211
+ viewRule: string;
212
+ createRule: string;
213
+ updateRule: null;
214
+ deleteRule: string;
215
+ };
216
+ fields: ({
217
+ name: string;
218
+ type: string;
219
+ config: {
220
+ collection: string;
221
+ displayField: string;
222
+ required: boolean;
223
+ maxLength?: undefined;
224
+ multiline?: undefined;
225
+ options?: undefined;
226
+ defaultValue?: undefined;
227
+ };
228
+ } | {
229
+ name: string;
230
+ type: string;
231
+ config: {
232
+ collection: string;
233
+ displayField: string;
234
+ required?: undefined;
235
+ maxLength?: undefined;
236
+ multiline?: undefined;
237
+ options?: undefined;
238
+ defaultValue?: undefined;
239
+ };
240
+ } | {
241
+ name: string;
242
+ type: string;
243
+ config: {
244
+ required: boolean;
245
+ maxLength: number;
246
+ collection?: undefined;
247
+ displayField?: undefined;
248
+ multiline?: undefined;
249
+ options?: undefined;
250
+ defaultValue?: undefined;
251
+ };
252
+ } | {
253
+ name: string;
254
+ type: string;
255
+ config: {
256
+ required: boolean;
257
+ multiline: boolean;
258
+ maxLength: number;
259
+ collection?: undefined;
260
+ displayField?: undefined;
261
+ options?: undefined;
262
+ defaultValue?: undefined;
263
+ };
264
+ } | {
265
+ name: string;
266
+ type: string;
267
+ config: {
268
+ options: {
269
+ label: string;
270
+ value: string;
271
+ }[];
272
+ defaultValue: string;
273
+ collection?: undefined;
274
+ displayField?: undefined;
275
+ required?: undefined;
276
+ maxLength?: undefined;
277
+ multiline?: undefined;
278
+ };
279
+ })[];
280
+ type?: undefined;
281
+ } | {
282
+ slug: string;
283
+ name: string;
284
+ description: string;
285
+ type: string;
286
+ urlPattern: string;
287
+ rules: {
288
+ listRule: string;
289
+ viewRule: string;
290
+ createRule: null;
291
+ updateRule: null;
292
+ deleteRule: null;
293
+ };
294
+ fields: ({
295
+ name: string;
296
+ type: string;
297
+ config: {
298
+ required: boolean;
299
+ maxLength: number;
300
+ allowedBlocks?: undefined;
301
+ };
302
+ } | {
303
+ name: string;
304
+ type: string;
305
+ config: {
306
+ allowedBlocks: string[];
307
+ required?: undefined;
308
+ maxLength?: undefined;
309
+ };
310
+ })[];
311
+ })[];
312
+ blocks: never[];
313
+ };
package/schema.js ADDED
@@ -0,0 +1,119 @@
1
+ /** The collections the blog creates on first install. Owners can change all of it afterwards. */
2
+ export const COLLECTIONS = ["blog-categories", "blog-tags", "blog-posts", "blog-comments", "blog-home"];
3
+ /** Blocks a post's body allows when it's created. Owners can add their own. */
4
+ export const BODY_BLOCKS = ["blog_text", "blog_image", "blog_quote", "blog_code", "blog_embed", "blog_callout"];
5
+ /** Who writes and who runs the blog. Created once, then owners change them under Roles like any other. */
6
+ export function blogRoles() {
7
+ const writing = ["dashboard:access", "collection:read", "file:list", "file:read", "file:create"];
8
+ return [
9
+ {
10
+ name: "blog-author",
11
+ label: "Blog author",
12
+ description: "Writes posts, and edits and deletes only their own. Their byline is their name.",
13
+ permissions: writing,
14
+ records: { "blog-posts": ["create", "list:own", "read:own", "update:own", "delete:own"] },
15
+ },
16
+ {
17
+ name: "blog-editor",
18
+ label: "Blog editor",
19
+ description: "Edits every post, category and tag, writes any byline, and moderates comments.",
20
+ permissions: [...writing, "file:delete", "ext.blog:moderate", "ext.blog:credit"],
21
+ records: Object.fromEntries(COLLECTIONS.map((slug) => [slug, ["list", "read", "create", "update", "delete"]])),
22
+ },
23
+ ];
24
+ }
25
+ /** Filled from the title or name when left empty, so it isn't required. */
26
+ const SLUG_FIELD = {
27
+ name: "slug",
28
+ type: "text",
29
+ config: { unique: true, maxLength: 80, pattern: "^[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$", patternError: "Use lowercase letters, numbers and hyphens, starting and ending with a letter or number." },
30
+ };
31
+ /** The name shown on a post. Filled from the writer's account, and only editors can change it. */
32
+ export const BYLINE_FIELD = { name: "byline", type: "text", config: { maxLength: 120 } };
33
+ const PUBLIC = { listRule: "", viewRule: "", createRule: null, updateRule: null, deleteRule: null };
34
+ /** A field the plugin's code reads or writes, by collection: the contract Extensions checks. */
35
+ export const CONTRACT = {
36
+ "blog-posts": { slug: "text", title: "text", excerpt: "text", body: "stream", byline: "text", categories: "reference", tags: "reference", allowComments: "boolean", readingMinutes: "number" },
37
+ "blog-categories": { slug: "text", name: "text" },
38
+ "blog-tags": { slug: "text", name: "text" },
39
+ "blog-comments": { post: "reference", parent: "reference", name: "text", body: "text", state: "radio" },
40
+ };
41
+ export function blogSchema(basePath) {
42
+ return {
43
+ version: 1,
44
+ collections: [
45
+ {
46
+ slug: "blog-categories",
47
+ name: "Categories",
48
+ description: "Broad topics. A category can sit inside another.",
49
+ urlPattern: `${basePath}/category/:slug`,
50
+ rules: PUBLIC,
51
+ fields: [
52
+ SLUG_FIELD,
53
+ { name: "name", type: "text", config: { required: true, maxLength: 120 } },
54
+ { name: "description", type: "text", config: { multiline: true, maxLength: 1000 } },
55
+ { name: "parent", type: "reference", config: { collection: "blog-categories", displayField: "name" } },
56
+ ],
57
+ },
58
+ {
59
+ slug: "blog-tags",
60
+ name: "Tags",
61
+ description: "Narrow topics, many to a post.",
62
+ urlPattern: `${basePath}/tag/:slug`,
63
+ rules: PUBLIC,
64
+ fields: [
65
+ SLUG_FIELD,
66
+ { name: "name", type: "text", config: { required: true, maxLength: 120 } },
67
+ ],
68
+ },
69
+ {
70
+ slug: "blog-posts",
71
+ name: "Posts",
72
+ description: "Articles. A slug, excerpt and reading time are filled in when left empty.",
73
+ urlPattern: `${basePath}/:slug`,
74
+ rules: { listRule: 'status = "published"', viewRule: 'status = "published"', createRule: null, updateRule: null, deleteRule: null },
75
+ fields: [
76
+ { name: "title", type: "text", config: { required: true, maxLength: 200, searchable: true } },
77
+ SLUG_FIELD,
78
+ { name: "excerpt", type: "text", config: { multiline: true, maxLength: 500, searchable: true } },
79
+ { name: "cover", type: "image", config: {} },
80
+ { name: "body", type: "stream", config: { allowedBlocks: BODY_BLOCKS } },
81
+ BYLINE_FIELD,
82
+ { name: "categories", type: "reference", config: { collection: "blog-categories", displayField: "name", allowMultiple: true } },
83
+ { name: "tags", type: "reference", config: { collection: "blog-tags", displayField: "name", allowMultiple: true } },
84
+ { name: "featured", type: "boolean", config: {} },
85
+ { name: "allowComments", type: "boolean", config: { defaultValue: true } },
86
+ { name: "readingMinutes", type: "number", config: {} },
87
+ ],
88
+ },
89
+ {
90
+ slug: "blog-comments",
91
+ name: "Comments",
92
+ description: "Readers' comments. New ones wait for approval unless comments are open.",
93
+ urlPattern: null,
94
+ // Commenters also see their own comments while they wait, so a new comment doesn't seem to vanish.
95
+ rules: { listRule: 'state = "approved" || (@request.auth.id != "" && createdById = @request.auth.id)', viewRule: 'state = "approved" || (@request.auth.id != "" && createdById = @request.auth.id)', createRule: '@request.auth.id != ""', updateRule: null, deleteRule: '@request.auth.id != "" && createdById = @request.auth.id' },
96
+ fields: [
97
+ { name: "post", type: "reference", config: { collection: "blog-posts", displayField: "title", required: true } },
98
+ { name: "parent", type: "reference", config: { collection: "blog-comments", displayField: "name" } },
99
+ { name: "name", type: "text", config: { required: true, maxLength: 80 } },
100
+ { name: "body", type: "text", config: { required: true, multiline: true, maxLength: 5000 } },
101
+ { name: "state", type: "radio", config: { options: [{ label: "Waiting for review", value: "pending" }, { label: "Approved", value: "approved" }, { label: "Spam", value: "spam" }], defaultValue: "pending" } },
102
+ ],
103
+ },
104
+ {
105
+ slug: "blog-home",
106
+ name: "Blog home",
107
+ description: "The heading and introduction of the blog's front page.",
108
+ type: "singleton",
109
+ urlPattern: basePath,
110
+ rules: PUBLIC,
111
+ fields: [
112
+ { name: "title", type: "text", config: { required: true, maxLength: 120 } },
113
+ { name: "intro", type: "stream", config: { allowedBlocks: BODY_BLOCKS } },
114
+ ],
115
+ },
116
+ ],
117
+ blocks: [],
118
+ };
119
+ }
@@ -0,0 +1,64 @@
1
+ import { type SiteWords } from "tansy/react";
2
+ /** What visitors read on the blog's pages, read as `t("blog.<key>")`. Themes and owners can word any of it differently. */
3
+ export declare const siteMessages: {
4
+ en: {
5
+ blog: {
6
+ home: string;
7
+ noPosts: string;
8
+ noPostsHere: string;
9
+ newerPosts: string;
10
+ olderPosts: string;
11
+ minutes: string;
12
+ tags: string;
13
+ morePosts: string;
14
+ category: string;
15
+ tag: string;
16
+ video: string;
17
+ comments: string;
18
+ noComments: string;
19
+ leaveComment: string;
20
+ name: string;
21
+ comment: string;
22
+ reply: string;
23
+ postComment: string;
24
+ postReply: string;
25
+ posting: string;
26
+ cancel: string;
27
+ waiting: string;
28
+ signIn: string;
29
+ failed: string;
30
+ offline: string;
31
+ };
32
+ };
33
+ ar: {
34
+ blog: {
35
+ home: string;
36
+ noPosts: string;
37
+ noPostsHere: string;
38
+ newerPosts: string;
39
+ olderPosts: string;
40
+ minutes: string;
41
+ tags: string;
42
+ morePosts: string;
43
+ category: string;
44
+ tag: string;
45
+ video: string;
46
+ comments: string;
47
+ noComments: string;
48
+ leaveComment: string;
49
+ name: string;
50
+ comment: string;
51
+ reply: string;
52
+ postComment: string;
53
+ postReply: string;
54
+ posting: string;
55
+ cancel: string;
56
+ waiting: string;
57
+ signIn: string;
58
+ failed: string;
59
+ offline: string;
60
+ };
61
+ };
62
+ };
63
+ /** The blog's words in the page's language, or in English where a theme passes none. */
64
+ export declare const blogWords: (words: SiteWords | undefined) => import("tansy/plugin").Formatters;