@jxsuite/feed 0.3.3 → 0.3.4
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 +24 -24
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -6,10 +6,10 @@
|
|
|
6
6
|
|
|
7
7
|
`@jxsuite/feed` is the Jx extension that turns a content collection into something readers
|
|
8
8
|
subscribe to. It contributes one class (`Feed`) and one project.json section, both reached through
|
|
9
|
-
`jx-extension.json
|
|
9
|
+
`jx-extension.json`, which names the class descriptor (`src/Feed.class.json`, whose `project` block
|
|
10
10
|
declares the section key) and the schema fragment that gives the section its shape:
|
|
11
11
|
|
|
12
|
-
- **`feed
|
|
12
|
+
- **`feed`**: a map of feed name → feed object. Each entry names its `collection`, the `basePath`
|
|
13
13
|
its entries are served under, and optional metadata (`title`, `description`, `author`), output
|
|
14
14
|
shape (`formats`, `output`, `pageSize`, `archive`, `contentMode`), frontmatter field names
|
|
15
15
|
(`dateField`, `updatedField`) and `language`. The schema
|
|
@@ -25,7 +25,7 @@ specs/extensions.md §1 exists to prevent. The capability contracts are specs/ex
|
|
|
25
25
|
(`emit`) and §8.6 (`head`). User docs:
|
|
26
26
|
[/docs/framework/site/feeds](https://jxsuite.com/docs/framework/site/feeds).
|
|
27
27
|
|
|
28
|
-
**Atom 1.0 (RFC 4287) and JSON Feed 1.1. RSS 2.0 is deliberately not offered
|
|
28
|
+
**Atom 1.0 (RFC 4287) and JSON Feed 1.1. RSS 2.0 is deliberately not offered**: no standards body,
|
|
29
29
|
unsettled `<guid>` semantics, and every reader handles Atom. All three standards this package binds
|
|
30
30
|
(RFC 4287, JSON Feed 1.1, RFC 5005) are recorded as **Subset** in the Standards Alignment table of
|
|
31
31
|
specs/site-architecture.md, each with an explicit list of what is not implemented. Read those rows
|
|
@@ -64,27 +64,27 @@ its collection key. A default build writes `dist/feed.xml` and `dist/feed.json`,
|
|
|
64
64
|
`src/Feed.class.json` declares three capabilities, all implemented by the plain object exported as
|
|
65
65
|
`Feed` from `src/feed.ts`:
|
|
66
66
|
|
|
67
|
-
- **`projectData(sectionValue, ctx?)
|
|
67
|
+
- **`projectData(sectionValue, ctx?)`**: timing `["compiler", "server"]`, the only one that also
|
|
68
68
|
runs on the server. Normalizes the section (defaults applied) into `_project.feed`.
|
|
69
|
-
- **`head(sectionValue, ctx)
|
|
70
|
-
configured format
|
|
69
|
+
- **`head(sectionValue, ctx)`**: timing `["compiler"]`. Returns one `<link rel="alternate">` per
|
|
70
|
+
configured format (one per format _and_ locale when the collection is localized), typed
|
|
71
71
|
`application/atom+xml` / `application/feed+json` and titled with the feed's `title` (or
|
|
72
72
|
`"Feed"`). Both links survive `<head>` dedup because the merger keys a link on `rel` plus `href`
|
|
73
73
|
plus whichever of `hreflang`, `type`, `media` or `sizes` is present
|
|
74
|
-
(specs/site-architecture.md §8.3)
|
|
74
|
+
(specs/site-architecture.md §8.3). For two formats that qualifier is `type`; for a localized
|
|
75
75
|
feed it is `hreflang`, and the links differ by `href` anyway.
|
|
76
|
-
- **`emit(sectionValue, ctx)
|
|
76
|
+
- **`emit(sectionValue, ctx)`**: timing `["compiler"]`. Returns `{ path, content }[]`; the host
|
|
77
77
|
writes them.
|
|
78
78
|
|
|
79
79
|
`head` exists separately from `emit` because the two answer different questions at different times
|
|
80
80
|
(specs/extensions.md §8.6): `head` derives entries from **configuration** and runs once before the
|
|
81
81
|
first page is built, while `emit` derives files from loaded content and runs after the last page has
|
|
82
|
-
been written
|
|
82
|
+
been written, too late to reach any `<head>`.
|
|
83
83
|
|
|
84
84
|
## Emission model
|
|
85
85
|
|
|
86
|
-
Everything happens inside the compiler's site build. `emit` runs at step 6e
|
|
87
|
-
components and the worker are generated, and before redirects and the `public/` copy
|
|
86
|
+
Everything happens inside the compiler's site build. `emit` runs at step 6e: after routes,
|
|
87
|
+
components and the worker are generated, and before redirects and the `public/` copy. The **host**
|
|
88
88
|
writes the returned records under `outDir` (paths are outDir-relative, a leading `/` is tolerated,
|
|
89
89
|
and a path escaping `outDir` is a build error). The package never touches the filesystem, which is
|
|
90
90
|
what makes both serializers testable against a literal array of items.
|
|
@@ -92,14 +92,14 @@ what makes both serializers testable against a literal array of items.
|
|
|
92
92
|
Consequences worth knowing:
|
|
93
93
|
|
|
94
94
|
- The `public/` copy runs after `emit`, so a same-named file in `public/` shadows an emitted feed.
|
|
95
|
-
- The compiler writes `_headers` Content-Type rules
|
|
96
|
-
`/feed.xml` and `/feed/archive/*`, `application/feed+json; charset=utf-8` for `/feed.json
|
|
97
|
-
only for files the build produced, and the names it looks for are the **default**
|
|
98
|
-
(`packages/compiler/src/site/headers-emitter.ts`). A custom `output` gets no rule.
|
|
95
|
+
- The compiler writes `_headers` Content-Type rules: `application/atom+xml; charset=utf-8` for
|
|
96
|
+
`/feed.xml` and `/feed/archive/*`, `application/feed+json; charset=utf-8` for `/feed.json`. It
|
|
97
|
+
writes them only for files the build produced, and the names it looks for are the **default**
|
|
98
|
+
ones (`packages/compiler/src/site/headers-emitter.ts`). A custom `output` gets no rule.
|
|
99
99
|
|
|
100
100
|
Subpath exports (`@jxsuite/feed/atom`, `/json-feed`, `/shared`) resolve to TypeScript source, so the
|
|
101
|
-
serializers and the pure feed model
|
|
102
|
-
`feedUpdated`, `paginate`, `feedPath
|
|
101
|
+
serializers and the pure feed model are importable on their own: `normalizeFeedConfig`,
|
|
102
|
+
`entryToItem`, `sortItems`, `feedUpdated`, `paginate`, `feedPath`.
|
|
103
103
|
|
|
104
104
|
## Surprises
|
|
105
105
|
|
|
@@ -107,7 +107,7 @@ serializers and the pure feed model — `normalizeFeedConfig`, `entryToItem`, `s
|
|
|
107
107
|
older entries are then published nowhere. `archive: true` is what preserves them.
|
|
108
108
|
- **Archives are chunked from the oldest end.** Chunking from the newest would reshuffle every
|
|
109
109
|
boundary on each new entry; counting from the oldest means archive 1 keeps its contents forever
|
|
110
|
-
and only the newest archive changes
|
|
110
|
+
and only the newest archive changes. RFC 5005 §2 asks that a published archive not change.
|
|
111
111
|
- **`<fh:complete/>` needs no archives _and_ nothing trimmed.** A document trimmed by `pageSize`
|
|
112
112
|
with archives off is not complete, and says so by omission.
|
|
113
113
|
- **RFC 5005 archives are Atom-only.** The JSON Feed branch writes exactly one document and never
|
|
@@ -117,8 +117,8 @@ serializers and the pure feed model — `normalizeFeedConfig`, `entryToItem`, `s
|
|
|
117
117
|
guess. Give the collection schema `"format": "date"` so the parser's date coercion
|
|
118
118
|
(`coerceEntryDates`, specs/parser.md §9.3) normalizes the field first. An entry with no readable
|
|
119
119
|
date falls back to `_meta.mtime`.
|
|
120
|
-
- **The feed-level `<updated>` is the newest item, never the build time
|
|
121
|
-
build re-notifies every subscriber on every deploy. An empty feed renders
|
|
120
|
+
- **The feed-level `<updated>` is the newest item, never the build time**, because a feed stamped
|
|
121
|
+
with the build re-notifies every subscriber on every deploy. An empty feed renders
|
|
122
122
|
`<updated>1970-01-01T00:00:00Z</updated>`.
|
|
123
123
|
- **A localized collection is several feeds, not one, and this is not configurable.** When the named
|
|
124
124
|
collection's `source` contains `{locale}`, each language is published in its own URL prefix
|
|
@@ -128,17 +128,17 @@ serializers and the pure feed model — `normalizeFeedConfig`, `entryToItem`, `s
|
|
|
128
128
|
know which locale its page is in.
|
|
129
129
|
- **`contentMode` branches only on `"full"`** (`src/shared.ts`), which is what adds
|
|
130
130
|
`<content type="html">` / `content_html`; the summary is emitted either way. A third value,
|
|
131
|
-
`"none"`, was accepted until 0.3.0 and did nothing
|
|
131
|
+
`"none"`, was accepted until 0.3.0 and did nothing. JSON Feed 1.1 requires one of
|
|
132
132
|
`content_html`/`content_text`, so "omit the content" was never expressible.
|
|
133
133
|
- **A feed naming a collection that is not loaded is skipped with a console warning**, not a build
|
|
134
134
|
error.
|
|
135
|
-
- **The schema requires `collection` and `basePath`, but the runtime tolerates their absence
|
|
135
|
+
- **The schema requires `collection` and `basePath`, but the runtime tolerates their absence**:
|
|
136
136
|
`collection` falls back to the section key and `basePath` to `"/"`. Validation, not
|
|
137
137
|
`normalizeFeedConfig`, is what enforces them.
|
|
138
138
|
|
|
139
139
|
## Versioning
|
|
140
140
|
|
|
141
|
-
Published to npm as `@jxsuite/feed
|
|
141
|
+
Published to npm as `@jxsuite/feed`, TypeScript source like every `@jxsuite` package, following
|
|
142
142
|
the monorepo's release train. Its only runtime dependency is `@jxsuite/schema`; extensions may
|
|
143
|
-
depend on core packages but never the reverse
|
|
143
|
+
depend on core packages but never the reverse: no core package lists this one as a runtime
|
|
144
144
|
dependency or imports it from `src/`, and `scripts/check-dep-rules.ts` enforces that.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jxsuite/feed",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.4",
|
|
4
4
|
"description": "Syndication feeds for Jx: Atom (RFC 4287) and JSON Feed emitted from content collections at build time",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -32,10 +32,10 @@
|
|
|
32
32
|
"build": "bun run prepare",
|
|
33
33
|
"test": "bun test --isolate",
|
|
34
34
|
"test:coverage": "bun test --isolate --coverage",
|
|
35
|
-
"upgrade": "
|
|
35
|
+
"upgrade": "bun update --latest && bun install"
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@jxsuite/schema": "^
|
|
38
|
+
"@jxsuite/schema": "^2.0.0"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
41
|
"ajv": "^8.20.0"
|