@cloudhal/astro-renderer 0.3.12 → 0.4.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/README.md +3 -0
- package/dist/src/feeds.d.ts +2 -1
- package/dist/src/feeds.js +39 -35
- package/dist/src/routing.d.ts +2 -0
- package/dist/src/routing.js +2 -0
- package/package.json +6 -6
package/README.md
CHANGED
|
@@ -27,6 +27,9 @@ const page = await source.pageByPath(Astro.params.path ? `/${Astro.params.path}`
|
|
|
27
27
|
|
|
28
28
|
`.astro` files ship as source (no build step); the consumer's Astro compiles them. `astro` is a peer dependency.
|
|
29
29
|
|
|
30
|
+
## Theme-facing API stability
|
|
31
|
+
`cloudhal init` copies `starters/blog/src` into each project, so a site keeps calling this package's exports (and `@cloudhal/core-ts`'s) as they were when it was created. Every export a theme imports is therefore a public API: never change its meaning under the same name. A breaking change keeps a deprecated fallback for the old call. In 0.3.11 `entryPath(entry)` became `entryPath(site, entry)` without one, and every site with an older theme copy rendered empty pages until 0.3.13 restored it. `packages/cli/test/old-theme-compat.test.ts` builds frozen copies of earlier starters (`packages/cli/test/fixtures/theme-v*/`) with today's packages. Add a new frozen copy when a release changes theme-facing APIs.
|
|
32
|
+
|
|
30
33
|
## Site analytics (RFC-0006)
|
|
31
34
|
|
|
32
35
|
The renderer carries the site side of Cloudhal's cookie-less analytics (`@cloudhal/analytics`):
|
package/dist/src/feeds.d.ts
CHANGED
|
@@ -58,7 +58,8 @@ export interface SitemapUrl {
|
|
|
58
58
|
* What belongs in `sitemap.xml`: published pages and entries of the default locale, and the
|
|
59
59
|
* indexable term archives (page 1 only, `lastmod` = the later of the newest listed entry and the
|
|
60
60
|
* term; see `archiveSummaries` — pass it published entries). Pages and archives asking for
|
|
61
|
-
* `noindex`, or canonicalised to another URL, are left out (a sitemap lists canonical URLs)
|
|
61
|
+
* `noindex`, or canonicalised to another URL, are left out (a sitemap lists canonical URLs), and so
|
|
62
|
+
* are the entries of collections with `sitemap: false` (RFC-0040).
|
|
62
63
|
*/
|
|
63
64
|
export declare function sitemapUrls(site: Site, pages: Page[], entries: ContentEntry[], origin: string, archives?: readonly ArchiveSummary[]): SitemapUrl[];
|
|
64
65
|
/**
|
package/dist/src/feeds.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* published only, noindex respected, canonical elsewhere excluded — live in one tested place.
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
import { entryPath } from "@cloudhal/core-ts";
|
|
7
|
+
import { collectionSettings, entryPath } from "@cloudhal/core-ts";
|
|
8
8
|
|
|
9
9
|
import { markdownText, renderBody } from "./markdown.js";
|
|
10
10
|
|
|
@@ -72,39 +72,41 @@ export function rssXml(options ) {
|
|
|
72
72
|
const { site, origin } = options;
|
|
73
73
|
const base = options.linkOrigin ?? origin;
|
|
74
74
|
const self = `${base}${options.feedPath ?? "/rss.xml"}`;
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
75
|
+
// RFC-0040: a collection with `feed: false` stays out of every feed.
|
|
76
|
+
const shown = published(options.entries).filter(
|
|
77
|
+
(e) => collectionSettings(site, e.collection).feed,
|
|
78
|
+
);
|
|
79
|
+
const items = shown.slice(0, FEED_LIMIT).map((e) => {
|
|
80
|
+
const url = `${base}${entryPath(site, e)}`;
|
|
81
|
+
const date = new Date(e.publishedAt ?? e.createdAt).toUTCString();
|
|
82
|
+
const cover = e.coverImage?.assetId ? options.assets?.get(e.coverImage.assetId) : undefined;
|
|
83
|
+
const image = cover
|
|
84
|
+
? absoluteUrl(
|
|
85
|
+
origin,
|
|
86
|
+
cover.storage.kind === "external" ? cover.storage.url : e.coverImage?.src,
|
|
87
|
+
)
|
|
88
|
+
: absoluteUrl(origin, e.coverImage?.src);
|
|
89
|
+
const mediaAttrs = cover
|
|
90
|
+
? ` type="${xml(cover.mediaType)}" fileSize="${cover.bytes}"${cover.image ? ` width="${cover.image.width}" height="${cover.image.height}"` : ""}`
|
|
91
|
+
: "";
|
|
92
|
+
const author = e.author.kind === "human" && e.author.name ? e.author.name : site.name;
|
|
93
|
+
return [
|
|
94
|
+
"<item>",
|
|
95
|
+
`<title>${xml(e.title)}</title>`,
|
|
96
|
+
`<link>${xml(url)}</link>`,
|
|
97
|
+
`<guid isPermaLink="true">${xml(url)}</guid>`,
|
|
98
|
+
`<pubDate>${date}</pubDate>`,
|
|
99
|
+
`<dc:creator>${cdata(author)}</dc:creator>`,
|
|
100
|
+
...itemCategories(e, options.taxonomy).map((t) => `<category>${xml(t)}</category>`),
|
|
101
|
+
e.summary ? `<description>${cdata(e.summary)}</description>` : "",
|
|
102
|
+
image ? `<media:content url="${xml(image)}" medium="image"${mediaAttrs}/>` : "",
|
|
103
|
+
`<content:encoded>${cdata(renderBody(e.body, options.assets ? { assets: options.assets, locale: e.locale, defaultLocale: site.defaultLocale } : undefined))}</content:encoded>`,
|
|
104
|
+
"</item>",
|
|
105
|
+
]
|
|
106
|
+
.filter(Boolean)
|
|
107
|
+
.join("");
|
|
108
|
+
});
|
|
109
|
+
const newest = shown[0];
|
|
108
110
|
return [
|
|
109
111
|
'<?xml version="1.0" encoding="UTF-8"?>',
|
|
110
112
|
'<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:media="http://search.yahoo.com/mrss/">',
|
|
@@ -160,7 +162,8 @@ export function archiveFeedXml(
|
|
|
160
162
|
* What belongs in `sitemap.xml`: published pages and entries of the default locale, and the
|
|
161
163
|
* indexable term archives (page 1 only, `lastmod` = the later of the newest listed entry and the
|
|
162
164
|
* term; see `archiveSummaries` — pass it published entries). Pages and archives asking for
|
|
163
|
-
* `noindex`, or canonicalised to another URL, are left out (a sitemap lists canonical URLs)
|
|
165
|
+
* `noindex`, or canonicalised to another URL, are left out (a sitemap lists canonical URLs), and so
|
|
166
|
+
* are the entries of collections with `sitemap: false` (RFC-0040).
|
|
164
167
|
*/
|
|
165
168
|
export function sitemapUrls(
|
|
166
169
|
site ,
|
|
@@ -183,6 +186,7 @@ export function sitemapUrls(
|
|
|
183
186
|
for (const entry of published(entries)) {
|
|
184
187
|
const path = entryPath(site, entry);
|
|
185
188
|
if (entry.locale !== site.defaultLocale || seen.has(path)) continue;
|
|
189
|
+
if (!collectionSettings(site, entry.collection).sitemap) continue;
|
|
186
190
|
seen.add(path);
|
|
187
191
|
urls.push({ loc: `${origin}${path}`, lastmod: entry.updatedAt });
|
|
188
192
|
}
|
package/dist/src/routing.d.ts
CHANGED
|
@@ -12,6 +12,8 @@ import { type ArchiveSummary, type ArchiveView } from "./archive.js";
|
|
|
12
12
|
import { type SearchView } from "./search.js";
|
|
13
13
|
import type { GraphSource } from "./source.js";
|
|
14
14
|
import { type TaxonomyIndex } from "./taxonomy.js";
|
|
15
|
+
/** RFC-0040: a collection's labels and settings with defaults, for themes. */
|
|
16
|
+
export { collectionLabel, collectionSettings } from "@cloudhal/core-ts/collections";
|
|
15
17
|
/** Themes link entries with core-ts's `entryPath(site, entry)`; re-exported for them. */
|
|
16
18
|
export { entryAt, entryPath };
|
|
17
19
|
export type Resolved = {
|
package/dist/src/routing.js
CHANGED
|
@@ -32,6 +32,8 @@ import {
|
|
|
32
32
|
taxonomyIndex,
|
|
33
33
|
} from "./taxonomy.js";
|
|
34
34
|
|
|
35
|
+
/** RFC-0040: a collection's labels and settings with defaults, for themes. */
|
|
36
|
+
export { collectionLabel, collectionSettings } from "@cloudhal/core-ts/collections";
|
|
35
37
|
/** Themes link entries with core-ts's `entryPath(site, entry)`; re-exported for them. */
|
|
36
38
|
export { entryAt, entryPath };
|
|
37
39
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cloudhal/astro-renderer",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "Render a Cloudhal Site Graph with Astro: data sources (live/snapshot), section components and the cloudhal() integration",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"homepage": "https://cloudhal.dev",
|
|
@@ -179,14 +179,14 @@
|
|
|
179
179
|
"README.md"
|
|
180
180
|
],
|
|
181
181
|
"dependencies": {
|
|
182
|
-
"@cloudhal/core-contracts": "0.
|
|
183
|
-
"@cloudhal/core-ts": "0.
|
|
184
|
-
"@cloudhal/storage": "0.
|
|
182
|
+
"@cloudhal/core-contracts": "0.4.0",
|
|
183
|
+
"@cloudhal/core-ts": "0.4.0",
|
|
184
|
+
"@cloudhal/storage": "0.4.0",
|
|
185
185
|
"marked": "^18.1.0",
|
|
186
186
|
"parse5": "8.0.1",
|
|
187
|
-
"@cloudhal/analytics": "0.
|
|
187
|
+
"@cloudhal/analytics": "0.4.0",
|
|
188
188
|
"vite": "^8.3.3",
|
|
189
|
-
"@cloudhal/comments": "0.
|
|
189
|
+
"@cloudhal/comments": "0.4.0"
|
|
190
190
|
},
|
|
191
191
|
"peerDependencies": {
|
|
192
192
|
"astro": "^7.3.0",
|