@cloudhal/astro-renderer 0.5.0 → 0.6.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.
@@ -0,0 +1,318 @@
1
+
2
+
3
+
4
+
5
+
6
+
7
+
8
+
9
+
10
+
11
+
12
+ import { searchDocuments, searchRows } from "@cloudhal/core-ts";
13
+ import { isAvailable, nextInstant } from "@cloudhal/core-ts/availability";
14
+ import { derivedGates, hasExpiryRules } from "@cloudhal/core-ts/fields";
15
+ import { matches } from "@cloudhal/core-ts/filter";
16
+ import {
17
+ evaluateEntryQuery,
18
+
19
+
20
+ rememberList,
21
+ } from "./entry-query.js";
22
+ import { gateIndex, splitEntries } from "./entry-views.js";
23
+ import { entryFields, } from "./fields.js";
24
+ import { navigationFor } from "./navigation.js";
25
+
26
+ import { byNewest, byPosition, compile, shown, termFilter, visible } from "./source-helpers.js";
27
+
28
+ /**
29
+ * Reads the current nodes on every call. Drafts are included so authors can preview them in dev,
30
+ * and so are gated nodes (a preview shows embargoed and expired content, RFC-0008 §7.3). Without
31
+ * drafts it serves what the public would see: published nodes whose gates are open at `now`.
32
+ */
33
+ export class LiveSource {
34
+ mode = "live";
35
+ #store ;
36
+ #siteId ;
37
+ #includeDrafts ;
38
+ #now ;
39
+
40
+ constructor(
41
+ store ,
42
+ siteId ,
43
+ options = {},
44
+ ) {
45
+ this.#store = store;
46
+ this.#siteId = siteId;
47
+ this.#includeDrafts = options.includeDrafts ?? true;
48
+ this.#now = options.now ?? Date.now;
49
+ }
50
+
51
+ /** Drafts and gated nodes, or what the public sees now. */
52
+ #visible (nodes ) {
53
+ if (this.#includeDrafts) return visible(nodes, true);
54
+ const now = this.#now();
55
+ return nodes.filter((n) => isAvailable(n, now));
56
+ }
57
+
58
+ /**
59
+ * Entries as the public sees them now, derived gates included (RFC-0042 §3): `listed` for lists,
60
+ * `reachable` for routes. With drafts both are everything not archived (previews ignore gates).
61
+ */
62
+ async #split(
63
+ entries ,
64
+ /** Every entry of the site, when the caller already read them (the pool for originals). */
65
+ all ,
66
+ ) {
67
+ if (this.#includeDrafts) {
68
+ const all = visible(entries, true);
69
+ return { listed: all, reachable: all, published: all };
70
+ }
71
+ const site = await this.site();
72
+ const isPublished = (e ) => e.status === "published";
73
+ // Translations read their original's date, which may sit in another locale or collection.
74
+ const pool = !hasExpiryRules(site)
75
+ ? entries
76
+ : (all ?? (await this.#store.listContentEntries(this.#siteId)));
77
+ const published = pool.filter(isPublished);
78
+ const derived = derivedGates(site, published);
79
+ return { ...splitEntries(entries.filter(isPublished), this.#now(), derived), published };
80
+ }
81
+
82
+ async nextGate() {
83
+ if (this.#includeDrafts) return undefined;
84
+ const [site, pages, entries] = await Promise.all([
85
+ this.site(),
86
+ this.#store.listPages(this.#siteId),
87
+ this.#store.listContentEntries(this.#siteId),
88
+ ]);
89
+ const isPublished = (n ) => n.status === "published";
90
+ const gates = gateIndex(site, pages.filter(isPublished), entries.filter(isPublished));
91
+ return nextInstant(gates, this.#now());
92
+ }
93
+
94
+ async site() {
95
+ const site = await this.#store.getSite(this.#siteId);
96
+ if (!site) throw new Error(`site ${this.#siteId} not found`);
97
+ return site;
98
+ }
99
+
100
+ async pages() {
101
+ const site = await this.site();
102
+ const pages = this.#visible(await this.#store.listPages(this.#siteId));
103
+ const order = new Map(site.pageIds.map((id, i) => [id, i]));
104
+ return pages.sort((a, b) => (order.get(a.id) ?? 1e9) - (order.get(b.id) ?? 1e9));
105
+ }
106
+
107
+ async pageByPath(path , locale ) {
108
+ const loc = locale ?? (await this.site()).defaultLocale;
109
+ return (await this.pages()).find((p) => p.path === path && p.locale === loc);
110
+ }
111
+
112
+ async entries(collection , locale ) {
113
+ const loc = locale ?? (await this.site()).defaultLocale;
114
+ const { listed } = await this.#split(
115
+ await this.#store.listContentEntries(this.#siteId, collection),
116
+ );
117
+ const out = listed.filter((e) => e.locale === loc).sort(byNewest);
118
+ return rememberList(out, { source: this, locale: loc });
119
+ }
120
+
121
+ async entryBySlug(
122
+ collection ,
123
+ slug ,
124
+ locale ,
125
+ ) {
126
+ const loc = locale ?? (await this.site()).defaultLocale;
127
+ const { reachable } = await this.#split(
128
+ await this.#store.listContentEntries(this.#siteId, collection),
129
+ );
130
+ return reachable.find((e) => e.slug === slug && e.locale === loc);
131
+ }
132
+
133
+ async allEntries(locale ) {
134
+ const loc = locale ?? (await this.site()).defaultLocale;
135
+ const all = await this.#store.listContentEntries(this.#siteId);
136
+ const { listed } = await this.#split(all, all);
137
+ return listed.filter((e) => e.locale === loc).sort(byNewest);
138
+ }
139
+
140
+ /** Every entry of a locale with a public URL, unlisted ones included (RFC-0042 §3). */
141
+ async routableEntries(locale ) {
142
+ const loc = locale ?? (await this.site()).defaultLocale;
143
+ const all = await this.#store.listContentEntries(this.#siteId);
144
+ const { reachable } = await this.#split(all, all);
145
+ return reachable.filter((e) => e.locale === loc).sort(byNewest);
146
+ }
147
+
148
+ /** RFC-0042 §4: a collection by its list fields (`queryEntries`). */
149
+ async queryEntries(q ) {
150
+ const site = await this.site();
151
+ const loc = q.locale ?? site.defaultLocale;
152
+ // With expiry rules every entry is read once (originals may sit elsewhere); else the collection.
153
+ const all = hasExpiryRules(site)
154
+ ? await this.#store.listContentEntries(this.#siteId)
155
+ : undefined;
156
+ const mine = all
157
+ ? all.filter((e) => e.collection === q.collection)
158
+ : await this.#store.listContentEntries(this.#siteId, q.collection);
159
+ const [split, taxonomies, terms] = await Promise.all([
160
+ this.#split(mine, all),
161
+ this.#store.listTaxonomies(this.#siteId),
162
+ this.#store.listTerms(this.#siteId),
163
+ ]);
164
+ const shownHere = q.includeExpired ? split.reachable : split.listed;
165
+ return evaluateEntryQuery({
166
+ site,
167
+ candidates: shownHere.filter((e) => e.locale === loc),
168
+ published: split.published,
169
+ taxonomies,
170
+ terms,
171
+ query: q,
172
+ now: this.#now(),
173
+ });
174
+ }
175
+
176
+ async search(query , options = {}) {
177
+ const site = await this.site();
178
+ const locale = options.locale ?? site.defaultLocale;
179
+ // What this source shows decided visibility and gates already (drafts included).
180
+ const [entries, pages, taxonomies, terms] = await Promise.all([
181
+ this.allEntries(locale),
182
+ this.pages(),
183
+ this.taxonomies(),
184
+ this.vocabulary(),
185
+ ]);
186
+ const rows = searchDocuments({
187
+ locales: [locale],
188
+ defaultLocale: site.defaultLocale,
189
+ site,
190
+ entries,
191
+ pages: pages.filter((p) => p.locale === locale),
192
+ taxonomies,
193
+ terms,
194
+ drafts: true,
195
+ }).map((r) => ({ ...r, gateFrom: undefined, gateUntil: undefined }));
196
+ return searchRows(rows, query, { ...options, locale, now: this.#now() });
197
+ }
198
+
199
+ async entryById(id ) {
200
+ const entry = await this.#store.getContentEntry(id);
201
+ if (!entry || entry.siteId !== this.#siteId) return undefined;
202
+ return (await this.#split([entry])).reachable.length > 0 ? entry : undefined;
203
+ }
204
+
205
+ entryFields(entry , options ) {
206
+ return entryFields(this, entry, options);
207
+ }
208
+
209
+ taxonomies() {
210
+ return this.#store.listTaxonomies(this.#siteId);
211
+ }
212
+
213
+ async terms(key ) {
214
+ const loc = (await this.site()).defaultLocale;
215
+ return (await this.#store.listTerms(this.#siteId, { taxonomy: key }))
216
+ .filter((t) => shown(t, this.#includeDrafts))
217
+ .sort(byPosition(loc));
218
+ }
219
+
220
+ async termBySlug(key , slug ) {
221
+ return (await this.terms(key)).find((t) => t.slug === slug);
222
+ }
223
+
224
+ vocabulary(key ) {
225
+ return this.#store.listTerms(this.#siteId, key === undefined ? {} : { taxonomy: key });
226
+ }
227
+
228
+ async entriesByFilter(
229
+ filter ,
230
+ options = {},
231
+ ) {
232
+ const loc = options.locale ?? (await this.site()).defaultLocale;
233
+ const [taxonomies, terms, entries] = await Promise.all([
234
+ this.#store.listTaxonomies(this.#siteId),
235
+ this.#store.listTerms(this.#siteId),
236
+ this.#store.listContentEntries(this.#siteId, { locale: loc }),
237
+ ]);
238
+ const f = compile(filter, taxonomies, terms);
239
+ const out = (await this.#split(entries)).listed.filter((e) => matches(f, e)).sort(byNewest);
240
+ return rememberList(options.limit === undefined ? out : out.slice(0, options.limit), {
241
+ source: this,
242
+ locale: loc,
243
+ });
244
+ }
245
+
246
+ entriesByTerm(
247
+ key ,
248
+ slug ,
249
+ options = {},
250
+ ) {
251
+ return this.entriesByFilter(termFilter(key, slug, options.descendants === true), options);
252
+ }
253
+
254
+ redirectFor(path , locale ) {
255
+ return this.#store.redirectFor(this.#siteId, path, locale);
256
+ }
257
+
258
+ redirects() {
259
+ return this.#store.listRedirects(this.#siteId);
260
+ }
261
+
262
+ menu(key ) {
263
+ return this.#store.getMenuByKey(this.#siteId, key);
264
+ }
265
+
266
+ async navigation(
267
+ key ,
268
+ locale ,
269
+ options = {},
270
+ ) {
271
+ const menu = await this.menu(key);
272
+ if (!menu) return undefined;
273
+ const site = await this.site();
274
+ const [pages, entries, taxonomies, terms] = await Promise.all([
275
+ this.#store.listPages(this.#siteId),
276
+ this.#store.listContentEntries(this.#siteId),
277
+ this.#store.listTaxonomies(this.#siteId),
278
+ this.#store.listTerms(this.#siteId),
279
+ ]);
280
+ return navigationFor(
281
+ menu,
282
+ {
283
+ site,
284
+ // drafts: everything but archived (the lookup decides); public: what is available now
285
+ pages: this.#includeDrafts ? pages : this.#visible(pages),
286
+ entries: this.#includeDrafts ? entries : (await this.#split(entries, entries)).reachable,
287
+ taxonomies,
288
+ terms,
289
+ includeDrafts: this.#includeDrafts,
290
+ ...(options.collectionIndex ? { collectionIndex: options.collectionIndex } : {}),
291
+ },
292
+ locale ?? site.defaultLocale,
293
+ );
294
+ }
295
+
296
+ async assets() {
297
+ const out = [];
298
+ let cursor ;
299
+ do {
300
+ const page = await this.#store.listAssets(this.#siteId, {
301
+ limit: 200,
302
+ ...(cursor ? { cursor } : {}),
303
+ });
304
+ out.push(...page.assets);
305
+ cursor = page.nextCursor;
306
+ } while (cursor);
307
+ return out;
308
+ }
309
+
310
+ async asset(id ) {
311
+ const a = await this.#store.getAsset(id);
312
+ return a?.siteId === this.#siteId ? a : undefined;
313
+ }
314
+
315
+ assetByPrefix(prefix16 ) {
316
+ return this.#store.getAssetByPrefix(this.#siteId, prefix16);
317
+ }
318
+ }
@@ -9,6 +9,7 @@
9
9
 
10
10
  import { entryPath, termSlug } from "@cloudhal/core-ts";
11
11
  import { localeRouting, localeUrl, localizedPath } from "@cloudhal/core-ts/locale-paths";
12
+ import { routableEntries } from "./entry-views.js";
12
13
 
13
14
 
14
15
 
@@ -110,7 +111,7 @@ async function groupMembers(
110
111
  ) {
111
112
  const inGroup = (n ) => n.id === group || n.translation?.group === group;
112
113
  if (pages) return (await source.pages()).filter(inGroup);
113
- const all = await Promise.all(site.locales.map((l) => source.allEntries(l)));
114
+ const all = await Promise.all(site.locales.map((l) => routableEntries(source, l)));
114
115
  return all.flat().filter(inGroup);
115
116
  }
116
117
 
@@ -195,8 +196,8 @@ export async function linkLocalizer(
195
196
  const home = (p ) => (own ? localeUrl(site, def, p, origin) : localizedPath(site, def, p));
196
197
  const [pages, entries, translated, taxonomies, terms] = await Promise.all([
197
198
  source.pages(),
198
- source.allEntries(def),
199
- source.allEntries(locale),
199
+ routableEntries(source, def),
200
+ routableEntries(source, locale),
200
201
  source.taxonomies(),
201
202
  source.vocabulary(),
202
203
  ]);
@@ -8,7 +8,17 @@ export declare function previewCollections(sections: readonly Section[]): string
8
8
  * (`.ch-*` classes, `data-section-id`), so agents can preview a change without a build and the
9
9
  * markup matches what the site will render.
10
10
  */
11
- export declare function renderSectionHtml(section: Section, entries?: Record<string, ContentEntry[]>, media?: MediaContext): string;
11
+ /**
12
+ * What a preview needs to list a `contentList` section by field (RFC-0042 §4): the site (field
13
+ * definitions, list fields, time zone) and the instant `now` compares with (default: the clock).
14
+ */
15
+ export interface PreviewListing {
16
+ readonly site: Site;
17
+ readonly now?: number | undefined;
18
+ }
19
+ export declare function renderSectionHtml(section: Section, entries?: Record<string, ContentEntry[]>, media?: MediaContext,
20
+ /** RFC-0042: lets a `contentList` with `where`/`orderBy` list as the site does. */
21
+ listing?: PreviewListing): string;
12
22
  export interface PreviewDocument {
13
23
  html: string;
14
24
  title: string;
@@ -19,6 +29,11 @@ export interface PreviewDocument {
19
29
  * expired, RFC-0008 §7.3); empty when its gates are open.
20
30
  */
21
31
  export declare function gateNoticeHtml(site: Site, node: Pick<Page, "availability">, now: number, locale?: string): string;
32
+ /**
33
+ * The notice for an entry past its collection's expiry at `now` (RFC-0042 §3.3): "Ended on …"
34
+ * for `unlist`, "Expired on …" for `hide`; empty before it, or when its own gates already speak.
35
+ */
36
+ export declare function derivedGateNoticeHtml(site: Site, entry: ContentEntry, now: number, locale?: string): string;
22
37
  /**
23
38
  * Full HTML document for a page preview. `now` (default: the caller's clock) decides whether the
24
39
  * page's gates are closed, which adds a notice.
@@ -1,5 +1,6 @@
1
1
 
2
2
 
3
+
3
4
 
4
5
 
5
6
 
@@ -8,6 +9,7 @@
8
9
 
9
10
 
10
11
  import { entryPath } from "@cloudhal/core-ts";
12
+ import { derivedGate } from "@cloudhal/core-ts/fields";
11
13
  import {
12
14
 
13
15
 
@@ -17,7 +19,8 @@ import {
17
19
  viewPagePath,
18
20
  } from "./archive.js";
19
21
  import { renderComponentSection } from "./blocks.js";
20
- import { gateNotice } from "./gates.js";
22
+ import { evaluateEntryQuery, listsByField, sectionQuery } from "./entry-query.js";
23
+ import { formatGateTime, gateNotice } from "./gates.js";
21
24
  import { renderBody, renderEntryArticle, renderMarkdown, safeHref, safeSrc } from "./markdown.js";
22
25
  import { assetCaption, imageAttributes, imgHtml, } from "./media.js";
23
26
  import { archiveHead, siteOrigin } from "./seo.js";
@@ -82,10 +85,55 @@ export function previewCollections(sections ) {
82
85
  * (`.ch-*` classes, `data-section-id`), so agents can preview a change without a build and the
83
86
  * markup matches what the site will render.
84
87
  */
88
+ /**
89
+ * What a preview needs to list a `contentList` section by field (RFC-0042 §4): the site (field
90
+ * definitions, list fields, time zone) and the instant `now` compares with (default: the clock).
91
+ */
92
+
93
+
94
+
95
+
96
+
97
+ /**
98
+ * A `contentList` section's entries in a preview: with `where`/`orderBy` (and `listing`), through
99
+ * the live renderer's evaluator (`evaluateEntryQuery`); otherwise the collection by the section's
100
+ * `sort`. A term `filter` is applied on the site only; a preview ignores it.
101
+ */
102
+ function previewList(
103
+ section ,
104
+ entries ,
105
+ listing ,
106
+ ) {
107
+ const all = entries[section.collection] ?? [];
108
+ if (listing && listsByField(section)) {
109
+ const { filter: _ignored, ...query } = sectionQuery(section);
110
+ return evaluateEntryQuery({
111
+ site: listing.site,
112
+ candidates: all,
113
+ published: all,
114
+ taxonomies: [],
115
+ terms: [],
116
+ query,
117
+ now: listing.now ?? Date.now(),
118
+ }).entries;
119
+ }
120
+ return [...all]
121
+ .sort((a, b) =>
122
+ section.sort === "title"
123
+ ? a.title.localeCompare(b.title)
124
+ : section.sort === "oldest"
125
+ ? (a.publishedAt ?? a.createdAt).localeCompare(b.publishedAt ?? b.createdAt)
126
+ : (b.publishedAt ?? b.createdAt).localeCompare(a.publishedAt ?? a.createdAt),
127
+ )
128
+ .slice(0, section.limit);
129
+ }
130
+
85
131
  export function renderSectionHtml(
86
132
  section ,
87
133
  entries = {},
88
134
  media ,
135
+ /** RFC-0042: lets a `contentList` with `where`/`orderBy` list as the site does. */
136
+ listing ,
89
137
  ) {
90
138
  switch (section.kind) {
91
139
  case "hero":
@@ -114,15 +162,7 @@ export function renderSectionHtml(
114
162
  }</figure>`;
115
163
  }
116
164
  case "contentList": {
117
- const list = [...(entries[section.collection] ?? [])]
118
- .sort((a, b) =>
119
- section.sort === "title"
120
- ? a.title.localeCompare(b.title)
121
- : section.sort === "oldest"
122
- ? (a.publishedAt ?? a.createdAt).localeCompare(b.publishedAt ?? b.createdAt)
123
- : (b.publishedAt ?? b.createdAt).localeCompare(a.publishedAt ?? a.createdAt),
124
- )
125
- .slice(0, section.limit);
165
+ const list = previewList(section, entries, listing);
126
166
  const items = list
127
167
  .map(
128
168
  (e) =>
@@ -161,16 +201,25 @@ export function renderSectionHtml(
161
201
  /** Words of the preview's gate notice (RFC-0008 §7.3), as the blog starter says them. */
162
202
  const GATE_WORDS
163
203
 
164
-
204
+
205
+
206
+
207
+  
208
+
209
+
165
210
  = {
166
211
  en: {
167
212
  embargoed: (when) => `Embargoed until ${when}. Only previews show it until then.`,
168
213
  expired: (when) => `Expired on ${when}. Only previews show it now.`,
214
+ ended: (when) =>
215
+ `Ended on ${when} (collection rule). It keeps its address but is left out of lists, feeds and search.`,
169
216
  },
170
217
  tr: {
171
218
  embargoed: (when) =>
172
219
  `${when} tarihine kadar ambargolu. O zamana kadar yalnızca önizlemede görünür.`,
173
220
  expired: (when) => `${when} tarihinde yayından kalktı. Artık yalnızca önizlemede görünür.`,
221
+ ended: (when) =>
222
+ `${when} tarihinde sona erdi (koleksiyon kuralı). Adresi kalır, ama listelerde, akışlarda ve aramada yer almaz.`,
174
223
  },
175
224
  };
176
225
 
@@ -186,10 +235,36 @@ export function gateNoticeHtml(
186
235
  ) {
187
236
  const notice = gateNotice(node, site, locale, now);
188
237
  if (!notice) return "";
238
+ return noticeHtml(notice.state, notice.at, notice.when, locale);
239
+ }
240
+
241
+ function noticeHtml(
242
+ state ,
243
+ at ,
244
+ when ,
245
+ locale ,
246
+ ) {
189
247
  const words =
190
248
  GATE_WORDS[locale.split("-")[0] ?? locale] ??
191
249
  (GATE_WORDS.en );
192
- return `<p class="ch-gate-notice" role="status" data-gate="${notice.state}" data-gate-at="${esc(notice.at)}">${esc(words[notice.state](notice.when))}</p>`;
250
+ return `<p class="ch-gate-notice" role="status" data-gate="${state}" data-gate-at="${esc(at)}">${esc(words[state](when))}</p>`;
251
+ }
252
+
253
+ /**
254
+ * The notice for an entry past its collection's expiry at `now` (RFC-0042 §3.3): "Ended on …"
255
+ * for `unlist`, "Expired on …" for `hide`; empty before it, or when its own gates already speak.
256
+ */
257
+ export function derivedGateNoticeHtml(
258
+ site ,
259
+ entry ,
260
+ now ,
261
+ locale = site.defaultLocale,
262
+ ) {
263
+ const gate = derivedGate(site, entry);
264
+ if (!gate || now < gate.at) return "";
265
+ const at = new Date(gate.at).toISOString();
266
+ const state = gate.action === "hide" ? "expired" : "ended";
267
+ return noticeHtml(state, at, formatGateTime(at, site, locale), locale);
193
268
  }
194
269
 
195
270
  /**
@@ -206,7 +281,7 @@ export function renderPagePreview(
206
281
  const ctx = previewMedia(site, media);
207
282
  const body =
208
283
  gateNoticeHtml(site, page, now) +
209
- page.sections.map((s) => renderSectionHtml(s, entries, ctx)).join("\n");
284
+ page.sections.map((s) => renderSectionHtml(s, entries, ctx, { site, now })).join("\n");
210
285
  const title = page.seo?.title ?? page.title;
211
286
  return { title, path: page.path, html: document(site, title, page.seo?.description, body) };
212
287
  }
@@ -233,7 +308,7 @@ export function renderEntryPreview(
233
308
  now = Date.now(),
234
309
  ) {
235
310
  const body =
236
- gateNoticeHtml(site, entry, now) +
311
+ (gateNoticeHtml(site, entry, now) || derivedGateNoticeHtml(site, entry, now)) +
237
312
  renderEntryArticle(entry, site.defaultLocale, previewMedia(site, media));
238
313
  return {
239
314
  title: entry.title,
@@ -99,7 +99,7 @@ export declare function redirectPaths(redirects: readonly Redirect[], served: re
99
99
  export interface StaticPaths {
100
100
  /** For the catch-all page route: pages, entries, archive pages, then paths that redirect. */
101
101
  readonly pages: string[];
102
- /** For the term feed route (`<archive>/rss.xml`). */
102
+ /** For the term feed route (`<archive>/rss.xml`), then each collection's (`<prefix>/rss.xml`). */
103
103
  readonly feeds: string[];
104
104
  }
105
105
  /**
@@ -18,6 +18,8 @@ import {
18
18
  parseArchivePath,
19
19
  termForSlug,
20
20
  } from "./archive.js";
21
+ import { collectionFeedPaths } from "./collection-feeds.js";
22
+ import { routableEntries } from "./entry-views.js";
21
23
  import { PREVIEW_PARAM } from "./resolver.js";
22
24
  import { searchRequest } from "./search.js";
23
25
 
@@ -71,7 +73,8 @@ export async function routablePaths(source , locale )
71
73
  const loc = locale ?? site.defaultLocale;
72
74
  const pagePaths = pages.filter((p) => p.locale === loc).map((p) => p.path);
73
75
  const taken = new Set(pagePaths);
74
- const entryPaths = (await source.allEntries(loc))
76
+ // RFC-0042 §3: an unlisted entry keeps its URL (static builds write it), only lists drop it.
77
+ const entryPaths = (await routableEntries(source, loc))
75
78
  .map((e) => entryPath(site, e))
76
79
  .filter((p) => !taken.has(p));
77
80
  return [...pagePaths, ...entryPaths];
@@ -259,7 +262,7 @@ export function redirectPaths(redirects , served
259
262
 
260
263
 
261
264
 
262
-
265
+
263
266
 
264
267
 
265
268
 
@@ -291,7 +294,14 @@ export async function staticPaths(
291
294
  )
292
295
  .filter((p) => !taken.has(p));
293
296
  const served = [...base, ...archivePages];
294
- const feeds = archives.flatMap((a) => (a.feedPath ? [a.feedPath] : []));
297
+ // RFC-0042 §5: each collection's feed too (the starter's feed route answers 404 for it, and the
298
+ // renderer's middleware answers with the feed), so old theme copies write it as well.
299
+ const feeds = [
300
+ ...new Set([
301
+ ...archives.flatMap((a) => (a.feedPath ? [a.feedPath] : [])),
302
+ ...collectionFeedPaths(site, entries),
303
+ ]),
304
+ ];
295
305
  // `…/page/1` answers with a 301 to the archive root (a meta-refresh page in static builds).
296
306
  const firstPages = archives.map((a) => `${a.path}/page/1`);
297
307
  return {
package/dist/src/seo.d.ts CHANGED
@@ -7,6 +7,10 @@ import type { ContentEntry, ImageRef, Page, Site } from "@cloudhal/core-contract
7
7
  import type { ArchiveView } from "./archive.js";
8
8
  import { type MediaContext } from "./media.js";
9
9
  import { type EntryTaxonomy, type ShownTerm } from "./taxonomy.js";
10
+ /** RFC-0042 §5: the `<link rel="alternate">` of a collection's feed. */
11
+ export { collectionFeedLink, type FeedLink } from "./collection-feeds.js";
12
+ /** RFC-0042 §2: a collection's JSON-LD preset in place of the generic `BlogPosting`. */
13
+ export { entryStructuredData, type StructuredDataOptions, withStructuredData, } from "./structured-data.js";
10
14
  export interface HeadMeta {
11
15
  /** `<title>`. */
12
16
  title: string;
@@ -82,4 +86,3 @@ export declare function archiveHead(site: Site, view: ArchiveView, origin: strin
82
86
  * (English for languages without them).
83
87
  */
84
88
  export declare function searchHead(site: Site, query: string, origin: string, locale?: string): HeadMeta;
85
- export {};
package/dist/src/seo.js CHANGED
@@ -10,6 +10,15 @@ import { inlineMarkdownText, markdownText, safeSrc } from "./markdown.js";
10
10
  import { assetAlt, imageObject, socialImageUrl } from "./media.js";
11
11
  import { entryTaxonomy, } from "./taxonomy.js";
12
12
 
13
+ /** RFC-0042 §5: the `<link rel="alternate">` of a collection's feed. */
14
+ export { collectionFeedLink, } from "./collection-feeds.js";
15
+ /** RFC-0042 §2: a collection's JSON-LD preset in place of the generic `BlogPosting`. */
16
+ export {
17
+ entryStructuredData,
18
+
19
+ withStructuredData,
20
+ } from "./structured-data.js";
21
+
13
22
 
14
23
 
15
24