@tansy/blog 0.0.0-stage → 0.1.2

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/CHANGELOG.md ADDED
@@ -0,0 +1,25 @@
1
+ # Changelog
2
+
3
+ What changed in each release of `@tansy/blog`. Releases up to 0.1.1 went out with every other
4
+ package on one version and are described in [tansy's changelog](../../CHANGELOG.md).
5
+
6
+ ## 0.1.2 — 2026-11-22
7
+
8
+ The parts `@tansy/blog/render` exports now fit inside a theme's own design without CSS to undo them.
9
+
10
+ - **Parts carry no outer margin or border.** The plugin's own post page still places them as before,
11
+ inside `.bl-main`, so it looks the same. A theme that embeds `MorePosts` or `PostComments` now gets
12
+ no top margin, padding or rule above them, and `PostMeta`, `PostCategories`, `PostTags` and
13
+ `PostList` bring no outer margin either. A theme that relied on that spacing sets it itself, as the
14
+ blog, dispatch and magazine themes in this repository now do: until you upgrade those themes, the
15
+ space and rule above "More posts" and the comments are missing on their post pages.
16
+ - **Headings are the theme's.** `PostComments` takes `heading`, `formHeading` and `headingLevel`, and
17
+ `MorePosts` takes `heading` and `headingLevel`. A string replaces the text, `false` hides the
18
+ heading while the section keeps the default text as its `aria-label`, and `headingLevel` (2 to 6)
19
+ sets the main heading's level, with the form heading and the post titles in `MorePosts` one below.
20
+ `PostList` takes `headingLevel` for its post titles. All new props are optional.
21
+ - **Ids no longer collide.** The headings take their ids from React's `useId`, so two parts on one
22
+ page don't share `bl-comments-title` or `bl-more-title`.
23
+ - **Class hooks for every element a theme styles:** `bl-comments-title`, `bl-form-title`,
24
+ `bl-more-title`, `bl-comments-empty` and `bl-replies`, beside the existing class names. Every rule
25
+ weighs a single class, so one class of the theme's overrides it.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Mohamed Salah
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,13 @@
1
- # Temporary Holding Version
1
+ <!-- Generated by scripts/package-metadata.mjs. Change that script, not this file. -->
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ # @tansy/blog
4
+
5
+ Turns tansy into a blog: posts, categories, tags, authors, comments and feeds.
6
+
7
+ ```bash
8
+ npm install @tansy/blog
9
+ ```
10
+
11
+ Add it to `tansy.config.ts`. See [the blog plugin documentation](https://github.com/mhmdsalahsebai/tansy/blob/main/docs/plugins/blog.md) for what it adds and the options it takes.
12
+
13
+ A first-party plugin for [tansy](https://github.com/mhmdsalahsebai/tansy), a self-hosted, runtime-schema CMS for Next.js. MIT licensed.
package/admin.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ declare const _default: import("tansy/admin").AdminPluginParts;
2
+ export default _default;
package/admin.js ADDED
@@ -0,0 +1,44 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { defineAdminPlugin, PageHeader } from "tansy/admin";
3
+ import { getT } from "tansy/server";
4
+ import { ModerateButtons } from "./moderate";
5
+ const text = (value) => (typeof value === "string" ? value : "");
6
+ /** As the signed-in person, so someone without access to a collection gets null rather than another person's view. */
7
+ async function count(records, slug, filter) {
8
+ return records.list(slug, { filter, perPage: 1, fields: "id" }).then((page) => page.totalItems).catch(() => null);
9
+ }
10
+ async function CommentQueue({ records, user }) {
11
+ const { t } = await getT(user.id);
12
+ const pending = await records.list("blog-comments", { filter: 'state = "pending"', sort: "createdAt", perPage: 100, expand: "post", fields: "id,name,body,createdAt,expand.post.title" }).catch(() => null);
13
+ return (_jsxs("div", { className: "cms-gutter", children: [_jsx(PageHeader, { title: t("ext.blog.pages.blog/comments"), description: t("ext.blog.queue.intro") }), pending === null && _jsx("p", { className: "cms-empty", children: t("ext.blog.queue.cantRead") }), pending?.items.length === 0 && _jsx("p", { className: "cms-empty", children: t("ext.blog.queue.empty") }), pending && pending.items.length > 0 && (_jsx("ul", { className: "cms-panel cms-divide", children: pending.items.map((comment) => {
14
+ const post = comment.expand?.post;
15
+ return (_jsxs("li", { className: "cms-cell", children: [_jsx("p", { className: "cms-text-sm cms-faded cms-mb-1", children: t("ext.blog.queue.on", { name: text(comment.name), post: text(post?.title) || t("ext.blog.queue.aPost") }) }), _jsx("p", { className: "cms-mb-2", style: { whiteSpace: "pre-line" }, children: text(comment.body) }), _jsx(ModerateButtons, { id: Number(comment.id) })] }, String(comment.id)));
16
+ }) })), pending && pending.totalItems > pending.items.length && _jsx("p", { className: "cms-muted cms-mt-4", children: t("ext.blog.queue.showing", { shown: pending.items.length, total: pending.totalItems }) })] }));
17
+ }
18
+ async function Overview({ records, user }) {
19
+ const { t } = await getT(user.id);
20
+ const [pending, drafts, published] = await Promise.all([
21
+ count(records, "blog-comments", 'state = "pending"'),
22
+ count(records, "blog-posts", 'status = "draft"'),
23
+ count(records, "blog-posts", 'status = "published"'),
24
+ ]);
25
+ const line = (value, key) => _jsx("li", { children: value === null ? t("ext.blog.overview.unknown", { label: t(`ext.blog.overview.${key}Label`) }) : t(`ext.blog.overview.${key}`, { count: value }) });
26
+ return _jsxs("ul", { className: "cms-muted cms-text-sm", children: [line(pending, "pending"), line(drafts, "drafts"), line(published, "published")] });
27
+ }
28
+ export default defineAdminPlugin({
29
+ pages: [{ path: "blog/comments", title: "Comments to review", permission: "ext.blog:moderate", component: CommentQueue }],
30
+ section: {
31
+ title: "Blog",
32
+ icon: "newspaper",
33
+ items: [
34
+ { collection: "blog-posts" },
35
+ { collection: "blog-categories" },
36
+ { collection: "blog-tags" },
37
+ { page: "blog/comments" },
38
+ { collection: "blog-comments", title: "All comments" },
39
+ { collection: "blog-home", title: "Blog home page" },
40
+ { settings: true },
41
+ ],
42
+ },
43
+ widgets: [{ id: "blog-overview", title: "Blog", permission: "ext.blog:moderate", component: Overview }],
44
+ });
package/blog.css ADDED
@@ -0,0 +1,64 @@
1
+ /*
2
+ * The blog plugin's pages. Colours, fonts and widths come from the active theme's --site-* tokens, with plain fallbacks.
3
+ * The exported parts (.bl-meta, .bl-kicker, .bl-list, .bl-tags, .bl-more, .bl-comments) carry no outer margin or border:
4
+ * the plugin's own template places them, under :where(.bl-main) at the end, and a theme that embeds them places them itself.
5
+ * Every selector weighs one class, so one class of the theme's overrides it.
6
+ */
7
+ .bl-main {
8
+ max-width: var(--site-size-measure, 42rem);
9
+ margin: 0 auto;
10
+ padding: var(--site-space-section, 3rem) 1rem;
11
+ color: var(--site-color-text, inherit);
12
+ font-family: var(--site-font-body, inherit);
13
+ line-height: 1.6;
14
+ }
15
+ .bl-main h1 { font-size: 2.25rem; line-height: 1.2; margin: 0 0 0.5rem; }
16
+ .bl-main a { color: var(--site-color-accent, inherit); }
17
+ .bl-muted, .bl-meta { color: var(--site-color-muted, #666); }
18
+ .bl-meta { font-size: 0.875rem; margin: 0; }
19
+ .bl-kicker { font-size: 0.8125rem; letter-spacing: 0.04em; text-transform: uppercase; margin: 0; display: flex; gap: 0.75rem; flex-wrap: wrap; }
20
+ .bl-cover { width: 100%; height: auto; border-radius: var(--site-radius-card, 0.5rem); margin: 0 0 1.5rem; }
21
+ .bl-body > * + * { margin-top: var(--site-space-gap, 1.25rem); }
22
+ .bl-list { list-style: none; padding: 0; margin: 0; display: grid; gap: var(--site-space-gap, 1.5rem); }
23
+ .bl-item { padding-bottom: var(--site-space-gap, 1.5rem); border-bottom: 1px solid var(--site-color-border, #e5e5e5); }
24
+ .bl-item-title { font-size: 1.375rem; margin: 0 0 0.25rem; }
25
+ .bl-featured .bl-item-title::before { content: "★ "; color: var(--site-color-accent, currentColor); }
26
+ .bl-tags { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 0.5rem; }
27
+ .bl-tags a, .bl-tags span { display: inline-block; padding: 0.125rem 0.625rem; border: 1px solid var(--site-color-border, #ddd); border-radius: 999px; font-size: 0.8125rem; text-decoration: none; }
28
+ .bl-quote { margin: 0; padding-left: 1rem; border-left: 3px solid var(--site-color-accent, currentColor); font-style: italic; }
29
+ .bl-quote cite { display: block; font-style: normal; color: var(--site-color-muted, #666); margin-top: 0.25rem; }
30
+ .bl-quote cite::before { content: "— "; }
31
+ .bl-callout { padding: 0.75rem 1rem; border-radius: var(--site-radius-card, 0.5rem); border: 1px solid var(--site-color-border, #ddd); }
32
+ .bl-callout-tip { border-color: #2f855a; }
33
+ .bl-callout-warning { border-color: #b7791f; }
34
+ .bl-figure { margin: 0; }
35
+ .bl-figure img { width: 100%; height: auto; border-radius: var(--site-radius-card, 0.5rem); }
36
+ .bl-figure figcaption { font-size: 0.875rem; color: var(--site-color-muted, #666); margin-top: 0.5rem; }
37
+ .bl-embed { position: relative; aspect-ratio: 16 / 9; }
38
+ .bl-embed iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; border-radius: var(--site-radius-card, 0.5rem); }
39
+ /* The editor's canvas: the parts of a block shown only while it's edited. */
40
+ .bl-quote-source { display: flex; gap: 0.35em; margin-top: 0.25rem; font-style: normal; color: var(--site-color-muted, #666); }
41
+ .bl-quote-source::before { content: "—"; }
42
+ .bl-editor-note { margin-top: 0.5rem; font-size: 0.875rem; color: var(--site-color-muted, #666); }
43
+ .bl-editor-placeholder { padding: 1rem; border: 1px dashed var(--site-color-border, #ccc); border-radius: var(--site-radius-card, 0.5rem); }
44
+ .bl-editor-placeholder p { margin: 0; }
45
+ .bl-code { overflow-x: auto; padding: 1rem; border-radius: var(--site-radius-card, 0.5rem); background: color-mix(in srgb, var(--site-color-text, #222) 6%, transparent); font-size: 0.875rem; }
46
+ .bl-thread { list-style: none; padding: 0; margin: 1rem 0; display: grid; gap: 1rem; }
47
+ .bl-replies { margin-left: 1.5rem; }
48
+ .bl-comment-body { white-space: pre-line; overflow-wrap: anywhere; margin: 0 0 0.25rem; }
49
+ .bl-form { display: grid; gap: 0.375rem; margin: 1rem 0; }
50
+ .bl-form input, .bl-form textarea { font: inherit; padding: 0.5rem; border: 1px solid var(--site-color-border, #ccc); border-radius: 0.375rem; background: transparent; color: inherit; }
51
+ .bl-actions { display: flex; gap: 0.5rem; margin: 0.5rem 0 0; }
52
+ .bl-form button { font: inherit; padding: 0.5rem 1rem; border-radius: 0.375rem; border: 0; background: var(--site-color-accent, #222); color: var(--site-color-on-accent, #fff); cursor: pointer; }
53
+ .bl-form button[type="button"] { background: transparent; color: inherit; border: 1px solid var(--site-color-border, #ccc); }
54
+ .bl-form button:disabled { opacity: 0.6; cursor: default; }
55
+ .bl-link { font: inherit; font-size: 0.875rem; background: none; border: 0; padding: 0; color: var(--site-color-accent, inherit); cursor: pointer; text-decoration: underline; }
56
+ .bl-error { color: #c53030; margin: 0; }
57
+ .bl-pager { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-top: var(--site-space-section, 3rem); font-size: 0.875rem; color: var(--site-color-muted, #666); }
58
+ /* Inner spacing: a post's meta inside a list item or a comment. */
59
+ :where(.bl-item, .bl-comment) .bl-meta { margin-bottom: 1rem; }
60
+ /* Where the plugin's own template places the parts. */
61
+ :where(.bl-main) .bl-meta { margin-bottom: 1rem; }
62
+ :where(.bl-main) .bl-kicker { margin-bottom: 0.5rem; }
63
+ :where(.bl-main) .bl-list, :where(.bl-main) .bl-tags { margin-top: 2rem; }
64
+ :where(.bl-main) > .bl-more, :where(.bl-main) > .bl-comments { margin-top: var(--site-space-section, 3rem); padding-top: 1.5rem; border-top: 1px solid var(--site-color-border, #e5e5e5); }
package/client.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ declare const _default: import("tansy/admin").AdminClientParts;
2
+ export default _default;
package/client.js ADDED
@@ -0,0 +1,17 @@
1
+ import { defineAdminClient, translate } from "tansy/admin";
2
+ import { blockEditors } from "./editors";
3
+ import { setCommentState } from "./moderate";
4
+ const action = (id, label, state) => ({
5
+ id,
6
+ label,
7
+ permission: "ext.blog:moderate",
8
+ collections: ["blog-comments"],
9
+ run: async ({ ids, refresh }) => {
10
+ await setCommentState(ids, state, translate);
11
+ refresh();
12
+ },
13
+ });
14
+ export default defineAdminClient({
15
+ bulkActions: [action("blog-approve", "Approve", "approved"), action("blog-spam", "Mark as spam", "spam")],
16
+ blockEditors,
17
+ });
package/comments.d.ts ADDED
@@ -0,0 +1,25 @@
1
+ import { type SiteWords } from "tansy/react";
2
+ import type { HeadingLevel } from "./text";
3
+ export interface PublicComment {
4
+ id: number;
5
+ name: string;
6
+ body: string;
7
+ parent: number | null;
8
+ createdAt: string;
9
+ pending?: boolean;
10
+ }
11
+ /** How a theme titles the comments: see `PostComments` in render.tsx. */
12
+ export interface CommentsHeadings {
13
+ /** The section's heading. A string replaces "Comments"; `false` shows none, and the section keeps "Comments" as its `aria-label`. */
14
+ heading?: string | false;
15
+ /** The heading over the form. A string replaces "Leave a comment"; `false` shows none. */
16
+ formHeading?: string | false;
17
+ /** The section heading's level, 2 to 6, default 2. The form heading is one level below. */
18
+ headingLevel?: HeadingLevel;
19
+ }
20
+ /** Approved comments from the page, plus the reader's own new ones. Replies go one level deep. */
21
+ export declare function Comments({ postId, initial, words: given, heading, formHeading, headingLevel }: {
22
+ postId: number;
23
+ initial: PublicComment[];
24
+ words?: SiteWords;
25
+ } & CommentsHeadings): import("react").JSX.Element;
package/comments.js ADDED
@@ -0,0 +1,64 @@
1
+ "use client";
2
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
3
+ import { useId, useState } from "react";
4
+ import { apiPath } from "tansy/react";
5
+ import { blogWords } from "./site-messages";
6
+ import { Heading } from "./heading";
7
+ function CommentForm({ postId, parent, onPosted, onCancel, words }) {
8
+ const { t } = words;
9
+ const id = useId();
10
+ const [name, setName] = useState("");
11
+ const [body, setBody] = useState("");
12
+ const [error, setError] = useState(null);
13
+ const [sending, setSending] = useState(false);
14
+ async function submit(event) {
15
+ event.preventDefault();
16
+ setSending(true);
17
+ setError(null);
18
+ try {
19
+ const response = await fetch(apiPath("/collections/blog-comments/records"), {
20
+ method: "POST",
21
+ headers: { "content-type": "application/json" },
22
+ body: JSON.stringify({ post: postId, name, body, ...(parent ? { parent } : {}) }),
23
+ });
24
+ const json = await response.json().catch(() => null);
25
+ if (response.status === 401 || response.status === 403)
26
+ return setError(t("blog.signIn"));
27
+ if (!response.ok || typeof json?.id !== "number")
28
+ return setError(t("blog.failed"));
29
+ onPosted({ id: json.id, name, body, parent, createdAt: json.createdAt ?? new Date().toISOString(), pending: json.state !== "approved" });
30
+ setBody("");
31
+ }
32
+ catch {
33
+ setError(t("blog.offline"));
34
+ }
35
+ finally {
36
+ setSending(false);
37
+ }
38
+ }
39
+ return (_jsxs("form", { className: "bl-form", onSubmit: submit, children: [_jsx("label", { htmlFor: `${id}-name`, children: t("blog.name") }), _jsx("input", { id: `${id}-name`, value: name, onChange: (event) => setName(event.target.value), maxLength: 80, required: true, autoComplete: "name" }), _jsx("label", { htmlFor: `${id}-body`, children: parent ? t("blog.reply") : t("blog.comment") }), _jsx("textarea", { id: `${id}-body`, value: body, onChange: (event) => setBody(event.target.value), maxLength: 5000, rows: 4, required: true }), error && _jsx("p", { className: "bl-error", role: "alert", children: error }), _jsxs("p", { className: "bl-actions", children: [_jsx("button", { type: "submit", disabled: sending, children: sending ? t("blog.posting") : parent ? t("blog.postReply") : t("blog.postComment") }), onCancel && _jsx("button", { type: "button", onClick: onCancel, children: t("blog.cancel") })] })] }));
40
+ }
41
+ function Entry({ comment, children, words }) {
42
+ return (_jsxs("li", { className: "bl-comment", children: [_jsxs("p", { className: "bl-meta", children: [_jsx("strong", { children: comment.name }), " \u00B7 ", _jsx("time", { dateTime: comment.createdAt, children: comment.createdAt ? words.formatDate(comment.createdAt) : "" }), comment.pending && _jsxs(_Fragment, { children: [" \u00B7 ", words.t("blog.waiting")] })] }), _jsx("p", { className: "bl-comment-body", children: comment.body }), children] }));
43
+ }
44
+ /** Approved comments from the page, plus the reader's own new ones. Replies go one level deep. */
45
+ export function Comments({ postId, initial, words: given, heading, formHeading, headingLevel = 2 }) {
46
+ const words = blogWords(given);
47
+ const { t } = words;
48
+ const titleId = useId();
49
+ const [comments, setComments] = useState(initial);
50
+ const [replyingTo, setReplyingTo] = useState(null);
51
+ const add = (comment) => {
52
+ setComments((current) => [...current, comment]);
53
+ setReplyingTo(null);
54
+ };
55
+ const topLevel = comments.filter((comment) => !comment.parent);
56
+ const title = heading ?? t("blog.comments");
57
+ const formTitle = formHeading ?? t("blog.leaveComment");
58
+ return (_jsxs("section", { className: "bl-comments", ...(title === false ? { "aria-label": t("blog.comments") } : { "aria-labelledby": titleId }), children: [title !== false && _jsx(Heading, { level: headingLevel, id: titleId, className: "bl-comments-title", children: title }), topLevel.length === 0 && _jsx("p", { className: "bl-muted bl-comments-empty", children: t("blog.noComments") }), _jsx("ol", { className: "bl-thread", children: topLevel.map((comment) => {
59
+ const replies = comments.filter((reply) => reply.parent === comment.id);
60
+ return (_jsxs(Entry, { comment: comment, words: words, children: [replies.length > 0 && _jsx("ol", { className: "bl-thread bl-replies", children: replies.map((reply) => _jsx(Entry, { comment: reply, words: words }, reply.id)) }), !comment.pending && (replyingTo === comment.id
61
+ ? _jsx(CommentForm, { postId: postId, parent: comment.id, onPosted: add, onCancel: () => setReplyingTo(null), words: words })
62
+ : _jsx("button", { type: "button", className: "bl-link", onClick: () => setReplyingTo(comment.id), children: t("blog.reply") }))] }, comment.id));
63
+ }) }), formTitle !== false && _jsx(Heading, { level: headingLevel + 1, className: "bl-form-title", children: formTitle }), _jsx(CommentForm, { postId: postId, parent: null, onPosted: add, words: words })] }));
64
+ }
package/editors.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ import { type BlockEditorDefinition } from "tansy/admin";
2
+ import "./blog.css";
3
+ export declare const blockEditors: BlockEditorDefinition[];
package/editors.js ADDED
@@ -0,0 +1,48 @@
1
+ "use client";
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { useT } from "tansy/admin";
4
+ import { embedUrl } from "./text";
5
+ import "./blog.css";
6
+ /*
7
+ * The blog's blocks on the editor's canvas, built from the same markup and classes as
8
+ * render.tsx, so they look as they will on the site and are edited in place.
9
+ */
10
+ const text = (value) => (typeof value === "string" ? value : "");
11
+ const TONES = ["info", "tip", "warning"];
12
+ function TextEditor({ Field }) {
13
+ const { t } = useT();
14
+ return _jsx(Field, { name: "body", placeholder: t("ext.blog.editors.startWriting") });
15
+ }
16
+ function QuoteEditor({ block, selected, Field }) {
17
+ const { t } = useT();
18
+ return (_jsxs("blockquote", { className: "bl-quote", children: [_jsx(Field, { name: "text", placeholder: t("ext.blog.editors.quote") }), (selected || text(block.value.source)) && _jsx("div", { className: "bl-quote-source", children: _jsx(Field, { name: "source", placeholder: t("ext.blog.editors.source") }) })] }));
19
+ }
20
+ function CalloutEditor({ block, Field }) {
21
+ const { t } = useT();
22
+ const tone = TONES.includes(text(block.value.tone)) ? text(block.value.tone) : "info";
23
+ return _jsx("aside", { className: `bl-callout bl-callout-${tone}`, children: _jsx(Field, { name: "body", placeholder: t("ext.blog.editors.note") }) });
24
+ }
25
+ function ImageEditor({ block, selected, Field }) {
26
+ const { t } = useT();
27
+ return (_jsxs("figure", { className: "bl-figure", children: [_jsx(Field, { name: "image", placeholder: t("ext.blog.editors.image") }), (selected || text(block.value.caption)) && _jsx("figcaption", { children: _jsx(Field, { name: "caption", placeholder: t("ext.blog.editors.caption") }) }), selected && _jsx("div", { className: "bl-editor-note", children: _jsx(Field, { name: "alt", placeholder: t("ext.blog.editors.alt") }) })] }));
28
+ }
29
+ function EmbedEditor({ block, selected, Field }) {
30
+ const { t } = useT();
31
+ const src = embedUrl(text(block.value.url));
32
+ return (_jsxs("figure", { className: "bl-figure", children: [src
33
+ // Inert until selected, so a click selects the block rather than playing the video.
34
+ ? _jsx("div", { className: "bl-embed", inert: !selected, children: _jsx("iframe", { src: src, title: text(block.value.caption) || t("ext.blog.editors.video"), loading: "lazy", allow: "encrypted-media; picture-in-picture; fullscreen", referrerPolicy: "strict-origin-when-cross-origin", sandbox: "allow-scripts allow-same-origin allow-presentation" }) })
35
+ : _jsxs("div", { className: "bl-editor-placeholder", children: [_jsx("p", { children: t("ext.blog.editors.pasteVideo") }), _jsx(Field, { name: "url" })] }), (selected || text(block.value.caption)) && _jsx("figcaption", { children: _jsx(Field, { name: "caption", placeholder: t("ext.blog.editors.caption") }) })] }));
36
+ }
37
+ function CodeEditor({ block, selected, Field }) {
38
+ const { t } = useT();
39
+ return (_jsxs("div", { className: "bl-code", children: [_jsx(Field, { name: "code", placeholder: t("ext.blog.editors.code") }), (selected || text(block.value.language)) && _jsx("div", { className: "bl-editor-note", children: _jsx(Field, { name: "language", placeholder: t("ext.blog.editors.language") }) })] }));
40
+ }
41
+ export const blockEditors = [
42
+ { blocks: ["blog_text"], component: TextEditor },
43
+ { blocks: ["blog_quote"], component: QuoteEditor },
44
+ { blocks: ["blog_callout"], component: CalloutEditor },
45
+ { blocks: ["blog_image"], component: ImageEditor },
46
+ { blocks: ["blog_embed"], component: EmbedEditor },
47
+ { blocks: ["blog_code"], component: CodeEditor },
48
+ ];
package/heading.d.ts ADDED
@@ -0,0 +1,11 @@
1
+ import { type ReactNode } from "react";
2
+ /** A heading at `level`, kept between h2 and h6, for the parts whose level the theme sets. No hooks, so server and client parts share it. */
3
+ export declare function Heading({ level, id, className, children }: {
4
+ level?: number;
5
+ id?: string;
6
+ className: string;
7
+ children: ReactNode;
8
+ }): import("react").DetailedReactHTMLElement<{
9
+ id: string | undefined;
10
+ className: string;
11
+ }, HTMLElement>;
package/heading.js ADDED
@@ -0,0 +1,6 @@
1
+ import { createElement } from "react";
2
+ import { headingTag } from "./text";
3
+ /** A heading at `level`, kept between h2 and h6, for the parts whose level the theme sets. No hooks, so server and client parts share it. */
4
+ export function Heading({ level, id, className, children }) {
5
+ return createElement(headingTag(level), { id, className }, children);
6
+ }
package/index.d.ts ADDED
@@ -0,0 +1,14 @@
1
+ export interface BlogOptions {
2
+ /** Where the public site lives, such as https://example.com. Feeds need absolute links. */
3
+ siteUrl: string;
4
+ /** The prefix of the addresses created on first install. After that, edit URL patterns in the dashboard. */
5
+ basePath?: string;
6
+ /** "moderated" holds new comments for review, "open" shows them straight away, and "off" refuses them. Until changed under Blog → Settings. */
7
+ comments?: "off" | "moderated" | "open";
8
+ /** Entries in each feed, until changed under Blog → Settings. */
9
+ feedItems?: number;
10
+ /** Who to email when a comment is waiting for review, until changed under Blog → Settings. */
11
+ notify?: string;
12
+ }
13
+ /** Turns the CMS into a blog: posts, categories, tags, comments, feeds, and author and editor roles. See docs/plugins/blog.md. */
14
+ export declare function blog(options: BlogOptions): import("tansy/plugin").CmsPlugin;