@tansy/theme-halo 0.1.0 → 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 +10 -0
- package/index.js +1 -1
- package/package.json +3 -3
- package/render.js +18 -18
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
What changed in each release of `@tansy/theme-halo`. 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
|
+
- Sections past the editor's picks are filled, the Recommended panel stays filled with featured
|
|
9
|
+
stories first, and wide covers are served at 1600 pixels, a thumbnail size `tansy` 0.1.1 adds.
|
|
10
|
+
- It now requires `tansy` ^0.1.1.
|
package/index.js
CHANGED
|
@@ -50,7 +50,7 @@ const archive = (filter) => ({
|
|
|
50
50
|
*/
|
|
51
51
|
export const halo = ({ tagline, showDates = true, relativeDates = true, accountLinks = true, search = true, colorScheme = "auto" } = {}) => defineTheme({
|
|
52
52
|
name: "halo",
|
|
53
|
-
version: "0.1.
|
|
53
|
+
version: "0.1.1",
|
|
54
54
|
apiVersion: 1,
|
|
55
55
|
render: "@tansy/theme-halo/render",
|
|
56
56
|
requires: { plugins: ["blog"] },
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tansy/theme-halo",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "A news front page for the blog plugin: an editor-curated lead story, recommended and trending picks, readers' choice and a popular carousel, on quiet panels.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"tansy-theme"
|
|
@@ -25,10 +25,10 @@
|
|
|
25
25
|
}
|
|
26
26
|
},
|
|
27
27
|
"peerDependencies": {
|
|
28
|
-
"@tansy/blog": "^0.1.
|
|
28
|
+
"@tansy/blog": "^0.1.1",
|
|
29
29
|
"next": "^16.4.6",
|
|
30
30
|
"react": "^19.3.0",
|
|
31
|
-
"tansy": "^0.1.
|
|
31
|
+
"tansy": "^0.1.1"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
34
|
"zod": "^4.6.7"
|
package/render.js
CHANGED
|
@@ -138,11 +138,14 @@ function Title({ story, props, as: Tag = "h3", className }) {
|
|
|
138
138
|
const href = hrefOf(story, props);
|
|
139
139
|
return _jsx(Tag, { className: className, children: href ? _jsx("a", { className: "ha-cover-link", href: href, children: text(story.title) }) : text(story.title) });
|
|
140
140
|
}
|
|
141
|
-
|
|
141
|
+
/** For a wide picture: the 1600-pixel version where the screen is dense enough to need it. */
|
|
142
|
+
const wide = (props, cover) => ({ src: props.fileUrl(cover, "800x0"), srcSet: `${props.fileUrl(cover, "800x0")} 800w, ${props.fileUrl(cover, "1600x0")} 1600w` });
|
|
143
|
+
function Picture({ story, props, size, sizes = "(min-width: 60rem) 40vw, 100vw", className, eager = false }) {
|
|
142
144
|
const cover = text(story.cover);
|
|
145
|
+
const source = size === "800x0" ? { ...wide(props, cover), sizes } : { src: props.fileUrl(cover, size) };
|
|
143
146
|
// eslint-disable-next-line @next/next/no-img-element -- an access-checked API address that redirects to a signed URL, which next/image can't optimize
|
|
144
147
|
if (cover)
|
|
145
|
-
return _jsx("img", { className: className,
|
|
148
|
+
return _jsx("img", { className: className, ...source, alt: props.fileText(cover).alt, style: { objectPosition: props.fileFocus(cover).objectPosition }, loading: eager ? "eager" : "lazy" });
|
|
146
149
|
return _jsx("span", { className: `${className} ha-blank`, "aria-hidden": "true" });
|
|
147
150
|
}
|
|
148
151
|
function ReadButton({ story, props }) {
|
|
@@ -164,11 +167,11 @@ function Rows({ stories, props }) {
|
|
|
164
167
|
}
|
|
165
168
|
/** Image, meta, title and tags. */
|
|
166
169
|
function Card({ story, props, eager = false }) {
|
|
167
|
-
return (_jsxs("article", { className: "ha-card", lang: text(story.locale) || undefined, children: [_jsx(Picture, { story: story, props: props, size: "800x0", className: "ha-card-image", eager: eager }), _jsx(Meta, { story: story, props: props }), _jsx(Title, { story: story, props: props, className: "ha-card-title" }), _jsx(Tags, { story: story, props: props })] }));
|
|
170
|
+
return (_jsxs("article", { className: "ha-card", lang: text(story.locale) || undefined, children: [_jsx(Picture, { story: story, props: props, size: "800x0", sizes: "(min-width: 60rem) 25vw, 100vw", className: "ha-card-image", eager: eager }), _jsx(Meta, { story: story, props: props }), _jsx(Title, { story: story, props: props, className: "ha-card-title" }), _jsx(Tags, { story: story, props: props })] }));
|
|
168
171
|
}
|
|
169
172
|
/** The cover with a lavender wash rising from the bottom, and the story over it in white. */
|
|
170
173
|
function Feature({ story, props, large = false }) {
|
|
171
|
-
return (_jsxs("article", { className: large ? "ha-feature ha-feature-large" : "ha-feature", lang: text(story.locale) || undefined, children: [_jsx(Picture, { story: story, props: props, size: "800x0", className: "ha-feature-image" }), _jsxs("div", { className: "ha-feature-body", children: [_jsx(Meta, { story: story, props: props }), _jsx(Title, { story: story, props: props, className: "ha-feature-title" }), large && _jsx(Tags, { story: story, props: props })] })] }));
|
|
174
|
+
return (_jsxs("article", { className: large ? "ha-feature ha-feature-large" : "ha-feature", lang: text(story.locale) || undefined, children: [_jsx(Picture, { story: story, props: props, size: "800x0", sizes: large ? "(min-width: 60rem) 50vw, 100vw" : "(min-width: 60rem) 22rem, 100vw", className: "ha-feature-image" }), _jsxs("div", { className: "ha-feature-body", children: [_jsx(Meta, { story: story, props: props }), _jsx(Title, { story: story, props: props, className: "ha-feature-title" }), large && _jsx(Tags, { story: story, props: props })] })] }));
|
|
172
175
|
}
|
|
173
176
|
/* ---------------------------------------------------------------- layout */
|
|
174
177
|
const GlobeIcon = () => (_jsx("svg", { "aria-hidden": "true", viewBox: "0 0 20 20", width: "16", height: "16", children: _jsx("path", { fill: "none", stroke: "currentColor", strokeWidth: "1.5", d: "M10 18a8 8 0 1 0 0-16 8 8 0 0 0 0 16Zm-8-8h16M10 2c2.2 2.2 3.2 5 3.2 8s-1 5.8-3.2 8c-2.2-2.2-3.2-5-3.2-8s1-5.8 3.2-8Z" }) }));
|
|
@@ -203,27 +206,23 @@ function Layout(props) {
|
|
|
203
206
|
/* ------------------------------------------------------------- front page */
|
|
204
207
|
/**
|
|
205
208
|
* Hands out stories to the front page's sections, most important first. A section an editor
|
|
206
|
-
* filled
|
|
207
|
-
* showed
|
|
208
|
-
* mostly empty.
|
|
209
|
+
* filled starts with their picks in their order. The rest of its places go to stories no
|
|
210
|
+
* earlier section showed and, where `reuse` allows, to ones that did, so a section an editor
|
|
211
|
+
* only half filled, or a young site's page, isn't left mostly empty.
|
|
209
212
|
*/
|
|
210
213
|
function allocator() {
|
|
211
214
|
const used = new Set();
|
|
212
|
-
return (picks, order, pools, count, reuse = false) => {
|
|
213
|
-
if (picks.length) {
|
|
214
|
-
const sorted = [...picks].sort((a, b) => order.indexOf(a.id) - order.indexOf(b.id)).slice(0, count);
|
|
215
|
-
for (const story of sorted)
|
|
216
|
-
used.add(story.id);
|
|
217
|
-
return sorted;
|
|
218
|
-
}
|
|
215
|
+
return (picks, order, pools, count, reuse = false, never = []) => {
|
|
219
216
|
const chosen = [];
|
|
220
|
-
const seen = new Set();
|
|
217
|
+
const seen = new Set(never.map((story) => story.id));
|
|
221
218
|
const add = (story) => {
|
|
222
219
|
if (chosen.length >= count || seen.has(story.id))
|
|
223
220
|
return;
|
|
224
221
|
seen.add(story.id);
|
|
225
222
|
chosen.push(story);
|
|
226
223
|
};
|
|
224
|
+
for (const story of [...picks].sort((a, b) => order.indexOf(a.id) - order.indexOf(b.id)))
|
|
225
|
+
add(story);
|
|
227
226
|
for (const pool of pools)
|
|
228
227
|
for (const story of pool)
|
|
229
228
|
if (!used.has(story.id))
|
|
@@ -246,7 +245,8 @@ function frontStories({ data, record }) {
|
|
|
246
245
|
const lead = take(items(data.pickLead), order("lead"), [featured, recent], 1)[0];
|
|
247
246
|
const spotlight = take(items(data.pickSpotlight), order("spotlight"), [featured, recent], 1)[0];
|
|
248
247
|
const latest = take([], [], [recent], 4);
|
|
249
|
-
|
|
248
|
+
// Beside the lead, so never empty and never the lead itself: featured stories first.
|
|
249
|
+
const recommended = take(items(data.pickRecommended), order("recommended"), [featured, recent], 5, true, lead ? [lead] : []);
|
|
250
250
|
const strip = take([], [], [featured, recent], 3);
|
|
251
251
|
const trending = take(items(data.pickTrending), order("trending"), [recent], 7, true);
|
|
252
252
|
const readers = take(items(data.pickReaders), order("readersChoice"), [featured, recent], 9, true);
|
|
@@ -333,13 +333,13 @@ const Tag = (props) => _jsx(Taxonomy, { ...props, kind: "tag" });
|
|
|
333
333
|
* through `data`, so they behave exactly as on its own page.
|
|
334
334
|
*/
|
|
335
335
|
function Post(props) {
|
|
336
|
-
const { record, data, stream,
|
|
336
|
+
const { record, data, stream, fileText, fileFocus, t, words } = props;
|
|
337
337
|
if (!record)
|
|
338
338
|
return null;
|
|
339
339
|
const side = items(data.sideStories);
|
|
340
340
|
const more = (items(data.moreStories).length ? items(data.moreStories) : side).slice(0, 4);
|
|
341
341
|
const cover = text(record.cover);
|
|
342
|
-
return (_jsxs("main", { className: "ha-page", children: [_jsxs("div", { className: "ha-post", children: [_jsxs("article", { className: "ha-panel ha-article", children: [_jsxs("header", { className: "ha-article-head", children: [_jsx(Meta, { story: record, props: props }), _jsx("h1", { className: "ha-headline ha-article-title", children: text(record.title) }), text(record.excerpt) && _jsx("p", { className: "ha-lead-text", children: text(record.excerpt) }), props.options.showDates && _jsx(PostMeta, { post: record, data: data, words: words })] }), cover && _jsx("figure", { className: "ha-article-cover", children: _jsx("img", {
|
|
342
|
+
return (_jsxs("main", { className: "ha-page", children: [_jsxs("div", { className: "ha-post", children: [_jsxs("article", { className: "ha-panel ha-article", children: [_jsxs("header", { className: "ha-article-head", children: [_jsx(Meta, { story: record, props: props }), _jsx("h1", { className: "ha-headline ha-article-title", children: text(record.title) }), text(record.excerpt) && _jsx("p", { className: "ha-lead-text", children: text(record.excerpt) }), props.options.showDates && _jsx(PostMeta, { post: record, data: data, words: words })] }), cover && _jsx("figure", { className: "ha-article-cover", children: _jsx("img", { ...wide(props, cover), sizes: "(min-width: 52rem) 52rem, 100vw", alt: fileText(cover).alt, style: { objectPosition: fileFocus(cover).objectPosition } }) }), _jsxs("div", { className: "ha-prose", children: [_jsx(StreamField, { blocks: record.body, ...stream }), _jsx(PostTags, { post: record, data: data, words: words })] }), _jsx("div", { className: "ha-comments", children: _jsx(PostComments, { post: record, data: data, words: words }) })] }), side.length > 0 && (_jsxs("aside", { className: "ha-panel ha-recommended ha-post-aside", "aria-labelledby": "ha-side", children: [_jsxs("div", { className: "ha-section-head ha-section-head-plain", children: [_jsx("h2", { id: "ha-side", className: "ha-panel-title", children: t("halo.recommended") }), blogHref(props) && _jsxs("a", { className: "ha-more", href: blogHref(props), children: [t("halo.viewAll"), _jsx(Arrow, {})] })] }), _jsx(Rows, { stories: side, props: props })] }))] }), more.length > 0 && (_jsxs("section", { className: "ha-section", "aria-labelledby": "ha-more-like", children: [_jsx(SectionHead, { id: "ha-more-like", label: t("halo.moreLikeThis"), props: props }), _jsx("ul", { className: "ha-grid ha-grid-four", children: more.map((story) => _jsx("li", { children: _jsx(Card, { story: story, props: props }) }, story.id)) })] }))] }));
|
|
343
343
|
}
|
|
344
344
|
/** Any other page, such as About. */
|
|
345
345
|
function Page({ record, stream }) {
|