@tansy/theme-blog 0.0.0-stage → 0.1.1

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,13 @@
1
+ # Changelog
2
+
3
+ What changed in each release of `@tansy/theme-blog`. Releases up to 0.1.0 went out with every other package
4
+ on one version and are described in [tansy's changelog](../../CHANGELOG.md).
5
+
6
+ ## 0.1.1 — 2026-11-22
7
+
8
+ Its post page now places the blog plugin's parts itself. From `@tansy/blog` 0.1.2 those parts
9
+ bring no outer margin or border of their own, so this release gives the space and the rule above
10
+ "More posts" and the comments in the theme's own CSS, and the post page looks as before. Use it with
11
+ `@tansy/blog` 0.1.2 or later.
12
+
13
+ Like every package, it now requires `tansy` ^0.1.1.
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/theme-blog
4
+
5
+ A blog look for tansy: a header with a menu, posts on the home page, post pages and plain pages.
6
+
7
+ ```bash
8
+ npm install @tansy/theme-blog
9
+ ```
10
+
11
+ Add it to `tansy.config.ts`. See [the themes guide](https://github.com/mhmdsalahsebai/tansy/blob/main/docs/guides/themes.md) for what it adds and the options it takes.
12
+
13
+ A first-party theme for [tansy](https://github.com/mhmdsalahsebai/tansy), a self-hosted, runtime-schema CMS for Next.js. MIT licensed.
Binary file
@@ -0,0 +1 @@
1
+ Geist by Vercel and basement.studio, under the SIL Open Font License 1.1: https://github.com/vercel/geist-font
package/index.d.ts ADDED
@@ -0,0 +1,10 @@
1
+ export interface BlogOptions {
2
+ /** Shown under the site's name. */
3
+ tagline?: string;
4
+ showDates: boolean;
5
+ }
6
+ /** The look of a blog: a header with a menu, a home page listing posts, its own post page, and plain pages. Archives come from the blog plugin, which this theme requires, and the post page is built from its parts. */
7
+ export declare const blog: ({ tagline, showDates }?: {
8
+ tagline?: string;
9
+ showDates?: boolean;
10
+ }) => import("tansy/theme").ThemeManifest<BlogOptions>;
package/index.js ADDED
@@ -0,0 +1,23 @@
1
+ import { defineTheme } from "tansy/theme";
2
+ import { z } from "zod";
3
+ import schema from "./schema.json";
4
+ const options = z.object({ tagline: z.string().max(200).optional(), showDates: z.boolean() });
5
+ /** The look of a blog: a header with a menu, a home page listing posts, its own post page, and plain pages. Archives come from the blog plugin, which this theme requires, and the post page is built from its parts. */
6
+ export const blog = ({ tagline, showDates = true } = {}) => defineTheme({
7
+ name: "blog",
8
+ version: "0.1.1",
9
+ apiVersion: 1,
10
+ render: "@tansy/theme-blog/render",
11
+ requires: { plugins: ["blog"] },
12
+ options: { schema: options, value: { tagline, showDates } },
13
+ schema,
14
+ tokens: {
15
+ color: { page: "#fbfaf7", text: "#23262b", muted: "#676c75", border: "#e4e1d9", accent: "#2f6f5e", "on-accent": "#ffffff" },
16
+ font: { body: 'var(--blog-font), system-ui, sans-serif' },
17
+ size: { measure: "42rem" },
18
+ space: { gap: "1.5rem", section: "3.5rem" },
19
+ radius: { card: "0.5rem" },
20
+ },
21
+ singletons: ["site-menu"],
22
+ queries: { home: { posts: { collection: "blog-posts", sort: "-publishedAt", perPage: 20, paged: true, fields: "id,title,excerpt,publishedAt", urls: "1" } } },
23
+ });
package/package.json CHANGED
@@ -1,6 +1,39 @@
1
1
  {
2
2
  "name": "@tansy/theme-blog",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.1.1",
4
+ "description": "A blog look for tansy: a header with a menu, posts on the home page, post pages and plain pages.",
5
+ "keywords": [
6
+ "tansy",
7
+ "tansy-theme",
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": "themes/blog"
18
+ },
19
+ "bugs": "https://github.com/mhmdsalahsebai/tansy/issues",
20
+ "exports": {
21
+ ".": {
22
+ "types": "./index.d.ts",
23
+ "default": "./index.js"
24
+ },
25
+ "./render": {
26
+ "types": "./render.d.ts",
27
+ "default": "./render.js"
28
+ }
29
+ },
30
+ "peerDependencies": {
31
+ "@tansy/blog": "^0.1.1",
32
+ "next": "^16.4.6",
33
+ "react": "^19.3.0",
34
+ "tansy": "^0.1.1"
35
+ },
36
+ "dependencies": {
37
+ "zod": "^4.6.7"
38
+ }
39
+ }
package/render.d.ts ADDED
@@ -0,0 +1,4 @@
1
+ import type { BlogOptions } from "./index";
2
+ import "./theme.css";
3
+ declare const _default: import("tansy/theme").ThemeComponents<BlogOptions>;
4
+ export default _default;
package/render.js ADDED
@@ -0,0 +1,80 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import localFont from "next/font/local";
3
+ import Link from "next/link";
4
+ import { MorePosts, PostCategories, PostComments, PostMeta, PostTags } from "@tansy/blog/render";
5
+ import { Menu, Pager, RichText, StreamField } from "tansy/react";
6
+ import { defineThemeComponents } from "tansy/theme";
7
+ import "./theme.css";
8
+ // Served from the site's own origin, as font-src 'self' requires.
9
+ const font = localFont({ src: "./fonts/GeistVF.woff", variable: "--blog-font", weight: "100 900" });
10
+ const text = (value) => (typeof value === "string" ? value : "");
11
+ /** The theme's words. Owners can change any of them per language under Languages → Site text. */
12
+ const messages = {
13
+ en: {
14
+ noPosts: "No posts yet.",
15
+ newerPosts: "Newer posts",
16
+ olderPosts: "Older posts",
17
+ keepReading: "Keep reading",
18
+ language: "Language",
19
+ menu: "Main",
20
+ },
21
+ ar: {
22
+ noPosts: "لا توجد مقالات بعد.",
23
+ newerPosts: "مقالات أحدث",
24
+ olderPosts: "مقالات أقدم",
25
+ keepReading: "تابع القراءة",
26
+ language: "اللغة",
27
+ menu: "القائمة الرئيسية",
28
+ },
29
+ };
30
+ /** An address in the page's language: "/blog" is "/ar/blog" on an Arabic page. */
31
+ const inLanguage = (props, path) => props.language?.href(path) ?? path;
32
+ function PublishedOn({ value, show, formatDate }) {
33
+ const date = text(value);
34
+ if (!show || !date)
35
+ return null;
36
+ return _jsx("time", { className: "blog-meta", dateTime: date, children: formatDate(date, "long") });
37
+ }
38
+ /** The same page in each language it's published in. */
39
+ function LanguageSwitcher({ language, t }) {
40
+ if (!language)
41
+ return null;
42
+ return (_jsx("nav", { className: "blog-languages", "aria-label": t("language"), children: language.locales.filter((locale) => language.alternates[locale.code]).map((locale) => (_jsx("a", { href: language.alternates[locale.code], hrefLang: locale.code, lang: locale.code, "aria-current": locale.code === language.locale ? "true" : undefined, children: locale.label }, locale.code))) }));
43
+ }
44
+ function Layout({ branding, globals, options, children, language, t }) {
45
+ return (_jsxs("div", { className: "blog-shell", children: [_jsxs("header", { className: "blog-header", children: [_jsxs("div", { children: [_jsx(Link, { className: "blog-brand", href: inLanguage({ language }, "/"), prefetch: false, children: branding.name }), options.tagline && _jsx("p", { className: "blog-tagline", children: options.tagline })] }), _jsx("nav", { className: "blog-nav", "aria-label": t("menu"), children: _jsx(Menu, { items: globals["site-menu"]?.items }) }), _jsx(LanguageSwitcher, { language: language, t: t })] }), children, _jsx("footer", { className: "blog-footer", children: branding.name })] }));
46
+ }
47
+ /** From the posts collection's URL pattern, so it follows whatever the owner sets, in the page's language. */
48
+ const postHref = (post, props) => (text(post.recordPath) ? inLanguage(props, text(post.recordPath)) : undefined);
49
+ function Home(props) {
50
+ const { data, options, path, t, formatDate, words } = props;
51
+ const posts = data.posts?.items ?? [];
52
+ return (_jsxs("main", { className: "blog-main", children: [posts.length === 0 && _jsx("p", { children: t("noPosts") }), _jsx("ul", { className: "blog-post-list", children: posts.map((post) => (_jsxs("li", { lang: typeof post.locale === "string" ? post.locale : undefined, children: [_jsx("h2", { children: postHref(post, props) ? _jsx(Link, { href: postHref(post, props), prefetch: false, children: text(post.title) }) : text(post.title) }), _jsx(PublishedOn, { value: post.publishedAt, show: options.showDates, formatDate: formatDate }), text(post.excerpt) && _jsx("p", { children: text(post.excerpt) })] }, post.id))) }), _jsx(Pager, { list: data.posts, path: path, previous: t("newerPosts"), next: t("olderPosts"), className: "blog-pager", words: words })] }));
53
+ }
54
+ /**
55
+ * The theme's own post page, built from the blog plugin's parts. It gets the plugin's lists
56
+ * as `data`, so the parts that link categories and tags, suggest posts and take comments
57
+ * work here as they do on the plugin's page.
58
+ */
59
+ function Post({ record, data, stream, options, fileUrl, fileText, t, words }) {
60
+ if (!record)
61
+ return null;
62
+ return (_jsxs("main", { className: "blog-main", children: [_jsxs("article", { children: [_jsx(PostCategories, { post: record, data: data, words: words }), _jsx("h1", { children: text(record.title) }), options.showDates && _jsx(PostMeta, { post: record, data: data, words: words }), text(record.cover) && _jsx("img", { className: "blog-cover", src: fileUrl(text(record.cover), "800x0"), alt: fileText(text(record.cover)).alt }), _jsx("div", { className: "blog-body", children: _jsx(StreamField, { blocks: record.body, ...stream }) }), _jsx(PostTags, { post: record, data: data, words: words })] }), _jsx(MorePosts, { post: record, data: data, words: words, heading: t("keepReading") }), _jsx(PostComments, { post: record, data: data, words: words })] }));
63
+ }
64
+ function Page({ record, stream }) {
65
+ if (!record)
66
+ return null;
67
+ return (_jsxs("main", { className: "blog-main", children: [_jsx("h1", { children: text(record.title) }), _jsx("div", { className: "blog-body", children: _jsx(StreamField, { blocks: record.body, ...stream }) })] }));
68
+ }
69
+ const TextBlock = ({ value }) => _jsx(RichText, { doc: value.body });
70
+ function Quote({ value }) {
71
+ return (_jsxs("blockquote", { className: "blog-quote", children: [_jsx("p", { children: text(value.text) }), text(value.source) && _jsx("cite", { children: text(value.source) })] }));
72
+ }
73
+ export default defineThemeComponents({
74
+ blocks: { blog_text: TextBlock, blog_quote: Quote },
75
+ // Archives and the blog's front page use the blog plugin's templates, inside this layout.
76
+ templates: { home: Home, "blog-posts": Post, default: Page },
77
+ layouts: { default: Layout },
78
+ fontClassName: font.variable,
79
+ messages,
80
+ });
package/schema.json ADDED
@@ -0,0 +1,31 @@
1
+ {
2
+ "version": 1,
3
+ "collections": [
4
+ {
5
+ "slug": "site-menu",
6
+ "name": "Menu",
7
+ "description": "Links shown at the top of every page.",
8
+ "type": "singleton",
9
+ "urlPattern": null,
10
+ "rules": {
11
+ "listRule": "",
12
+ "viewRule": "",
13
+ "createRule": null,
14
+ "updateRule": null,
15
+ "deleteRule": null
16
+ },
17
+ "fields": [
18
+ {
19
+ "name": "items",
20
+ "type": "stream",
21
+ "config": {
22
+ "allowedBlocks": [
23
+ "menu_item"
24
+ ]
25
+ }
26
+ }
27
+ ]
28
+ }
29
+ ],
30
+ "blocks": []
31
+ }
package/theme.css ADDED
@@ -0,0 +1,151 @@
1
+ .site-root {
2
+ min-height: 100vh;
3
+ background: var(--site-color-page);
4
+ color: var(--site-color-text);
5
+ font-family: var(--site-font-body);
6
+ line-height: 1.65;
7
+ }
8
+
9
+ .blog-shell {
10
+ max-width: var(--site-size-measure);
11
+ margin-inline: auto;
12
+ padding: var(--site-space-gap);
13
+ }
14
+
15
+ .blog-header {
16
+ display: flex;
17
+ flex-wrap: wrap;
18
+ gap: var(--site-space-gap);
19
+ align-items: baseline;
20
+ justify-content: space-between;
21
+ padding-block-end: var(--site-space-gap);
22
+ border-block-end: 1px solid var(--site-color-border);
23
+ }
24
+
25
+ .blog-brand {
26
+ color: inherit;
27
+ font-size: 1.25rem;
28
+ font-weight: 650;
29
+ text-decoration: none;
30
+ }
31
+
32
+ .blog-tagline,
33
+ .blog-meta,
34
+ .blog-quote cite,
35
+ .blog-footer {
36
+ color: var(--site-color-muted);
37
+ font-size: 0.9rem;
38
+ }
39
+
40
+ .blog-tagline { margin: 0; }
41
+
42
+ .blog-nav ul {
43
+ display: flex;
44
+ flex-wrap: wrap;
45
+ gap: 1rem;
46
+ padding: 0;
47
+ margin: 0;
48
+ list-style: none;
49
+ }
50
+
51
+ .site-root a { color: var(--site-color-accent); }
52
+
53
+ .blog-main { padding-block: var(--site-space-section); }
54
+
55
+ .blog-main h1 {
56
+ margin-block: 0 0.5rem;
57
+ font-size: clamp(1.9rem, 5vw, 2.6rem);
58
+ line-height: 1.15;
59
+ letter-spacing: -0.02em;
60
+ }
61
+
62
+ .blog-post-list {
63
+ display: grid;
64
+ gap: var(--site-space-section);
65
+ padding: 0;
66
+ margin: 0;
67
+ list-style: none;
68
+ }
69
+
70
+ .blog-post-list h2 {
71
+ margin-block: 0 0.25rem;
72
+ font-size: 1.4rem;
73
+ line-height: 1.25;
74
+ }
75
+
76
+ .blog-post-list p { margin: 0; }
77
+
78
+ .blog-body { margin-block-start: var(--site-space-gap); }
79
+
80
+ .blog-cover {
81
+ width: 100%;
82
+ height: auto;
83
+ margin-block-start: var(--site-space-gap);
84
+ border-radius: var(--site-radius-card);
85
+ }
86
+
87
+ .blog-pager {
88
+ display: flex;
89
+ align-items: center;
90
+ justify-content: space-between;
91
+ gap: 1rem;
92
+ margin-block-start: var(--site-space-section);
93
+ color: var(--site-color-muted);
94
+ font-size: 0.9rem;
95
+ }
96
+
97
+ .blog-quote {
98
+ padding-inline-start: 1rem;
99
+ margin: var(--site-space-gap) 0;
100
+ border-inline-start: 3px solid var(--site-color-accent);
101
+ }
102
+
103
+ .blog-quote p {
104
+ margin: 0;
105
+ font-size: 1.15rem;
106
+ }
107
+
108
+ .blog-footer {
109
+ padding-block-start: var(--site-space-gap);
110
+ border-block-start: 1px solid var(--site-color-border);
111
+ }
112
+
113
+ [data-preview-notice] {
114
+ padding: 0.5rem 1rem;
115
+ margin: 0;
116
+ background: var(--site-color-accent);
117
+ color: var(--site-color-on-accent);
118
+ text-align: center;
119
+ }
120
+
121
+ [data-preview-notice] a { color: inherit; }
122
+
123
+ [data-missing-block] {
124
+ padding: 0.75rem 1rem;
125
+ border: 1px dashed var(--site-color-border);
126
+ border-radius: var(--site-radius-card);
127
+ color: var(--site-color-muted);
128
+ }
129
+
130
+ .blog-languages {
131
+ display: flex;
132
+ gap: 0.75rem;
133
+ font-size: 0.875rem;
134
+ }
135
+
136
+ .blog-languages a[aria-current="true"] {
137
+ font-weight: 600;
138
+ text-decoration: none;
139
+ }
140
+
141
+ /* Where the blog plugin's parts sit on the theme's post page: the parts bring no outer spacing of their own. */
142
+ :where(.blog-main) .bl-meta { margin-block-end: 1rem; }
143
+ :where(.blog-main) .bl-kicker { margin-block-end: 0.5rem; }
144
+ :where(.blog-main) .bl-list,
145
+ :where(.blog-main) .bl-tags { margin-block-start: 2rem; }
146
+ :where(.blog-main) > .bl-more,
147
+ :where(.blog-main) > .bl-comments {
148
+ margin-block-start: var(--site-space-section);
149
+ padding-block-start: 1.5rem;
150
+ border-block-start: 1px solid var(--site-color-border);
151
+ }